public BuildFieldDisplayContext(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildDisplayContext context)
     : base(context.Shape, context.DisplayType, context.GroupId, context.ShapeFactory, context.Layout, context.Updater)
 {
     ContentPart = contentPart;
     TypePartDefinition = typePartDefinition;
     PartFieldDefinition = partFieldDefinition;
 }
 public Task BuildPartFieldEditorAsync(ContentPartFieldDefinition model, BuildEditorContext context)
 {
     return _partFieldDisplayDrivers.InvokeAsync(async contentDisplay =>
     {
         var result = await contentDisplay.BuildEditorAsync(model, context);
         if (result != null)
             result.Apply(context);
     }, Logger);
 }
        public Task<dynamic> UpdatePartFieldEditorAsync(ContentPartFieldDefinition contentPartFieldDefinition, IUpdateModel updater, string groupId = "")
        {
            if (contentPartFieldDefinition == null)
            {
                throw new ArgumentNullException(nameof(contentPartFieldDefinition));
            }

            var contentPartDefinition = contentPartFieldDefinition.PartDefinition;
            dynamic partFieldDefinitionShape = CreateContentShape("ContentPartFieldDefinition_Edit");

            _contentDefinitionManager.AlterPartDefinition(contentPartDefinition.Name, partBuilder =>
            {
                partBuilder.WithField(contentPartFieldDefinition.Name, async partFieldBuilder =>
                {
                    partFieldDefinitionShape.ContentField = contentPartFieldDefinition;

                    var fieldContext = new UpdatePartFieldEditorContext(
                        partFieldBuilder,
                        partFieldDefinitionShape,
                        groupId,
                        _shapeFactory,
                        _layoutAccessor.GetLayout(),
                        updater
                    );

                    await BindPlacementAsync(fieldContext);

                    await _handlers.InvokeAsync(handler => handler.UpdatePartFieldEditorAsync(contentPartFieldDefinition, fieldContext), Logger);
                });
            });

            return Task.FromResult<dynamic>(partFieldDefinitionShape);
        }
 public UpdateFieldEditorContext(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, UpdateEditorContext context)
     : base(contentPart, typePartDefinition, partFieldDefinition, context)
 {
 }
        public async Task<dynamic> BuildPartFieldEditorAsync(ContentPartFieldDefinition contentPartFieldDefinition, IUpdateModel updater, string groupId = "")
        {
            if (contentPartFieldDefinition == null)
            {
                throw new ArgumentNullException(nameof(contentPartFieldDefinition));
            }

            dynamic partFieldDefinitionShape = CreateContentShape("ContentPartFieldDefinition_Edit");
            partFieldDefinitionShape.ContentField = contentPartFieldDefinition;

            var fieldContext = new BuildEditorContext(
                partFieldDefinitionShape,
                groupId,
                _shapeFactory,
                _layoutAccessor.GetLayout(),
                updater
            );

            await BindPlacementAsync(fieldContext);

            await _handlers.InvokeAsync(handler => handler.BuildPartFieldEditorAsync(contentPartFieldDefinition, fieldContext), Logger);

            return partFieldDefinitionShape;
        }
 private void Apply(ContentPartFieldDefinition model, ContentPartFieldDefinitionRecord record)
 {
     record.Settings = model.Settings;
 }
        protected ContentPartFieldDefinitionBuilder(ContentPartFieldDefinition field)
        {
            Current = field;

            _settings = new JObject(field.Settings);
        }
 public ContentPartDefinitionBuilder WithField(string fieldName, Action<ContentPartFieldDefinitionBuilder> configuration)
 {
     var existingField = _fields.FirstOrDefault(x => x.Name == fieldName);
     if (existingField != null)
     {
         var toRemove = _fields.Where(x => x.Name == fieldName).ToArray();
         foreach (var remove in toRemove)
         {
             _fields.Remove(remove);
         }
     }
     else
     {
         existingField = new ContentPartFieldDefinition(null, fieldName, new JObject());
     }
     var configurer = new FieldConfigurerImpl(existingField, _part);
     configuration(configurer);
     _fields.Add(configurer.Build());
     return this;
 }
 public FieldConfigurerImpl(ContentPartFieldDefinition field, ContentPartDefinition part)
     : base(field)
 {
     _fieldDefinition = field.FieldDefinition;
     _fieldName = field.Name;
     _partDefinition = part;
 }