public override IDisplayResult Display(MatrixFieldComplex field, BuildFieldDisplayContext context)
        {
            return(Initialize <DisplayMatrixFieldComplexViewModel>(GetDisplayShapeType(context), async model =>
            {
                var fieldSettings = context.PartFieldDefinition.GetSettings <MatrixFieldComplexPredefinedListEditorSettings>();
                model.MatrixCells = _matrixTableProvider.BuildMatrixTable(fieldSettings).ToList();
                model.Field = field;
                model.BuildFieldDisplayContext = context;
                model.Settings = context.PartFieldDefinition.GetSettings <MatrixFieldComplexSettings>();
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;

                var contentItemDisplayManager = _serviceProvider.GetService <IContentItemDisplayManager>();
                // build cell display for existing items record
                foreach (var matrixCell in model.MatrixCells)
                {
                    //Get  prefix for  existing content items
                    var contentItem = field.ContentItems.FirstOrDefault(x => x.DisplayText == matrixCell.Name);
                    //Build Editor for Content Item (coming from ContentCard shape)
                    dynamic contentItemDisplayEditor = await contentItemDisplayManager.BuildDisplayAsync(contentItem, context.Updater, model.Settings.DisplayType ?? "Detail");
                    //We don't show Actions and Side bar the parent editor has its own buttons.
                    contentItemDisplayEditor.Actions = null;
                    contentItemDisplayEditor.Sidebar = null;

                    matrixCell.ContentEditor = contentItemDisplayEditor;
                }
            })
                   .Location("Content")
                   .Location("SummaryAdmin", ""));
        }
示例#2
0
 public override IDisplayResult Display(MatrixField field, BuildFieldDisplayContext context)
 {
     return(Initialize <DisplayMatrixFieldViewModel>(GetDisplayShapeType(context), model =>
     {
         var fieldSettings = context.PartFieldDefinition.GetSettings <MatrixFieldPredefinedListEditorSettings>();
         model.MatrixCells = _matrixTableProvider.BuildMatrixTable(fieldSettings).ToList();
         model.Selections = field.Selections;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     })
            .Location("Content")
            .Location("SummaryAdmin", ""));
 }