Exemple #1
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(
            ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (_typeHasConfigPart)
            {
                var settings = new FrontendEditorConfigurationSettings();
                if (updateModel.TryUpdateModel(settings, "FrontendEditorConfigurationSettings", null, null))
                {
                    FrontendEditorConfigurationSettings.SetValues(builder, settings.AllowFrontEndEdit);

                    // Update the type settings
                    var partDefinition = _contentDefinitionManager.GetPartDefinition(builder.PartName);
                    var typeDefinition = _typeBuilder.Current;

                    // At this stage, the settings in the FieldDefinition are not updated, so the IFrontEndProfileService
                    // has no way of knowing whether the value of settings.AllowFrontEndEdit has changed. We need to pass
                    // it along to be used.
                    var fieldPlacements = GetEditorPlacement(typeDefinition, partDefinition, builder.Current, settings.AllowFrontEndEdit);
                    if (fieldPlacements.Any())
                    {
                        UpdateFrontEndPlacements(typeDefinition, fieldPlacements);
                        //// schedules a re-evaluation of the shell
                        //_settingsManagerEventHandlers.Value.Invoke(x => x.Saved(_shellSettings), Logger);
                    }
                }
                yield return(DefinitionTemplate(settings));
            }
        }
Exemple #2
0
        public override IEnumerable <TemplateViewModel> TypePartEditorUpdate(
            ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var typeDefinition = _contentDefinitionManager.GetTypeDefinition(builder.TypeName);

            if (_typeHasConfigPart ||
                typeDefinition.Parts.Any(ctpd => ctpd.PartDefinition.Name == "FrontendEditConfigurationPart"))
            {
                _typeHasConfigPart = true;
                var settings = new FrontendEditorConfigurationSettings();
                if (updateModel.TryUpdateModel(settings, "FrontendEditorConfigurationSettings", null, null))
                {
                    FrontendEditorConfigurationSettings.SetValues(builder, settings.AllowFrontEndEdit);

                    // Update the type settings
                    var partDefinition = typeDefinition.Parts
                                         .FirstOrDefault(ctpd => ctpd.PartDefinition.Name == builder.Name)?.PartDefinition;
                    if (partDefinition != null)   // sanity check
                    // At this stage, the settings in the PartDefinition are not updated, so the IFrontEndProfileService
                    // has no way of knowing whether the value of settings.AllowFrontEndEdit has changed. We need to
                    // pass it along to be used.
                    {
                        var partPlacements = GetEditorPlacement(typeDefinition, partDefinition, settings.AllowFrontEndEdit);
                        if (partPlacements.Any())
                        {
                            UpdateFrontEndPlacements(typeDefinition, partPlacements);
                            //// schedules a re-evaluation of the shell
                            //_settingsManagerEventHandlers.Value.Invoke(x => x.Saved(_shellSettings), Logger);
                        }
                    }
                }

                yield return(DefinitionTemplate(settings));
            }
        }