public override IDisplayResult Edit(TaxonomyField field, BuildFieldEditorContext context) { return(Initialize <EditTagTaxonomyFieldViewModel>(GetEditorShapeType(context), async model => { var settings = context.PartFieldDefinition.GetSettings <TaxonomyFieldSettings>(); model.Taxonomy = await _contentManager.GetAsync(settings.TaxonomyContentItemId, VersionOptions.Latest); if (model.Taxonomy != null) { var termEntries = new List <TermEntry>(); TaxonomyFieldDriverHelper.PopulateTermEntries(termEntries, field, model.Taxonomy.As <TaxonomyPart>().Terms, 0); var tagTermEntries = termEntries.Select(te => new TagTermEntry { ContentItemId = te.ContentItemId, Selected = te.Selected, DisplayText = te.Term.DisplayText, IsLeaf = te.IsLeaf }); model.TagTermEntries = JsonConvert.SerializeObject(tagTermEntries, SerializerSettings); } model.Field = field; model.Part = context.ContentPart; model.PartFieldDefinition = context.PartFieldDefinition; })); }
public override IDisplayResult Edit(TaxonomyField field, BuildFieldEditorContext context) { return(Initialize <EditTaxonomyFieldViewModel>(GetEditorShapeType(context), async model => { var settings = context.PartFieldDefinition.GetSettings <TaxonomyFieldSettings>(); model.Taxonomy = await _contentManager.GetAsync(settings.TaxonomyContentItemId, VersionOptions.Latest); if (model.Taxonomy != null) { var termEntries = new List <TermEntry>(); TaxonomyFieldDriverHelper.PopulateTermEntries(termEntries, field, model.Taxonomy.As <TaxonomyPart>().Terms, 0); model.TermEntries = termEntries; } model.Field = field; model.Part = context.ContentPart; model.PartFieldDefinition = context.PartFieldDefinition; })); }