public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.FieldType != "ReferenceField") {
                yield break;
            }
            var model = new ReferenceFieldSettings();
            if (updateModel.TryUpdateModel(model, "ReferenceFieldSettings", null, null)) {
                UpdateSettings(model, builder, "ReferenceFieldSettings");

                if (model.QueryId <= 0) {
                    model.QueryId = CreateQuery(model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
                }

                if (model.RelationshipId <= 0) {
                    var httpContext = _httpContextAccessor.Current();
                    var routeValues = httpContext.Request.RequestContext.RouteData.Values;
                    var entityName = routeValues["id"].ToString();
                    model.RelationshipId = _relationshipService.CreateOneToManyRelationship(builder.Name, model.RelationshipName, model.ContentTypeName, entityName);
                }

                if (model.QueryId <= 0 || model.RelationshipId <= 0) {
                    updateModel.AddModelError("QueryOrRelation", T("Invalid Query or Relationship Id"));
                    yield break;
                }

                UpdateSettings(model, builder, "ReferenceFieldSettings");
                builder.WithSetting("ReferenceFieldSettings.DisplayAsLink", model.DisplayAsLink.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.ContentTypeName", model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.RelationshipName", model.RelationshipName.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.RelationshipId", model.RelationshipId.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("ReferenceFieldSettings.QueryId", model.QueryId.ToString(CultureInfo.InvariantCulture));
            }
            yield return DefinitionTemplate(model);
        }
Esempio n. 2
0
 // This editor method will be called when the editor form is posted.
 protected override DriverResult Editor(PersonListPart part, IUpdateModel updater, dynamic shapeHelper)
 {
     // We could check if the model state is valid through TryUpdateModel's return value, e.g. is Sex properly
     // set?
     updater?.TryUpdateModel(part, Prefix, null, null);
     return(Editor(part, shapeHelper));
 }
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (!builder.FieldType.Equals(typeof(MoneyField).Name)) yield break;

            var model = new MoneyFieldSettings();

            if (updateModel.TryUpdateModel(model, typeof(MoneyFieldSettings).Name, null, null))
            {
                if (string.IsNullOrEmpty(model.DefaultCurrency))
                {
                    builder.WithSetting("MoneyFieldSettings.DefaultCurrency", Currency.FromCurrentCulture().Iso3LetterCode);
                }
                else
                {
                    Currency parsedCurrency;
                    if (Currency.TryParse(model.DefaultCurrency, out parsedCurrency))
                    {
                        builder.WithSetting("MoneyFieldSettings.DefaultCurrency", model.DefaultCurrency);
                    }
                    else
                    {
                        updateModel.AddModelError("InvalidCurrencyIsoCode", T("MoneyField - Invalid currency iso code was given."));
                    }
                }

                builder.WithSetting("MoneyFieldSettings.IsCurrencyReadOnly", model.IsCurrencyReadOnly.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("MoneyFieldSettings.Hint", model.Hint);
                builder.WithSetting("MoneyFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
            }
            yield return DefinitionTemplate(model);
        }
Esempio n. 4
0
 public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel)
 {
     var model = new ContentPartSettings();
     updateModel.TryUpdateModel(model, "ContentPartSettings", null, null);
     builder.Attachable(model.Attachable);
     yield return DefinitionTemplate(model);
 }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "RelatedContentPart") yield break;

            var viewModel = new PropertyFieldsViewModel();
            updateModel.TryUpdateModel(viewModel, "PropertyFieldsViewModel", null, null);
            var settings = new RelatedContentRelationshipSettings();
            foreach (var relationshipFieldsModel in viewModel.Fields)
            {
                settings.DisplayName += String.Format("<field>{0}</field>", relationshipFieldsModel.DisplayName);
                settings.RelatedContentFields += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedContentFields);
                settings.RelatedcontentType += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedcontentType);
            }

            builder.WithSetting("RelatedContentRelationshipSettings.RelatedcontentType",
                settings.RelatedcontentType);
            builder.WithSetting("RelatedContentRelationshipSettings.RelatedContentFields",
                settings.RelatedContentFields);
            builder.WithSetting("RelatedContentRelationshipSettings.DisplayName",
                settings.DisplayName);

            var model = GetModel(settings);

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != typeof (TermPart).Name) yield break;

            var settings = new ExtraTermPartSettings();
            updateModel.TryUpdateModel(settings, typeof (ExtraTermPartSettings).Name, null, null);
            builder.WithSetting("ExtraTermPartSettings.OnlyDirectChildren", settings.OnlyDirectChildren.ToString());
        }
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new SecurableContentItemsSettingsViewModel();
            updateModel.TryUpdateModel(model, "SecurableContentItemsSettingsViewModel", null, null);

            builder.WithSetting("ContentPermissionsTypeSettings.SecurableContentItems", model.SecurableContentItems.ToString());

            yield return DefinitionTemplate(model);
        }
Esempio n. 8
0
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new ContentTypeSettings();
            updateModel.TryUpdateModel(model, "ContentTypeSettings", null, null);
            builder.Creatable(model.Creatable);
            builder.Draftable(model.Draftable);

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new DateTimeFieldSettings();
            if(updateModel.TryUpdateModel(model, "DateTimeFieldSettings", null, null)) {
                builder.WithSetting("DateTimeFieldSettings.Display", model.Display.ToString());
            }

            yield return DefinitionTemplate(model);
        }
Esempio n. 10
0
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new ExperimentalSettings();
            updateModel.TryUpdateModel(model, "ExperimentalSettings", null, null);
            builder
                .WithSetting("ExperimentalSettings.ShowDebugLinks", model.ShowDebugLinks ? true.ToString() : null);

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new AssociativyTaxonomiesAdapterTypeSettings();
            updateModel.TryUpdateModel(model, "AssociativyTaxonomiesAdapterTypeSettings", null, null);
            builder.WithSetting("AssociativyTaxonomiesAdapterTypeSettings.GraphNamesSerialized", model.GraphNamesSerialized);

            yield return DefinitionTemplate(model);
        }
Esempio n. 12
0
 protected override DriverResult Editor(SeoSitemapPart part, IUpdateModel updater, dynamic shapeHelper)
 {
     return(ContentShape("Parts_SeoSitemap_Edit", () =>
     {
         updater?.TryUpdateModel(part, Prefix, null, null);
         return shapeHelper.EditorTemplate(TemplateName: "Parts/SeoSitemap", Model: part, Prefix: Prefix);
     }));
 }
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new HtmlFieldSettings();
            if (updateModel.TryUpdateModel(model, "HtmlFieldSettings", null, null)) {
                builder.WithSetting("HtmlFieldSettings.FlavorDefault", model.FlavorDefault);
            }

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != typeof(AuthorablePart).Name) yield break;

            var model = new AuthorablePartSettings();
            updateModel.TryUpdateModel(model, typeof (AuthorablePartSettings).Name, null, null);
            builder.WithSetting(string.Format("{0}.{1}", typeof(AuthorablePartSettings).Name, model.AutomaticallyAssignEditorToAuthors.GetType().Name), model.AutomaticallyAssignEditorToAuthors.ToString());

            yield return DefinitionTemplate(model);
        }
Esempio n. 15
0
        public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "BodyPart")
                yield break;

            var model = new BodyPartSettings();
            updateModel.TryUpdateModel(model, "BodyPartSettings", null, null);
            builder.WithSetting("BodyPartSettings.FlavorDefault", !string.IsNullOrWhiteSpace(model.FlavorDefault) ? model.FlavorDefault : null);
            yield return DefinitionTemplate(model);
        }
Esempio n. 16
0
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new FieldIndexing();
            updateModel.TryUpdateModel(model, "FieldIndexing", null, null);
            builder.WithSetting("FieldIndexing.Included", model.Included ? true.ToString() : null);

            CreateIndexingTasks();

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "ElementWrapperPart")
                yield break;

            var model = new ElementWrapperPartSettings();
            updateModel.TryUpdateModel(model, "ElementWrapperPartSettings", null, null);
            builder.WithSetting("ElementWrapperPartSettings.ElementTypeName", model.ElementTypeName);
            yield return DefinitionTemplate(model);
        }
Esempio n. 18
0
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new DynamicTypeSettingsViewModel();
            updateModel.TryUpdateModel(model, "DynamicTypeSettingsViewModel", null, null);

            builder.WithSetting("DynamicTypeSettings.IsDeployed", model.IsDeployed.ToString());

            yield return DefinitionTemplate(model);
        }
Esempio n. 19
0
        public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new TypeIndexing();
            updateModel.TryUpdateModel(model, "TypeIndexing", null, null);
            builder.WithSetting("TypeIndexing.Indexes", model.Indexes);

            CreateIndexingTasks();
            
            yield return DefinitionTemplate(model);
        }
Esempio n. 20
0
 public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
     if (builder.Name == "CommonPart") {
         var model = new DateEditorSettings();
         if (updateModel.TryUpdateModel(model, "DateEditorSettings", null, null)) {
             builder.WithSetting("DateEditorSettings.ShowDateEditor", model.ShowDateEditor.ToString());
         }
         yield return DefinitionTemplate(model);
     }
 }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "AssociativyNodeLabelPart")
                yield break;

            var model = new AssociativyNodeLabelTypePartSettings();
            updateModel.TryUpdateModel(model, "AssociativyNodeLabelTypePartSettings", null, null);
            builder.WithSetting("AssociativyNodeLabelTypePartSettings.DefaultLabelPattern", !String.IsNullOrWhiteSpace(model.DefaultLabelPattern) ? model.DefaultLabelPattern : null);
            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "AuditTrailPart")
                yield break;

            var settings = new AuditTrailPartSettings();
            updateModel.TryUpdateModel(settings, "AuditTrailPartSettings", null, null);
            settings.Build(builder);

            yield return DefinitionTemplate(settings);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "FavoritePart")
                yield break;

            var model = new FavoriteTypePartSettings();
            updateModel.TryUpdateModel(model, "FavoriteTypePartSettings", null, null);
            builder.WithSetting("FavoriteTypePartSettings.ShowVoter", model.ShowVoter.ToString());

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "ConnectorPart")
                yield break;
            var model = new AggregationTypePartSettings();
            updateModel.TryUpdateModel(model, "AggregationTypePartSettings", null, null);
            builder.WithSetting("AggregationTypePartSettings.ExposeFeed", model.ExposeFeed.ToString());

            yield return DefinitionTemplate(model);
        }
Esempio n. 25
0
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "LayoutPart")
                yield break;

            var model = new LayoutTypePartSettings();
            updateModel.TryUpdateModel(model, "LayoutTypePartSettings", null, null);
            builder.WithSetting("LayoutTypePartSettings.IsTemplate", model.IsTemplate.ToString());
            builder.WithSetting("LayoutTypePartSettings.DefaultLayoutData", model.DefaultLayoutData);
            yield return DefinitionTemplate(model);
        }
Esempio n. 26
0
 public override void UpdateFieldSettings(string fieldType, string fieldName, SettingsDictionary settingsDictionary, IUpdateModel updateModel) {
     if (fieldType != "PhoneField") {
         return;
     }
     var model = new PhoneFieldSettings();
     if (updateModel.TryUpdateModel(model, "PhoneFieldSettings", null, null)) {
         UpdateSettings(model, settingsDictionary, "PhoneFieldSettings");
         settingsDictionary["PhoneFieldSettings.DefaultValue"] = model.DefaultValue;
     }
 }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "AdminMenuPart") {
                yield break;
            }

            var model = new AdminMenuPartTypeSettings();
            updateModel.TryUpdateModel(model, "AdminMenuPartTypeSettings", null, null);
            builder.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", model.DefaultPosition);
            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
            var model = new ChoiceListFieldSettings();
            if (updateModel.TryUpdateModel(model, "ChoiceListFieldSettings", null, null))
            {
                builder.WithSetting("ChoiceListFieldSettings.Options", model.Options);
                builder.WithSetting("ChoiceListFieldSettings.ListMode", model.ListMode);
            }

            yield return DefinitionTemplate(model);
        }
 public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
     var settings = builder.Current.Settings;
     if (settings.ContainsKey("Stereotype") && settings["Stereotype"] == "Media") {
         var model = new MediaFileNameEditorSettings();
         if (updateModel.TryUpdateModel(model, "MediaFileNameEditorSettings", null, null)) {
             builder.WithSetting("MediaFileNameEditorSettings.ShowFileNameEditor", model.ShowFileNameEditor.ToString());
         }
     }
     return base.TypeEditorUpdate(builder, updateModel);
 }
Esempio n. 30
0
        public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel) {
            if (builder.Name != "ContainerPart")
                yield break;

            var model = new ContainerPartSettings();
            updateModel.TryUpdateModel(model, "ContainerPartSettings", null, null);
            builder.WithSetting("ContainerPartSettings.PageSizeDefault", model.PageSizeDefault.ToString());
            builder.WithSetting("ContainerPartSettings.PaginatedDefault", model.PaginatedDefault.ToString());
            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "DrillRoutePart")
                yield break;
            var model = new DrillRouteTypePartSettings();
            updateModel.TryUpdateModel(model, "DrillRouteTypePartSettings", null, null);

            builder.WithSetting("DrillRouteTypePartSettings.DrilledDisplayType", model.DrilledDisplayType);

            yield return DefinitionTemplate(model);
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "ItemCounterPart")
                yield break;

            var model = new ItemCounterPartTypePartSettings();

            updateModel.TryUpdateModel(model, "ItemCounterPartTypePartSettings", null, null);
            builder.WithSetting("ItemCounterPartTypePartSettings.Type", Enum.GetName(typeof(VisitCounterType), model.Type));
            yield return DefinitionTemplate(model);
        }
Esempio n. 33
0
        private bool ValidateShapeName(ShapePart part, IUpdateModel updater)
        {
            var titleViewModel = new TitleViewModel();

            if (!updater.TryUpdateModel(titleViewModel, "Title", null, null))
            {
                return(false);
            }

            var name = titleViewModel.Title;

            if (!string.IsNullOrWhiteSpace(name) &&
                name[0].IsLetter() &&
                name.All(c => c.IsLetter() || Char.IsDigit(c) || c == '.' || c == '-'))
            {
                return(true);
            }

            updater.AddModelError("Title", T("{0} names can only contain alphanumerical, dot (.) or dash (-) characters and have to start with a letter.", part.ContentItem.TypeDefinition.DisplayName));
            return(false);
        }
Esempio n. 34
0
        protected override DriverResult Editor(SslSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            if (updater.TryUpdateModel(part, Prefix, null, null))
            {
                _signals.Trigger(SslSettingsPart.CacheKey);
                if (!part.Enabled)
                {
                    part.SecureEverything = false;
                }
                if (!part.SecureEverything)
                {
                    part.SendStrictTransportSecurityHeaders = false;
                }
                if (!part.StrictTransportSecurityIncludeSubdomains)
                {
                    part.StrictTransportSecurityPreload = false;
                }
            }

            return(Editor(part, shapeHelper));
        }
        protected override DriverResult Editor(ProductListPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(new ProductListEditViewModel {
                Part = part
            }, this.Prefix, null, null);

            if (part.EnablePaging && !part.PageSize.HasValue)
            {
                updater.AddModelError("PageSizeRequired", this._localizer("Page size is required"));
            }
            if (part.FromCatalogHierarchySelection && !part.CatalogHierarchyId.HasValue)
            {
                updater.AddModelError("CatalogHierarchyIdRequired", this._localizer("Magelia WebStore Catalogs and Categories component is required"));
            }
            if (part.DisplayViewDetail && String.IsNullOrEmpty(part.ViewDetailUrlPattern))
            {
                updater.AddModelError("ViewDetailUrlPatternRequired", this._localizer("Url pattern is required"));
            }

            return(this.Editor(part, shapeHelper));
        }
Esempio n. 36
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(
            ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (!_typeHasGDPRPart)
            {
                yield break;
            }
            //we only do stuff for ContentPickerFields
            if (builder.FieldType != "ContentPickerField")
            {
                yield break;
            }

            var vm = new ContentPickerFieldGDPRPartFieldSettingsViewModel();

            if (updateModel.TryUpdateModel(vm, "ContentPickerFieldGDPRPartFieldSettingsViewModel", null, null))
            {
                var settings = vm.Settings;
                ContentPickerFieldGDPRPartFieldSettings.SetValues(builder, settings);
            }
        }
 //POST
 protected override DriverResult Editor(UserRegistrationPolicyPart part, IUpdateModel updater, dynamic shapeHelper)
 {
     if (currentControllerAction != CONTROLLER_ACTION)
     {
         return(null);
     }
     if (_utilsServices.FeatureIsEnabled("Laser.Orchard.Policy"))
     {
         var policies = _usersExtensionsServices.BuildEditorForRegistrationPolicies();
         if (updater.TryUpdateModel(policies, Prefix, null, null))
         {
             if (policies.Count(x => (
                                    (x.PolicyAnswer == false) && x.UserHaveToAccept)) > 0)
             {
                 updater.AddModelError("NotAcceptedPolicies", T("User has to accept policies!"));
             }
             _controllerAccessor.Context.Controller.TempData["VolatileAnswers"] = String.Join(",", policies.Where(x => x.PolicyAnswer).Select(x => x.PolicyId.ToString()));
         }
     }
     return(Editor(part, shapeHelper));
 }
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "MediaPickerField")
            {
                yield break;
            }

            var model = new MediaPickerFieldSettings();

            if (updateModel.TryUpdateModel(model, "MediaPickerFieldSettings", null, null))
            {
                builder.WithSetting("MediaPickerFieldSettings.Hint", model.Hint);
                builder.WithSetting("MediaPickerFieldSettings.AllowedExtensions", model.AllowedExtensions);
                builder.WithSetting("MediaPickerFieldSettings.Required", model.Required.ToString());
                builder.WithSetting("MediaPickerFieldSettings.Custom1", model.Custom1);
                builder.WithSetting("MediaPickerFieldSettings.Custom2", model.Custom2);
                builder.WithSetting("MediaPickerFieldSettings.Custom3", model.Custom3);
            }

            yield return(DefinitionTemplate(model));
        }
Esempio n. 39
0
        public override IEnumerable <TemplateViewModel> TypePartEditorUpdate(
            ContentTypePartDefinitionBuilder builder,
            IUpdateModel updateModel)
        {
            if (builder.Name == "SeoPart")
            {
                var model = new SeoPartSettings();
                updateModel.TryUpdateModel(model, "SeoPartSettings", null, null);

                if (model.Templates == null)
                {
                    model.Templates = getMicrodataTemplate();
                }

                builder.WithSetting("SeoPartSettings.RobotsNoIndex", model.RobotsNoIndex.ToString());
                builder.WithSetting("SeoPartSettings.RobotsNoFollow", model.RobotsNoFollow.ToString());
                builder.WithSetting("SeoPartSettings.RobotsNoSnippet", model.RobotsNoSnippet.ToString());
                builder.WithSetting("SeoPartSettings.RobotsNoOdp", model.RobotsNoOdp.ToString());
                builder.WithSetting("SeoPartSettings.RobotsNoArchive", model.RobotsNoArchive.ToString());
                builder.WithSetting("SeoPartSettings.RobotsUnavailableAfter", model.RobotsUnavailableAfter.ToString());
                builder.WithSetting("SeoPartSettings.RobotsNoImageIndex", model.RobotsNoImageIndex.ToString());
                builder.WithSetting("SeoPartSettings.GoogleNoSiteLinkSearchBox", model.GoogleNoSiteLinkSearchBox.ToString());
                builder.WithSetting("SeoPartSettings.GoogleNoTranslate", model.GoogleNoTranslate.ToString());
                if (model.CanonicalUrl != null)
                {
                    builder.WithSetting("SeoPartSettings.CanonicalUrl", model.CanonicalUrl.ToString());
                }
                else
                {
                    builder.WithSetting("SeoPartSettings.CanonicalUrl", "");
                }
                builder.WithSetting("SeoPartSettings.JsonLd", model.JsonLd != null ? model.JsonLd.ToString() : "");

                builder.WithSetting("SeoPartSettings.ShowAggregatedMicrodata", model.ShowAggregatedMicrodata.ToString());

                yield return(DefinitionTemplate(model));
            }

            yield break;
        }
        // POST
        protected override DriverResult Editor(CommentPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            var workContext = _workContextAccessor.GetContext();

            part.CommentDateUtc = _clock.UtcNow;

            if (!String.IsNullOrEmpty(part.SiteName) && !part.SiteName.StartsWith("http://") && !part.SiteName.StartsWith("https://"))
            {
                part.SiteName = "http://" + part.SiteName;
            }

            var currentUser = workContext.CurrentUser;

            part.UserName = (currentUser != null ? currentUser.UserName : null);

            if (currentUser != null)
            {
                part.Author = currentUser.UserName;
            }

            if (String.IsNullOrEmpty(part.Author))
            {
                updater.AddModelError("NameMissing", T("You didn't specify your name."));
            }

            var moderateComments = workContext.CurrentSite.As <CommentSettingsPart>().Record.ModerateComments;

            part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved;

            var commentedOn = _contentManager.Get <ICommonPart>(part.CommentedOn);

            if (commentedOn != null && commentedOn.Container != null)
            {
                part.CommentedOnContainer = commentedOn.Container.ContentItem.Id;
            }
            commentedOn.As <CommentsPart>().Record.CommentPartRecords.Add(part.Record);

            return(Editor(part, shapeHelper));
        }
        protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater, dynamic shapeHelper)
        {
            // don't apply editor without apply roles permission
            if (!_authorizationService.TryCheckAccess(Permissions.AssignRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
            {
                return(null);
            }

            var            userRoles    = _workContext.CurrentUser.As <UserRolesPart>().Roles;
            IList <string> allowedRoles = userRoles.SelectMany(userRole => _allowedRoleService.GetAllowedRolesForRoleByName(userRole)).ToList();

            var model = BuildEditorViewModel(userRolesPart);

            if (updater.TryUpdateModel(model, Prefix, null, null))
            {
                var currentUserRoleRecords = _userRolesRepository.Fetch(x => x.UserId == model.User.Id).ToArray();
                var currentRoleRecords     = currentUserRoleRecords.Select(x => x.Role);
                var targetRoleRecords      = model.Roles.Where(x => x.Granted).Select(x => _roleService.GetRole(x.RoleId)).ToArray();
                foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x)))
                {
                    _notifier.Warning(T("Adding role {0} to user {1}", addingRole.Name, userRolesPart.As <IUser>().UserName));
                    _userRolesRepository.Create(new UserRolesPartRecord {
                        UserId = model.User.Id, Role = addingRole
                    });
                    _roleEventHandlers.UserAdded(new UserAddedContext {
                        Role = addingRole, User = model.User
                    });
                }
                foreach (var removingRole in currentUserRoleRecords.Where(x => !targetRoleRecords.Contains(x.Role)).Where(x => allowedRoles.Any(y => y == x.Role.Name)))
                {
                    _notifier.Warning(T("Removing role {0} from user {1}", removingRole.Role.Name, userRolesPart.As <IUser>().UserName));
                    _userRolesRepository.Delete(removingRole);
                    _roleEventHandlers.UserRemoved(new UserRemovedContext {
                        Role = removingRole.Role, User = model.User
                    });
                }
            }
            return(ContentShape("Parts_Roles_UserRoles_Edit",
                                () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix)));
        }
        protected override DriverResult Editor(ContentPart part, Fields.DateTimeField field, IUpdateModel updater, dynamic shapeHelper)
        {
            var viewModel = new DateTimeFieldViewModel();

            if (updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null))
            {
                DateTime value;

                var settings = field.PartFieldDefinition.Settings.GetModel <DateTimeFieldSettings>();

                if (settings.Display == DateTimeFieldDisplays.DateOnly)
                {
                    viewModel.Time = new DateTime(1980, 1, 1).ToString("t", _cultureInfo.Value);
                }

                if (settings.Display == DateTimeFieldDisplays.TimeOnly)
                {
                    viewModel.Date = new DateTime(1980, 1, 1).ToString("d", _cultureInfo.Value);
                }

                string parseDateTime = String.Concat(viewModel.Date, " ", viewModel.Time);

                if (settings.Required && (String.IsNullOrWhiteSpace(viewModel.Time) || String.IsNullOrWhiteSpace(viewModel.Date)))
                {
                    updater.AddModelError(GetPrefix(field, part), T("{0} is required", field.DisplayName));
                }

                if (DateTime.TryParse(parseDateTime, _cultureInfo.Value, DateTimeStyles.None, out value))
                {
                    field.DateTime = TimeZoneInfo.ConvertTimeToUtc(value, Services.WorkContext.CurrentTimeZone);
                }
                else
                {
                    updater.AddModelError(GetPrefix(field, part), T("{0} is an invalid date and time", field.DisplayName));
                    field.DateTime = DateTime.MinValue;
                }
            }

            return(Editor(part, field, shapeHelper));
        }
Esempio n. 43
0
        protected override DriverResult Editor(GamePart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var viewModel = new GamePartVM();

            if (updater.TryUpdateModel(viewModel, Prefix, null, null))
            {
                var mapperConfiguration = new MapperConfiguration(cfg => {
                    cfg.CreateMap <GamePartVM, GamePart>()
                    .ForMember(dest => dest.GameDate, opt => opt.Ignore());
                });

                var mapper = mapperConfiguration.CreateMapper();

                mapper.Map <GamePartVM, GamePart>(viewModel, part);
                if (!String.IsNullOrWhiteSpace(viewModel.GameDate))
                {
                    part.GameDate = _dateLocalization.StringToDatetime(viewModel.GameDate, "") ?? DateTime.Now;
                }
            }

            return(Editor(part, shapeHelper));
        }
Esempio n. 44
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "BooleanField")
            {
                yield break;
            }

            var model = new BooleanFieldSettings();

            if (updateModel.TryUpdateModel(model, "BooleanFieldSettings", null, null))
            {
                builder.WithSetting("BooleanFieldSettings.Hint", model.Hint);
                builder.WithSetting("BooleanFieldSettings.Optional", model.Optional.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("BooleanFieldSettings.NotSetLabel", model.NotSetLabel);
                builder.WithSetting("BooleanFieldSettings.OnLabel", model.OnLabel);
                builder.WithSetting("BooleanFieldSettings.OffLabel", model.OffLabel);
                builder.WithSetting("BooleanFieldSettings.SelectionMode", model.SelectionMode.ToString());
                builder.WithSetting("BooleanFieldSettings.DefaultValue", model.DefaultValue.HasValue ? model.DefaultValue.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
            }

            yield return(DefinitionTemplate(model));
        }
Esempio n. 45
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "TextField")
            {
                yield break;
            }

            var model = new TextFieldSettingsEventsViewModel {
                Settings = new TextFieldSettings()
            };

            if (updateModel.TryUpdateModel(model, "TextFieldSettingsEventsViewModel", null, null))
            {
                builder.WithSetting("TextFieldSettings.Flavor", model.Settings.Flavor);
                builder.WithSetting("TextFieldSettings.Hint", model.Settings.Hint);
                builder.WithSetting("TextFieldSettings.Required", model.Settings.Required.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("TextFieldSettings.Placeholder", model.Settings.Placeholder);
                builder.WithSetting("TextFieldSettings.DefaultValue", model.Settings.DefaultValue);

                yield return(DefinitionTemplate(model));
            }
        }
Esempio n. 46
0
        protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater, dynamic shapeHelper)
        {
            var viewModel = new TextFieldDriverViewModel {
                Field    = field,
                Text     = field.Value,
                Settings = field.PartFieldDefinition.Settings.GetModel <TextFieldSettings>()
            };

            if (updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null))
            {
                if (viewModel.Settings.Required && string.IsNullOrWhiteSpace(viewModel.Text))
                {
                    updater.AddModelError("Text", T("The field {0} is mandatory", T(field.DisplayName)));
                    return(ContentShape("Fields_Common_Text_Edit", GetDifferentiator(field, part),
                                        () => shapeHelper.EditorTemplate(TemplateName: "Fields.Common.Text.Edit", Model: viewModel, Prefix: GetPrefix(field, part))));
                }

                field.Value = viewModel.Text;
            }

            return(Editor(part, field, shapeHelper));
        }
Esempio n. 47
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "FilePickField")
            {
                yield break;
            }

            var model = new FilePickSettings();

            if (updateModel.TryUpdateModel(model, "FilePickSettings", null, null))
            {
                builder.WithSetting("FilePickSettings.Width", model.Width);
                builder.WithSetting("FilePickSettings.Height", model.Height.ToString());
                builder.WithSetting("FilePickSettings.Editable", model.Editable.ToString().ToLower());
                builder.WithSetting("FilePickSettings.Required", model.Required.ToString().ToLower());
                builder.WithSetting("FilePickSettings.Prompt", model.Prompt);
                builder.WithSetting("FilePickSettings.LabelAlign", model.LabelAlign);
                builder.WithSetting("FilePickSettings.LabelPosition", model.LabelPosition);
            }

            yield return(DefinitionTemplate(model));
        }
Esempio n. 48
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "DateTimeField")
            {
                yield break;
            }

            var model = new DateTimeFieldSettings();

            if (updateModel.TryUpdateModel(model, "DateTimeFieldSettings", null, null))
            {
                builder.WithSetting("DateTimeFieldSettings.Display", model.Display.ToString());
                builder.WithSetting("DateTimeFieldSettings.Hint", model.Hint);
                builder.WithSetting("DateTimeFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("DateTimeFieldSettings.DatePlaceholder", model.DatePlaceholder);
                builder.WithSetting("DateTimeFieldSettings.TimePlaceholder", model.TimePlaceholder);
                model.DefaultValue = model.Editor == null ? model.DefaultValue : _dateLocalizationServices.ConvertFromLocalizedString(model.Editor.Date, model.Editor.Time);
                builder.WithSetting("DateTimeFieldSettings.DefaultValue", model.DefaultValue.HasValue ? model.DefaultValue.Value.ToString(CultureInfo.InvariantCulture) : String.Empty);

                yield return(DefinitionTemplate(model));
            }
        }
Esempio n. 49
0
        public override IEnumerable <TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "InfiniteAjaxScrollingPart")
            {
                yield break;
            }

            var model = new InfiniteAjaxScrollingTypePartSettings();

            updateModel.TryUpdateModel(model, "InfiniteAjaxScrollingTypePartSettings", null, null);
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.UseHistory", model.UseHistory.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.Container", model.Container.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.Pagination", model.Pagination.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.Item", model.Item.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.NextAnchor", model.NextAnchor.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.Loader", model.Loader.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.OnLoadItems", string.IsNullOrWhiteSpace(model.OnLoadItems) ? string.Empty : model.OnLoadItems.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.BeforePageChange", string.IsNullOrWhiteSpace(model.BeforePageChange) ? string.Empty : model.BeforePageChange.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.OnPageChange", string.IsNullOrWhiteSpace(model.OnPageChange) ? string.Empty : model.OnPageChange.ToString());
            builder.WithSetting("InfiniteAjaxScrollingTypePartSettings.OnRenderComplete", string.IsNullOrWhiteSpace(model.OnRenderComplete) ? string.Empty : model.OnRenderComplete.ToString());
            yield return(DefinitionTemplate(model));
        }
        protected override DriverResult Editor(ShareLinkPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            ShareLinkVM vm = new ShareLinkVM();

            updater.TryUpdateModel(vm, Prefix, null, null);
            Mapper.Initialize(cfg => {
                cfg.CreateMap <ShareLinkVM, ShareLinkPart>()
                .ForSourceMember(src => src.ShowSharedImage, opt => opt.Ignore())
                .ForSourceMember(src => src.ShowSharedLink, opt => opt.Ignore())
                .ForSourceMember(src => src.ShowSharedText, opt => opt.Ignore())
                .ForSourceMember(src => src.ShowSharedBody, opt => opt.Ignore());
            });
            Mapper.Map(vm, part);

            if (vm.SharedImage != null)
            {
                part.SharedIdImage = vm.SharedImage.Replace("{", "").Replace("}", "");
                part.SharedImage   = _sharelinkservice.GetImgUrl(part.SharedIdImage);
            }

            return(Editor(part, shapeHelper));
        }
        // POST
        protected override DriverResult Editor(SmsGatewayPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var model = new SmsGatewayVM {
                SmsGateway = part
            };

            updater.TryUpdateModel(model, Prefix, null, new string[] { "Settings" });

            // reset Alias
            if (!part.HaveAlias)
            {
                part.Alias = null;
            }

            // reset Recipient List
            if (!part.SendToRecipientList)
            {
                part.RecipientList = null;
            }

            return(Editor(part, shapeHelper));
        }
Esempio n. 52
0
        public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater)
        {
            var contentTypeViewModels = _contentDefinitionManager.ListTypeDefinitions()
                                        .OrderBy(x => x.Name)
                                        .Select(x => new ContentTypeEntry {
                Name = x.Name, DisplayName = x.DisplayName
            })
                                        .ToList();

            var viewModel = new ContentBuilderStepViewModel {
                ContentTypes = contentTypeViewModels
            };

            if (updater != null && updater.TryUpdateModel(viewModel, Prefix, null, null))
            {
                DataContentTypes      = viewModel.ContentTypes.Where(x => x.ExportData).Select(x => x.Name).ToList();
                SchemaContentTypes    = viewModel.ContentTypes.Where(x => x.ExportSchema).Select(x => x.Name).ToList();
                VersionHistoryOptions = viewModel.VersionHistoryOptions;
            }

            return(shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Content", Model: viewModel, Prefix: Prefix));
        }
Esempio n. 53
0
        protected override DriverResult Editor(DynamicButtonToWorkflowsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            List <DynamicButtonToWorkflowsRecord> model = new List <DynamicButtonToWorkflowsRecord>();

            if (updater.TryUpdateModel(model, Prefix, null, null))
            {
                if (part.ContentItem.Id != 0)
                {
                    foreach (DynamicButtonToWorkflowsRecord button in model)
                    {
                        if (_orchardServices.WorkContext.HttpContext.Request.Form["submit.Save"] == "submit.DynamicCustomButton." + button.GlobalIdentifier)
                        {
                            part.ButtonName     = button.ButtonName;
                            part.MessageToWrite = button.ButtonMessage;
                            part.ActionAsync    = button.ButtonAsync;
                        }
                    }
                }
            }

            return(Editor(part, shapeHelper));
        }
        protected override DriverResult Editor(AdminSearchSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            return(ContentShape("Parts_AdminSearch_SiteSettings", () => {
                var model = new SearchSettingsViewModel();
                var searchFields = part.SearchFields;

                if (updater != null)
                {
                    if (updater.TryUpdateModel(model, Prefix, null, null))
                    {
                        part.SearchIndex = model.SelectedIndex;
                        part.SearchFields = model.Entries.ToDictionary(x => x.Index, x => x.Fields.Where(e => e.Selected).Select(e => e.Field).ToArray());
                        part.FilterCulture = model.FilterCulture;
                    }
                }
                else if (_indexManager.HasIndexProvider())
                {
                    // viewing editor: build model from part
                    model.FilterCulture = part.FilterCulture;
                    model.SelectedIndex = part.SearchIndex;
                    model.Entries = _indexManager.GetSearchIndexProvider().List().Select(x => {
                        var indexSettings = new IndexSettingsEntry {
                            Index = x,
                            Fields = new List <SearchSettingsEntry>()
                        };
                        foreach (var field in _indexManager.GetSearchIndexProvider().GetFields(x))
                        {
                            indexSettings.Fields.Add(new SearchSettingsEntry {
                                Field = field, Selected = (searchFields.ContainsKey(x) && searchFields[x].Contains(field))
                            });
                        }

                        return indexSettings;
                    }).ToList();
                }

                return shapeHelper.EditorTemplate(TemplateName: "Parts/AdminSearch.SiteSettings", Model: model, Prefix: Prefix);
            }).OnGroup("admin search"));
        }
Esempio n. 55
0
        protected override DriverResult Editor(ContentPart part, LinkField field, IUpdateModel updater, dynamic shapeHelper)
        {
            if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null))
            {
                var settings = field.PartFieldDefinition.Settings.GetModel <LinkFieldSettings>();

                if (settings.Required && String.IsNullOrWhiteSpace(field.Value))
                {
                    updater.AddModelError(GetPrefix(field, part), T("Url is required for {0}", field.DisplayName));
                }
                else if (!String.IsNullOrWhiteSpace(field.Value) && !Uri.IsWellFormedUriString(field.Value, UriKind.RelativeOrAbsolute))
                {
                    updater.AddModelError(GetPrefix(field, part), T("{0} is an invalid url.", field.Value));
                }
                else if (settings.LinkTextMode == LinkTextMode.Required && String.IsNullOrWhiteSpace(field.Text))
                {
                    updater.AddModelError(GetPrefix(field, part), T("Text is required for {0}.", field.DisplayName));
                }
            }

            return(Editor(part, field, shapeHelper));
        }
Esempio n. 56
0
        protected override DriverResult Editor(NavigationPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var currentUser  = _workContextAccessor.GetContext().CurrentUser;
            var allowedMenus = _menuService.GetMenus().Where(menu => _authorizationService.TryCheckAccess(Permissions.ManageMenus, currentUser, menu)).ToList();

            if (!allowedMenus.Any())
            {
                return(null);
            }

            var model = new NavigationPartViewModel();

            if (updater.TryUpdateModel(model, Prefix, null, null))
            {
                if (model.AddMenuItem)
                {
                    if (string.IsNullOrEmpty(model.MenuText))
                    {
                        updater.AddModelError("MenuText", T("The MenuText field is required"));
                    }
                    else
                    {
                        var menu = allowedMenus.FirstOrDefault(m => m.Id == model.CurrentMenuId);

                        if (menu != null)
                        {
                            var menuItem = _contentManager.Create <ContentMenuItemPart>("ContentMenuItem");
                            menuItem.Content = part.ContentItem;

                            menuItem.As <MenuPart>().MenuText     = model.MenuText;
                            menuItem.As <MenuPart>().MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
                            menuItem.As <MenuPart>().Menu         = menu;
                        }
                    }
                }
            }

            return(Editor(part, shapeHelper));
        }
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "LinkField")
            {
                yield break;
            }

            var model = new LinkFieldSettings();

            if (updateModel.TryUpdateModel(model, "LinkFieldSettings", null, null))
            {
                builder.WithSetting("LinkFieldSettings.Hint", model.Hint);
                builder.WithSetting("LinkFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("LinkFieldSettings.TargetMode", model.TargetMode.ToString());
                builder.WithSetting("LinkFieldSettings.LinkTextMode", model.LinkTextMode.ToString());
                builder.WithSetting("LinkFieldSettings.StaticText", model.StaticText);
                builder.WithSetting("LinkFieldSettings.DefaultValue", model.DefaultValue);
                builder.WithSetting("LinkFieldSettings.TextDefaultValue", model.TextDefaultValue);

                yield return(DefinitionTemplate(model));
            }
        }
Esempio n. 58
0
        protected override DriverResult Editor(TwitterPostPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            TwitterPostVM vm = new TwitterPostVM();

            updater.TryUpdateModel(vm, Prefix, null, null);

            var mapperConfiguration = new MapperConfiguration(cfg => {
                cfg.CreateMap <TwitterPostVM, TwitterPostPart>();
            });
            IMapper _mapper = mapperConfiguration.CreateMapper();

            _mapper.Map <TwitterPostVM, TwitterPostPart>(vm, part);
            if (vm.SelectedList != null)
            {
                part.AccountList = vm.SelectedList.Select(x => Int32.Parse(x)).ToArray();
            }
            else
            {
                part.AccountList = new Int32[] { }
            };
            return(Editor(part, shapeHelper));
        }
Esempio n. 59
0
        public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.FieldType != "NumericField")
            {
                yield break;
            }

            var model = new NumericFieldSettings();

            if (updateModel.TryUpdateModel(model, "NumericFieldSettings", null, null))
            {
                builder.WithSetting("NumericFieldSettings.Hint", model.Hint);
                builder.WithSetting("NumericFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("NumericFieldSettings.Scale", model.Scale.ToString(CultureInfo.InvariantCulture));
                builder.WithSetting("NumericFieldSettings.Minimum", model.Minimum.HasValue ? model.Minimum.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
                builder.WithSetting("NumericFieldSettings.Maximum", model.Maximum.HasValue ? model.Maximum.Value.ToString(CultureInfo.InvariantCulture) : string.Empty);
                builder.WithSetting("NumericFieldSettings.Placeholder", model.Placeholder);
                builder.WithSetting("NumericFieldSettings.DefaultValue", model.DefaultValue);
            }

            yield return(DefinitionTemplate(model));
        }
        public override IEnumerable <TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (builder.Name != "ContainerPart")
            {
                yield break;
            }

            var viewModel = new ContainerTypePartSettingsViewModel {
                AvailableItemContentTypes = _containerService.GetContainableTypes().ToList()
            };

            updateModel.TryUpdateModel(viewModel, "ContainerTypePartSettingsViewModel", null, new[] { "AvailableItemContentTypes" });
            builder.WithSetting("ContainerTypePartSettings.ItemsShownDefault", viewModel.ItemsShownDefault.ToString());
            builder.WithSetting("ContainerTypePartSettings.PageSizeDefault", viewModel.PageSizeDefault.ToString());
            builder.WithSetting("ContainerTypePartSettings.PaginatedDefault", viewModel.PaginatedDefault.ToString());
            builder.WithSetting("ContainerTypePartSettings.RestrictedItemContentTypes", viewModel.RestrictedItemContentTypes != null ? string.Join(",", viewModel.RestrictedItemContentTypes) : "");
            builder.WithSetting("ContainerTypePartSettings.RestrictItemContentTypes", viewModel.RestrictItemContentTypes.ToString());
            builder.WithSetting("ContainerTypePartSettings.EnablePositioning", viewModel.EnablePositioning.ToString());
            builder.WithSetting("ContainerTypePartSettings.AdminListViewName", viewModel.AdminListViewName);
            builder.WithSetting("ContainerTypePartSettings.DisplayContainerEditor", viewModel.DisplayContainerEditor.ToString());
            yield return(DefinitionTemplate(viewModel));
        }