public Task <dynamic> UpdateTypeEditorAsync(ContentTypeDefinition contentTypeDefinition, IUpdateModel updater, string groupId) { if (contentTypeDefinition == null) { throw new ArgumentNullException(nameof(contentTypeDefinition)); } dynamic contentTypeDefinitionShape = CreateContentShape("ContentTypeDefinition_Edit"); contentTypeDefinitionShape.ContentTypeDefinition = contentTypeDefinition; _contentDefinitionManager.AlterTypeDefinition(contentTypeDefinition.Name, typeBuilder => { var typeContext = new UpdateTypeEditorContext( typeBuilder, contentTypeDefinitionShape, groupId, _shapeFactory, _layoutAccessor.GetLayout(), updater ); BindPlacementAsync(typeContext).Wait(); _handlers.InvokeAsync(handler => handler.UpdateTypeEditorAsync(contentTypeDefinition, typeContext), Logger).Wait(); }); return(Task.FromResult <dynamic>(contentTypeDefinitionShape)); }
public Task UpdateTypeEditorAsync(ContentTypeDefinition model, UpdateTypeEditorContext context) { return(_typeDisplayDrivers.InvokeAsync(async contentDisplay => { var result = await contentDisplay.UpdateEditorAsync(model, context); if (result != null) { result.Apply(context); } }, Logger)); }
public override async Task <IDisplayResult> UpdateAsync(ContentTypeDefinition contentTypeDefinition, UpdateTypeEditorContext context) { var model = new ContentTypeViewModel(); await context.Updater.TryUpdateModelAsync(model, Prefix); context.Builder.DisplayedAs(model.DisplayName); if (String.IsNullOrWhiteSpace(model.DisplayName)) { context.Updater.ModelState.AddModelError("DisplayName", T["The Content Type name can't be empty."]); } return(Edit(contentTypeDefinition, context.Updater)); }
public Task <dynamic> UpdateTypeEditorAsync(ContentTypeDefinition contentTypeDefinition, IUpdateModel updater, string groupId) { if (contentTypeDefinition == null) { throw new ArgumentNullException(nameof(contentTypeDefinition)); } var contentTypeDefinitionShape = _shapeFactory.Create <ContentTypeDefinitionViewModel>("ContentTypeDefinition"); _contentDefinitionManager.AlterTypeDefinition(contentTypeDefinition.Name, typeBuilder => { contentTypeDefinitionShape.ContentTypeDefinition = contentTypeDefinition; dynamic typeShape = CreateContentShape("ContentTypeDefinition_Edit"); var typeContext = new UpdateTypeEditorContext( typeBuilder, typeShape, groupId, _shapeFactory, _layoutAccessor.GetLayout(), updater ); foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { // Don't show the type's private part as it can't be removed or configured if (String.Equals(contentTypePartDefinition.PartDefinition.Name, contentTypeDefinition.Name, StringComparison.Ordinal)) { continue; } dynamic partShape = CreateContentShape("ContentTypePartDefinition_Edit"); typeBuilder.WithPart(contentTypePartDefinition.PartDefinition.Name, typePartBuilder => { partShape.ContentPart = contentTypePartDefinition; var partContext = new UpdateTypePartEditorContext( typePartBuilder, partShape, groupId, _shapeFactory, _layoutAccessor.GetLayout(), updater ); BindPlacementAsync(partContext).Wait(); _handlers.InvokeAsync(handler => handler.UpdateTypePartEditorAsync(contentTypePartDefinition, partContext), Logger).Wait(); contentTypeDefinitionShape.TypePartSettings.Add(partContext.Shape); }); } // Global fields var globalPartDefinition = _contentDefinitionManager.GetPartDefinition(contentTypeDefinition.Name); if (globalPartDefinition != null && globalPartDefinition.Fields.Any()) { _contentDefinitionManager.AlterPartDefinition(globalPartDefinition.Name, partBuilder => { foreach (var contentPartFieldDefinition in globalPartDefinition.Fields) { dynamic fieldShape = CreateContentShape("ContentPartFieldDefinition_Edit"); partBuilder.WithField(contentPartFieldDefinition.Name, partFieldBuilder => { fieldShape.ContentField = contentPartFieldDefinition; var fieldContext = new UpdatePartFieldEditorContext( partFieldBuilder, fieldShape, groupId, _shapeFactory, _layoutAccessor.GetLayout(), updater ); BindPlacementAsync(fieldContext).Wait(); _handlers.InvokeAsync(handler => handler.UpdatePartFieldEditorAsync(contentPartFieldDefinition, fieldContext), Logger).Wait(); contentTypeDefinitionShape.TypeFieldSettings.Add(fieldContext.Shape); }); } }); } BindPlacementAsync(typeContext).Wait(); _handlers.InvokeAsync(handler => handler.UpdateTypeEditorAsync(contentTypeDefinition, typeContext), Logger).Wait(); contentTypeDefinitionShape.TypeSettings = typeShape; }); return(Task.FromResult <dynamic>(contentTypeDefinitionShape)); }
public override async Task <IDisplayResult> UpdateAsync(ContentTypeDefinition contentTypeDefinition, UpdateTypeEditorContext context) { var model = new ContentTypeSettingsViewModel(); if (await context.Updater.TryUpdateModelAsync(model, Prefix)) { context.Builder.Creatable(model.Creatable); context.Builder.Listable(model.Listable); context.Builder.Draftable(model.Draftable); context.Builder.Securable(model.Securable); context.Builder.Stereotype(model.Stereotype); } return(Edit(contentTypeDefinition, context.Updater)); }