/// <summary>
        /// We need to extend the model for content areas with available display options so our component will get a correct css class
        /// see how it's used in Assets/Scripts/components/ContentArea.vue
        /// </summary>
        private static object ConvertContentAreaItem(ContentApiModel contentApiModel, ContentAreaPropertyModel propertyModel)
        {
            var contentModelDisplayOption = propertyModel.Value.FirstOrDefault(x => x.ContentLink.Id == contentApiModel.ContentLink.Id)?.DisplayOption;

            contentApiModel.Properties.Add("displayOption", contentModelDisplayOption);
            return(contentApiModel);
        }
예제 #2
0
        /// <summary>
        /// Extends the language models with a link to each language.
        /// The links are used in Assets/Scripts/components/LanguageSelector.vue
        /// </summary>
        private void ExtendLanguageModels(ContentApiModel contentModel, IContent content)
        {
            var listPublished = _versionRepository.ListPublished(content.ContentLink);
            var listLanguagesWithPublishedContents = listPublished.Select(x => x.LanguageBranch);

            // Filter the existingLanguages list to make it contain only languages which has a published version
            contentModel.ExistingLanguages =
                contentModel.ExistingLanguages.Where(x => listLanguagesWithPublishedContents.Contains(x.Name)).Select(x => new ExtendedLanguageModel(x)
            {
                Link = ResolveUrl(content.ContentLink, x.Name)
            }).ToList <LanguageModel>();
        }
예제 #3
0
        public virtual ContentApiModel TransformContent(BlockData block)
        {
            BlockData fakeContent = this.CreateFakeContent(block);

            if (fakeContent == null)
            {
                return(null);
            }

            CopyPropertyValuesToFake(block, fakeContent);
            // ReSharper disable once SuspiciousTypeConversion.Global
            ContentApiModel contentApiModel = this.contentModelMapper.TransformContent((IContent)fakeContent);

            CleanupFakeData(contentApiModel);

            return(contentApiModel);
        }
예제 #4
0
 private static void CleanupFakeData(ContentApiModel contentApiModel)
 {
     contentApiModel.ContentLink = null;
     contentApiModel.ParentLink  = null;
     contentApiModel.Name        = null;
 }