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); }
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); }
public static ContentPartFieldDefinitionBuilder WithLocation(this ContentPartFieldDefinitionBuilder obj, IDictionary <string, ContentLocation> settings) { foreach (var entry in GetSettingEntries(settings)) { obj = obj.WithSetting(entry.Key, entry.Value); } return(obj); }
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); }
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> 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); }
protected void UpdateSettings(FieldSettings model, ContentPartFieldDefinitionBuilder builder, string prefix) { model.HelpText = model.HelpText ?? string.Empty; builder.WithSetting(prefix + ".HelpText", model.HelpText); builder.WithSetting(prefix + ".Required", model.Required.ToString()); builder.WithSetting(prefix + ".ReadOnly", model.ReadOnly.ToString()); builder.WithSetting(prefix + ".AlwaysInLayout", model.AlwaysInLayout.ToString()); builder.WithSetting(prefix + ".IsSystemField", model.IsSystemField.ToString()); builder.WithSetting(prefix + ".IsAudit", model.IsAudit.ToString()); }
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 void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "PhoneField") { return; } var model = settingsDictionary.TryGetModel<PhoneFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "PhoneFieldSettings"); builder.WithSetting("PhoneFieldSettings.DefaultValue", model.DefaultValue); } }
public override void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "CoeveryTextField") { return; } var model = settingsDictionary.TryGetModel<CoeveryTextFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "CoeveryTextFieldSettings"); builder.WithSetting("CoeveryTextFieldSettings.IsDispalyField", model.IsDispalyField.ToString()); builder.WithSetting("CoeveryTextFieldSettings.MaxLength", model.MaxLength.ToString()); builder.WithSetting("CoeveryTextFieldSettings.PlaceHolderText", model.PlaceHolderText); } }
public override void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "OptionSetField") { return; } var model = settingsDictionary.TryGetModel<OptionSetFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "OptionSetFieldSettings"); builder.WithSetting("OptionSetFieldSettings.OptionSetId", model.OptionSetId.ToString()); builder.WithSetting("OptionSetFieldSettings.ListMode", model.ListMode.ToString()); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { 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); }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "PhoneField") { yield break; } var model = new PhoneFieldSettings(); if (updateModel.TryUpdateModel(model, "PhoneFieldSettings", null, null)) { UpdateSettings(model, builder, "PhoneFieldSettings"); builder.WithSetting("PhoneFieldSettings.DefaultValue", model.DefaultValue); } yield return DefinitionTemplate(model); }
public override void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "NumberField") { return; } var model = settingsDictionary.TryGetModel<NumberFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "NumberFieldSettings"); builder.WithSetting("NumberFieldSettings.Length", model.Length.ToString()); builder.WithSetting("NumberFieldSettings.DecimalPlaces", model.DecimalPlaces.ToString()); builder.WithSetting("NumberFieldSettings.DefaultValue", model.DefaultValue.ToString()); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "LocationField") { yield break; } var model = new LocationFieldSettings(); if (updateModel.TryUpdateModel(model, "LocationFieldSettings", null, null)) { builder.WithSetting("LocationFieldSettings.Required", model.Required.ToString()); } yield return DefinitionTemplate(model); }
public override void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "BooleanField") { return; } var model = settingsDictionary.TryGetModel<BooleanFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "BooleanFieldSettings"); builder.WithSetting("BooleanFieldSettings.SelectionMode", model.SelectionMode.ToString()); builder.WithSetting("BooleanFieldSettings.DependencyMode", model.DependencyMode.ToString()); builder.WithSetting("BooleanFieldSettings.DefaultValue", model.DefaultValue.ToString()); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "CoeveryTextField") { yield break; } var model = new CoeveryTextFieldSettings(); if (updateModel.TryUpdateModel(model, "CoeveryTextFieldSettings", null, null)) { UpdateSettings(model, builder, "CoeveryTextFieldSettings"); builder.WithSetting("CoeveryTextFieldSettings.MaxLength", model.MaxLength.ToString()); builder.WithSetting("CoeveryTextFieldSettings.PlaceHolderText", model.PlaceHolderText); } yield return DefinitionTemplate(model); }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "ContentPickerField") { yield break; } var model = new ContentPickerSearchFieldSettings(); if (updateModel.TryUpdateModel(model, "ContentPickerSearchFieldSettings", null, null)) { builder.WithSetting("ContentPickerSearchFieldSettings.ShowSearchTab", model.ShowSearchTab.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("ContentPickerSearchFieldSettings.SearchIndex", model.SearchIndex); builder.WithSetting("ContentPickerSearchFieldSettings.DisplayedContentTypes", model.DisplayedContentTypes); } yield return DefinitionTemplate(model); }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "ContentPickerField") { yield break; } var model = new ContentPickerFieldSettings(); if (updateModel.TryUpdateModel(model, "ContentPickerFieldSettings", null, null)) { builder.WithSetting("ContentPickerFieldSettings.Hint", model.Hint); builder.WithSetting("ContentPickerFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("ContentPickerFieldSettings.Multiple", model.Multiple.ToString(CultureInfo.InvariantCulture)); } yield return DefinitionTemplate(model); }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "HintField") { yield break; } var model = new HintFieldSettings(); if (updateModel.TryUpdateModel(model, "HintFieldSettings", null, null)) { builder.WithSetting("HintFieldSettings.Hint", model.Hint); yield return DefinitionTemplate(model); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "ContentReferenceField") { yield break; } var model = new ContentReferenceFieldSettings(); if (updateModel.TryUpdateModel(model, "ContentReferenceFieldSettings", null, null)) { builder.WithSetting("ContentReferenceFieldSettings.QueryId", model.QueryId.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("ContentReferenceFieldSettings.DisplayAsLink", model.DisplayAsLink.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("ContentReferenceFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture)); } yield return DefinitionTemplate(model); }
protected void UpdateSettings(FieldSettings model, ContentPartFieldDefinitionBuilder builder, string prefix) { model.HelpText = model.HelpText ?? string.Empty; builder.WithSetting(prefix + ".HelpText", model.HelpText); builder.WithSetting(prefix + ".Required", model.Required.ToString()); builder.WithSetting(prefix + ".ReadOnly", model.ReadOnly.ToString()); builder.WithSetting(prefix + ".AlwaysInLayout", model.AlwaysInLayout.ToString()); builder.WithSetting(prefix + ".IsSystemField", model.IsSystemField.ToString()); builder.WithSetting(prefix + ".IsAudit", model.IsAudit.ToString()); //var prefix = viewModel.FieldTypeName + "Settings"; //var clientSettings = new FieldSettings(); //updateModel.TryUpdateModel(clientSettings, prefix, null, null); //if (clientSettings.IsSystemField) { // updateModel.AddModelError("IsSystemField", T("Can't modify the IsSystemField field.")); //} }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "NumberField") { yield break; } var model = new NumberFieldSettings(); if (updateModel.TryUpdateModel(model, "NumberFieldSettings", null, null)) { UpdateSettings(model, builder, "NumberFieldSettings"); builder.WithSetting("NumberFieldSettings.Length", model.Length.ToString()); builder.WithSetting("NumberFieldSettings.DecimalPlaces", model.DecimalPlaces.ToString()); builder.WithSetting("NumberFieldSettings.DefaultValue", model.DefaultValue.ToString()); } yield return DefinitionTemplate(model); }
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)) { UpdateSettings(model, builder, "BooleanFieldSettings"); builder.WithSetting("BooleanFieldSettings.SelectionMode", model.SelectionMode.ToString()); builder.WithSetting("BooleanFieldSettings.DependencyMode", model.DependencyMode.ToString()); builder.WithSetting("BooleanFieldSettings.DefaultValue", model.DefaultValue.ToString()); } yield return DefinitionTemplate(model); }
public override void UpdateFieldSettings(ContentPartFieldDefinitionBuilder builder, SettingsDictionary settingsDictionary) { if (builder.FieldType != "ReferenceField") { return; } var model = settingsDictionary.TryGetModel<ReferenceFieldSettings>(); if (model != null) { UpdateSettings(model, builder, "ReferenceFieldSettings"); builder.WithSetting("ReferenceFieldSettings.DisplayAsLink", model.DisplayAsLink.ToString()); builder.WithSetting("ReferenceFieldSettings.ContentTypeName", model.ContentTypeName); builder.WithSetting("ReferenceFieldSettings.RelationshipName", model.RelationshipName); builder.WithSetting("ReferenceFieldSettings.RelationshipId", model.RelationshipId.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("ReferenceFieldSettings.QueryId", model.QueryId.ToString(CultureInfo.InvariantCulture)); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { var model = new ImageFieldSettings(); if(updateModel.TryUpdateModel(model, "ImageFieldSettings", null, null)) { builder.WithSetting("ImageFieldSettings.Hint", model.Hint); builder.WithSetting("ImageFieldSettings.MaxHeight", model.MaxHeight.ToString()); builder.WithSetting("ImageFieldSettings.MaxWidth", model.MaxWidth.ToString()); builder.WithSetting("ImageFieldSettings.Required", model.Required.ToString()); builder.WithSetting("ImageFieldSettings.MediaFolder", model.MediaFolder); builder.WithSetting("ImageFieldSettings.FileName", model.FileName); builder.WithSetting("ImageFieldSettings.AlternateText", model.AlternateText.ToString()); builder.WithSetting("ImageFieldSettings.ResizeAction", model.ResizeAction.ToString()); } yield return DefinitionTemplate(model); }
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); yield return DefinitionTemplate(model); } }
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)); 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); } }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { var previous = builder.Current.Settings.GetModel<FieldIndexing>(); var model = new FieldIndexing(); updateModel.TryUpdateModel(model, "FieldIndexing", null, null); builder.WithSetting("FieldIndexing.Included", model.Included ? true.ToString() : null); // create indexing tasks only if settings have changed if (model.Included != previous.Included) { // if a field setting has changed, all existing content items need to be re-indexed CreateIndexingTasks(); } yield return DefinitionTemplate(model); }
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.FieldType != "EnumerationField") { yield break; } var model = new EnumerationFieldSettings(); if (updateModel.TryUpdateModel(model, "EnumerationFieldSettings", null, null)) { builder.WithSetting("EnumerationFieldSettings.Hint", model.Hint); builder.WithSetting("EnumerationFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture)); builder.WithSetting("EnumerationFieldSettings.Options", model.Options); builder.WithSetting("EnumerationFieldSettings.ListMode", model.ListMode.ToString()); builder.WithSetting("EnumerationFieldSettings.DefaultValue", model.DefaultValue); } yield return DefinitionTemplate(model); }
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); } yield return DefinitionTemplate(model); }