mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Adding the ability to specify tokenized default values for content fields, fixes #5934
And also fixing build error. *Shame!*
This commit is contained in:
@@ -72,8 +72,15 @@ namespace Orchard.Core.Common.Drivers {
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Fields.Common.Text.Edit", Model: viewModel, Prefix: GetPrefix(field, part)));
|
||||
}
|
||||
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>();
|
||||
|
||||
if (String.IsNullOrEmpty(field.Value) && !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = settings.DefaultValue;
|
||||
}
|
||||
else {
|
||||
field.Value = viewModel.Text;
|
||||
}
|
||||
}
|
||||
|
||||
return Editor(part, field, shapeHelper);
|
||||
}
|
||||
|
@@ -7,5 +7,6 @@ namespace Orchard.Core.Common.Settings {
|
||||
public string Flavor { get; set; }
|
||||
public bool Required { get; set; }
|
||||
public string Hint { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
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.DefaultValue", model.Settings.DefaultValue);
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
@model Orchard.Core.Common.ViewModels.TextFieldSettingsEventsViewModel
|
||||
|
||||
@* This is a token-less default value editor that can be overridden from features that can depend on Orchard.Tokens. *@
|
||||
|
||||
<label for="@Html.FieldIdFor(m => m.Settings.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.Settings.DefaultValue, new { @class = "text large" })
|
||||
<span class="hint">@T("Default value for the field. If there is no value given for the actual field, this will be filled in. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.Settings.DefaultValue)
|
@@ -19,3 +19,6 @@
|
||||
<span class="hint">@T("The help text is written under the field when authors are editing the content item.")</span>
|
||||
@Html.ValidationMessageFor(m => m.Settings.Hint)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Display.DefinitionTemplate(TemplateName: "TextFieldDefaultValueEditor", Model: Model)
|
||||
</fieldset>
|
@@ -12,4 +12,7 @@
|
||||
@if (HasText(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
}
|
||||
@if (!String.IsNullOrWhiteSpace(Model.Settings.DefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
</fieldset>
|
@@ -578,6 +578,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\AdminTabs.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Common\Views\DefinitionTemplates\TextFieldDefaultValueEditor.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@@ -799,6 +799,11 @@ namespace Orchard.Core.Shapes {
|
||||
RenderInternal(Html, Output, "EditorTemplates/" + TemplateName, Model, Prefix);
|
||||
}
|
||||
|
||||
[Shape]
|
||||
public void DefinitionTemplate(HtmlHelper Html, TextWriter Output, string TemplateName, object Model, string Prefix) {
|
||||
RenderInternal(Html, Output, "DefinitionTemplates/" + TemplateName, Model, Prefix);
|
||||
}
|
||||
|
||||
static void RenderInternal(HtmlHelper Html, TextWriter Output, string TemplateName, object Model, string Prefix) {
|
||||
var adjustedViewData = new ViewDataDictionary(Html.ViewDataContainer.ViewData) {
|
||||
Model = DetermineModel(Html, Model),
|
||||
|
@@ -1,16 +1,15 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Fields.ViewModels;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Localization.Models;
|
||||
using Orchard.Localization.Services;
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class DateTimeFieldDriver : ContentFieldDriver<DateTimeField> {
|
||||
@@ -97,6 +96,7 @@ namespace Orchard.Fields.Drivers {
|
||||
Name = field.DisplayName,
|
||||
Hint = settings.Hint,
|
||||
IsRequired = settings.Required,
|
||||
HasDefaultValue = settings.DefaultValue.HasValue,
|
||||
Editor = new DateTimeEditor() {
|
||||
Date = showDate ? DateLocalizationServices.ConvertToLocalizedDateString(value, options) : null,
|
||||
Time = showTime ? DateLocalizationServices.ConvertToLocalizedTimeString(value, options) : null,
|
||||
@@ -150,7 +150,7 @@ namespace Orchard.Fields.Drivers {
|
||||
field.DateTime = utcDateTime.Value;
|
||||
}
|
||||
} else {
|
||||
field.DateTime = DateTime.MinValue;
|
||||
field.DateTime = settings.DefaultValue.HasValue ? settings.DefaultValue.Value : DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
|
@@ -1,18 +1,22 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class EnumerationFieldDriver : ContentFieldDriver<EnumerationField> {
|
||||
public IOrchardServices Services { get; set; }
|
||||
private const string TemplateName = "Fields/Enumeration.Edit";
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public EnumerationFieldDriver(IOrchardServices services) {
|
||||
public EnumerationFieldDriver(IOrchardServices services, ITokenizer tokenizer) {
|
||||
Services = services;
|
||||
_tokenizer = tokenizer;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -33,7 +37,16 @@ namespace Orchard.Fields.Drivers {
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, EnumerationField field, dynamic shapeHelper) {
|
||||
return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field, part),
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part)));
|
||||
() => {
|
||||
if (field.Value == null) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<EnumerationFieldSettings>();
|
||||
if (!String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = _tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
}
|
||||
}
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part));
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, EnumerationField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
@@ -1,19 +1,22 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class InputFieldDriver : ContentFieldDriver<InputField> {
|
||||
public IOrchardServices Services { get; set; }
|
||||
private const string TemplateName = "Fields/Input.Edit";
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public InputFieldDriver(IOrchardServices services) {
|
||||
public InputFieldDriver(IOrchardServices services, ITokenizer tokenizer) {
|
||||
Services = services;
|
||||
_tokenizer = tokenizer;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -43,6 +46,10 @@ namespace Orchard.Fields.Drivers {
|
||||
if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<InputFieldSettings>();
|
||||
|
||||
if (field.Value == null && !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = _tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
}
|
||||
|
||||
if (settings.Required && string.IsNullOrWhiteSpace(field.Value)) {
|
||||
updater.AddModelError(GetPrefix(field, part), T("The field {0} is mandatory.", T(field.DisplayName)));
|
||||
}
|
||||
|
@@ -1,18 +1,22 @@
|
||||
using System;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class LinkFieldDriver : ContentFieldDriver<LinkField> {
|
||||
public IOrchardServices Services { get; set; }
|
||||
private const string TemplateName = "Fields/Link.Edit";
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public LinkFieldDriver(IOrchardServices services) {
|
||||
public LinkFieldDriver(IOrchardServices services, ITokenizer tokenizer) {
|
||||
Services = services;
|
||||
_tokenizer = tokenizer;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
@@ -41,6 +45,15 @@ namespace Orchard.Fields.Drivers {
|
||||
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 (String.IsNullOrEmpty(field.Value) && !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = _tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
}
|
||||
|
||||
if(!String.IsNullOrEmpty(settings.TextDefaultValue) && String.IsNullOrWhiteSpace(field.Text)) {
|
||||
field.Text = _tokenizer.Replace(settings.TextDefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
}
|
||||
|
||||
if (settings.Required && string.IsNullOrWhiteSpace(field.Value)) {
|
||||
updater.AddModelError(GetPrefix(field, part), T("Url is required for {0}", field.DisplayName));
|
||||
}
|
||||
|
@@ -1,21 +1,25 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Fields.Fields;
|
||||
using Orchard.Fields.Settings;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Fields.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
public class NumericFieldDriver : ContentFieldDriver<NumericField> {
|
||||
public IOrchardServices Services { get; set; }
|
||||
private const string TemplateName = "Fields/Numeric.Edit";
|
||||
private readonly Lazy<CultureInfo> _cultureInfo;
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public NumericFieldDriver(IOrchardServices services) {
|
||||
public NumericFieldDriver(IOrchardServices services, ITokenizer tokenizer) {
|
||||
Services = services;
|
||||
_tokenizer = tokenizer;
|
||||
T = NullLocalizer.Instance;
|
||||
|
||||
_cultureInfo = new Lazy<CultureInfo>(() => CultureInfo.GetCultureInfo(Services.WorkContext.CurrentCulture));
|
||||
@@ -40,7 +44,6 @@ namespace Orchard.Fields.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, NumericField field, dynamic shapeHelper) {
|
||||
|
||||
return ContentShape("Fields_Numeric_Edit", GetDifferentiator(field, part),
|
||||
() => {
|
||||
var model = new NumericFieldViewModel {
|
||||
@@ -66,8 +69,17 @@ namespace Orchard.Fields.Drivers {
|
||||
}
|
||||
|
||||
if (!settings.Required && String.IsNullOrWhiteSpace(viewModel.Value)) {
|
||||
if (settings.DefaultValue != null) {
|
||||
if (Decimal.TryParse(_tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } }), NumberStyles.Any, _cultureInfo.Value, out value)
|
||||
&& Math.Round(value, settings.Scale) == value
|
||||
&& !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
field.Value = null;
|
||||
}
|
||||
}
|
||||
else if (Decimal.TryParse(viewModel.Value, NumberStyles.Any, _cultureInfo.Value, out value)) {
|
||||
field.Value = value;
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Fields;
|
||||
using Orchard.Core.Common.Settings;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Fields.Drivers {
|
||||
// The original driver of the TextField is in Orchard.Core, where tokenization can not be used.
|
||||
// This driver was added so the default value of the TextField can be tokenized.
|
||||
public class TextFieldDriver : ContentFieldDriver<TextField> {
|
||||
private readonly ITokenizer _tokenizer;
|
||||
|
||||
public TextFieldDriver(ITokenizer tokenizer) {
|
||||
_tokenizer = tokenizer;
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>();
|
||||
|
||||
if (String.IsNullOrEmpty(field.Value) && !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = _tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,4 +9,4 @@ Features:
|
||||
Orchard.Fields:
|
||||
Description: Contains the following fields: Input, Boolean, DateTime, Numeric, Link, Enumeration
|
||||
Category: Fields
|
||||
Dependencies: Common, Orchard.Resources
|
||||
Dependencies: Common, Orchard.Resources, Orchard.Tokens
|
||||
|
@@ -76,6 +76,7 @@
|
||||
<Content Include="Styles\Images\move.gif" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="Drivers\TextFieldDriver.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
@@ -90,6 +91,10 @@
|
||||
<Name>Orchard.Core</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Tokens\Orchard.Tokens.csproj">
|
||||
<Project>{6f759635-13d7-4e94-bcc9-80445d63f117}</Project>
|
||||
<Name>Orchard.Tokens</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Placement.info">
|
||||
@@ -149,6 +154,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Fields\Input.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\DefinitionTemplates\TextFieldDefaultValueEditor.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@@ -1,17 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using Orchard.Localization.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
public class DateTimeFieldEditorEvents : ContentDefinitionEditorEventsBase {
|
||||
private readonly IDateLocalizationServices _dateLocalizationServices;
|
||||
|
||||
public DateTimeFieldEditorEvents(IDateLocalizationServices dateLocalizationServices) {
|
||||
_dateLocalizationServices = dateLocalizationServices;
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
|
||||
if (definition.FieldDefinition.Name == "DateTimeField") {
|
||||
var model = definition.Settings.GetModel<DateTimeFieldSettings>();
|
||||
model.Editor = new DateTimeEditor() {
|
||||
ShowDate = true,
|
||||
ShowTime = true,
|
||||
Date = _dateLocalizationServices.ConvertToLocalizedDateString(model.DefaultValue),
|
||||
Time = _dateLocalizationServices.ConvertToLocalizedTimeString(model.DefaultValue),
|
||||
};
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +40,8 @@ namespace Orchard.Fields.Settings {
|
||||
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);
|
||||
}
|
||||
|
@@ -1,4 +1,7 @@
|
||||
namespace Orchard.Fields.Settings {
|
||||
using Orchard.Core.Common.ViewModels;
|
||||
using System;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
|
||||
public enum DateTimeFieldDisplays {
|
||||
DateAndTime,
|
||||
@@ -10,5 +13,7 @@
|
||||
public DateTimeFieldDisplays Display { get; set; }
|
||||
public string Hint { get; set; }
|
||||
public bool Required { get; set; }
|
||||
public DateTime? DefaultValue { get; set; }
|
||||
public DateTimeEditor Editor { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
public class EnumerationFieldListModeEvents : ContentDefinitionEditorEventsBase {
|
||||
@@ -27,6 +27,7 @@ namespace Orchard.Fields.Settings {
|
||||
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);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
public bool Required { get; set; }
|
||||
public string Options { get; set; }
|
||||
public ListMode ListMode { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
public EnumerationFieldSettings() {
|
||||
ListMode = ListMode.Dropdown;
|
||||
|
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
public class InputFieldListModeEvents : ContentDefinitionEditorEventsBase {
|
||||
@@ -32,6 +33,7 @@ namespace Orchard.Fields.Settings {
|
||||
builder.WithSetting("InputFieldSettings.Pattern", model.Pattern);
|
||||
builder.WithSetting("InputFieldSettings.EditorCssClass", model.EditorCssClass);
|
||||
builder.WithSetting("InputFieldSettings.MaxLength", model.MaxLength.ToString());
|
||||
builder.WithSetting("InputFieldSettings.DefaultValue", model.DefaultValue);
|
||||
}
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
public string Pattern { get; set; }
|
||||
public string EditorCssClass { get; set; }
|
||||
public int MaxLength { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
public InputFieldSettings() {
|
||||
Type = InputType.Text;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
public class LinkFieldListModeEvents : ContentDefinitionEditorEventsBase {
|
||||
@@ -28,6 +28,8 @@ namespace Orchard.Fields.Settings {
|
||||
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);
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@
|
||||
public TargetMode TargetMode { get; set; }
|
||||
public LinkTextMode LinkTextMode { get; set; }
|
||||
public string StaticText { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
public string TextDefaultValue { get; set; }
|
||||
|
||||
public LinkFieldSettings() {
|
||||
TargetMode = TargetMode.None;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.ContentManagement.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Orchard.Fields.Settings {
|
||||
public class NumericFieldListModeEvents : ContentDefinitionEditorEventsBase {
|
||||
@@ -28,6 +28,7 @@ namespace Orchard.Fields.Settings {
|
||||
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.DefaultValue", model.DefaultValue);
|
||||
}
|
||||
|
||||
yield return DefinitionTemplate(model);
|
||||
|
@@ -5,6 +5,7 @@
|
||||
public int Scale { get; set; }
|
||||
public decimal? Minimum { get; set; }
|
||||
public decimal? Maximum { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
|
||||
public NumericFieldSettings() {
|
||||
Scale = 0;
|
||||
|
@@ -6,5 +6,6 @@ namespace Orchard.Fields.ViewModels {
|
||||
public string Hint { get; set; }
|
||||
public bool IsRequired { get; set; }
|
||||
public DateTimeEditor Editor { get; set; }
|
||||
public bool HasDefaultValue { get; set; }
|
||||
}
|
||||
}
|
@@ -27,3 +27,12 @@
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.Editor)">@T("Default value")</label>
|
||||
@Html.EditorFor(m => m.Editor)
|
||||
<span class="hint">@T("Pick a default date for the field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.Editor)
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@@ -28,3 +28,11 @@
|
||||
<span class="hint">@T("The help text is written under the field when users are selecting an option.")</span>
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("Enter a default option for the field. You can use tokens in this field. If there is no equivalent choice among Options, it will not be used. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
@@ -77,3 +77,11 @@
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("A valid url as a default value, i.e. http://orchardproject.net, /content/file.pdf ... You can use tokens in this field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
@@ -44,3 +44,19 @@
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("A valid url as a default value, i.e. http://orchardproject.net, /content/file.pdf ... You can use tokens in this field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.TextDefaultValue)">@T("Link text default value")</label>
|
||||
@Html.TextBoxFor(m => m.TextDefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("If the Link text is set to Optional or Required, a default value can be set for it. You can use tokens in this field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.TextDefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
@@ -39,3 +39,11 @@
|
||||
@Html.ValidationMessageFor(m => m.Hint)
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<div class="editor-field">
|
||||
<label class="forpicker" for="@Html.FieldIdFor(m => m.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("The default value for the field. It must be a number, and if not it will not shown. Make sure to set the Scale property if the value is not an integer. You can use tokens in this field. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.DefaultValue)
|
||||
</div>
|
||||
</fieldset>
|
@@ -0,0 +1,7 @@
|
||||
@model Orchard.Core.Common.ViewModels.TextFieldSettingsEventsViewModel
|
||||
@* This override is here so that the token helper can be used on the default value's textbox, which can not be used in Orchard.Core. *@
|
||||
|
||||
<label for="@Html.FieldIdFor(m => m.Settings.DefaultValue)">@T("Default value")</label>
|
||||
@Html.TextBoxFor(m => m.Settings.DefaultValue, new { @class = "text large tokenized ui-autocomplete-input" })
|
||||
<span class="hint">@T("Default value for the field. You can use tokens in this field. If there is no value given for the actual field, this will be filled in. (optional)")</span>
|
||||
@Html.ValidationMessageFor(m => m.Settings.DefaultValue)
|
@@ -6,4 +6,7 @@
|
||||
@if (HasText(Model.Hint)) {
|
||||
<span class="hint">@Model.Hint</span>
|
||||
}
|
||||
@if (Model.HasDefaultValue) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used if one is configured.")</span>
|
||||
}
|
||||
</fieldset>
|
||||
|
@@ -11,4 +11,7 @@
|
||||
@if (HasText(settings.Hint)) {
|
||||
<span class="hint">@settings.Hint</span>
|
||||
}
|
||||
@if (!String.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
</fieldset>
|
||||
|
@@ -27,13 +27,21 @@
|
||||
@Html.TextBoxFor(m => m.Value, new { @class = "text large" })
|
||||
<span class="hint">@T("A valid url, i.e. http://orchardproject.net, /content/file.pdf, ...")</span>
|
||||
</div>
|
||||
@if (!String.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
@if (settings.LinkTextMode == LinkTextMode.Optional || settings.LinkTextMode == LinkTextMode.Required) {
|
||||
<div class="editor-label">
|
||||
<label for="@Html.FieldIdFor(m => m.Text)" @if(settings.LinkTextMode == LinkTextMode.Required) { <text>class="required"</text> }>@T("Text")</label>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
@Html.TextBoxFor(m => m.Text, new {@class = "text medium"})
|
||||
@Html.TextBoxFor(m => m.Text, new { @class = "text medium" })
|
||||
@if (!String.IsNullOrWhiteSpace(settings.TextDefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
else {
|
||||
<span class="hint">@T("The text of the link. If left empty, the url will be used instead.")</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
@@ -11,4 +11,7 @@
|
||||
@if (HasText(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
}
|
||||
@if (!String.IsNullOrWhiteSpace(Model.Settings.DefaultValue)) {
|
||||
<span class="hint">@T("If the field is left empty then the default value will be used.")</span>
|
||||
}
|
||||
</fieldset>
|
||||
|
@@ -5,7 +5,7 @@ using System.Web;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData {
|
||||
public static class MetaDataExtensions {
|
||||
public static class MediaMetaDataExtensions {
|
||||
/// <summary>
|
||||
/// This extension method can be used for easy image part creation. Adds all necessary parts and settings to the part.
|
||||
/// </summary>
|
@@ -101,7 +101,7 @@
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="Drivers\VectorImagePartDriver.cs" />
|
||||
<Compile Include="Extensions\MetaDataExtensions.cs" />
|
||||
<Compile Include="Extensions\MediaMetaDataExtensions.cs" />
|
||||
<Compile Include="Factories\VectorImageFactory.cs" />
|
||||
<Compile Include="Handlers\MediaLibrarySettingsPartHandler.cs" />
|
||||
<Compile Include="Models\MediaLibrarySettingsPart.cs" />
|
||||
|
@@ -5,7 +5,7 @@ using System.Web;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData {
|
||||
public static class MetaDataExtensions {
|
||||
public static class WidgetsMetaDataExtensions {
|
||||
/// <summary>
|
||||
/// This extension method can be used for easy widget creation. Adds all necessary parts and settings to the part.
|
||||
/// </summary>
|
@@ -72,7 +72,7 @@
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="ControlWrapper.cs" />
|
||||
<Compile Include="Drivers\LayerPartDriver.cs" />
|
||||
<Compile Include="Extensions\MetaDataExtensions.cs" />
|
||||
<Compile Include="Extensions\WidgetsMetaDataExtensions.cs" />
|
||||
<Compile Include="Handlers\DisplayedContentItemHandler.cs" />
|
||||
<Compile Include="Handlers\LayerHintHandler.cs" />
|
||||
<Compile Include="Drivers\WidgetPartDriver.cs" />
|
||||
|
Reference in New Issue
Block a user