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.Versionable(model.Versionable);
                context.Builder.Securable(model.Securable);
                context.Builder.Enabled(model.Enabled);
                context.Builder.HiddenFromPicker(model.HiddenFromPicker);
                var stereotype = model.Stereotype?.Trim();
                context.Builder.Stereotype(stereotype);
                context.Builder.Category(model.Category?.Trim());
                context.Builder.Description(model.Description?.Trim());
                context.Builder.Icon(model.Icon?.Trim());

                if (!IsAlphaNumericOrEmpty(stereotype))
                {
                    context.Updater.ModelState.AddModelError(nameof(ContentTypeSettingsViewModel.Stereotype), S["The stereotype should be alphanumeric."]);
                }
            }

            return(Edit(contentTypeDefinition));
        }
Ejemplo n.º 2
0
        public override IEnumerable <TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new ContentTypeSettingsViewModel();

            updateModel.TryUpdateModel(model, "ContentTypeSettingsViewModel", null, null);

            builder.Creatable(model.Creatable);
            builder.Draftable(model.Draftable);
            builder.WithSetting("Stereotype", model.Stereotype);

            yield return(DefinitionTemplate(model));
        }
        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));
        }
        public override IEnumerable <TemplateViewModel> TypeEditor(ContentTypeDefinition definition)
        {
            var settings = definition.Settings.ToObject <ContentTypeSettings>();
            var model    = new ContentTypeSettingsViewModel
            {
                Creatable = settings.Creatable,
                Listable  = settings.Listable,
                Draftable = settings.Draftable,
                Securable = settings.Securable,
            };

            model.Stereotype = definition.Settings.Value <string>("Stereotype") ?? "";

            yield return(DefinitionTemplate(model));
        }
Ejemplo n.º 5
0
        public override IEnumerable <TemplateViewModel> TypeEditor(ContentTypeDefinition definition)
        {
            var settings = definition.Settings.GetModel <ContentTypeSettings>();
            var model    = new ContentTypeSettingsViewModel {
                Creatable = settings.Creatable,
                Draftable = settings.Draftable,
            };

            if (definition.Settings.ContainsKey("Stereotype"))
            {
                model.Stereotype = definition.Settings["Stereotype"] ?? String.Empty;
            }

            yield return(DefinitionTemplate(model));
        }