diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs new file mode 100644 index 000000000..ba4e2d1dc --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs @@ -0,0 +1,71 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Fields.Fields; +using Orchard.Fields.Settings; +using Orchard.Localization; + +namespace Orchard.Fields.Drivers { + public class BooleanFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/Boolean.Edit"; + + public BooleanFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(BooleanField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, BooleanField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Boolean", GetDifferentiator(field, part), () => { + var settings = field.PartFieldDefinition.Settings.GetModel(); + return shapeHelper.Fields_Boolean().Settings(settings); + }); + } + + protected override DriverResult Editor(ContentPart part, BooleanField field, dynamic shapeHelper) { + // if the content item is new, assign the default value + if(!part.HasDraft() && !part.HasPublished()) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + field.Value = settings.DefaultValue; + } + + return ContentShape("Fields_Boolean_Edit", GetDifferentiator(field, part), + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part))); + } + + protected override DriverResult Editor(ContentPart part, BooleanField field, IUpdateModel updater, dynamic shapeHelper) { + if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + if (!settings.Optional && !field.Value.HasValue) { + updater.AddModelError(field.Name, T("The field {0} is mandatory.", T(field.DisplayName))); + } + } + + return Editor(part, field, shapeHelper); + } + + protected override void Importing(ContentPart part, BooleanField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Value", v => field.Value = bool.Parse(v)); + } + + protected override void Exporting(ContentPart part, BooleanField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member(null, typeof(Boolean), T("Value"), T("The boolean value of the field.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs new file mode 100644 index 000000000..d8e7fa4df --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs @@ -0,0 +1,126 @@ +using System; +using System.Globalization; +using System.Xml; +using JetBrains.Annotations; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.Fields.Settings; +using Orchard.Fields.ViewModels; +using Orchard.ContentManagement.Handlers; +using Orchard.Localization; + +namespace Orchard.Fields.Drivers { + [UsedImplicitly] + public class DateTimeFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/DateTime.Edit"; // EditorTemplates/Fields/DateTime.Edit.cshtml + private readonly Lazy _cultureInfo; + + public DateTimeFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + + _cultureInfo = new Lazy(() => CultureInfo.GetCultureInfo(Services.WorkContext.CurrentCulture)); + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(ContentField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, Fields.DateTimeField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_DateTime", // this is just a key in the Shape Table + GetDifferentiator(field, part), + () => { + var settings = field.PartFieldDefinition.Settings.GetModel(); + var value = field.DateTime; + + + var viewModel = new DateTimeFieldViewModel { + Name = field.DisplayName, + Date = value != DateTime.MinValue ? TimeZoneInfo.ConvertTimeFromUtc(value, Services.WorkContext.CurrentTimeZone).ToString("d", _cultureInfo.Value) : String.Empty, + Time = value != DateTime.MinValue ? TimeZoneInfo.ConvertTimeFromUtc(value, Services.WorkContext.CurrentTimeZone).ToString("t", _cultureInfo.Value) : String.Empty, + ShowDate = settings.Display == DateTimeFieldDisplays.DateAndTime || settings.Display == DateTimeFieldDisplays.DateOnly, + ShowTime = settings.Display == DateTimeFieldDisplays.DateAndTime || settings.Display == DateTimeFieldDisplays.TimeOnly, + Hint = settings.Hint, + Required = settings.Required + }; + + return shapeHelper.Fields_DateTime( // this is the actual Shape which will be resolved (Fields/DateTime.cshtml) + Model: viewModel); + } + ); + } + + protected override DriverResult Editor(ContentPart part, Fields.DateTimeField field, dynamic shapeHelper) { + + var settings = field.PartFieldDefinition.Settings.GetModel(); + var value = field.DateTime; + + var viewModel = new DateTimeFieldViewModel { + Name = field.DisplayName, + Date = value != DateTime.MinValue ? TimeZoneInfo.ConvertTimeFromUtc(value, Services.WorkContext.CurrentTimeZone).ToString("d", _cultureInfo.Value) : String.Empty, + Time = value != DateTime.MinValue ? TimeZoneInfo.ConvertTimeFromUtc(value, Services.WorkContext.CurrentTimeZone).ToString("t", _cultureInfo.Value) : String.Empty, + ShowDate = settings.Display == DateTimeFieldDisplays.DateAndTime || settings.Display == DateTimeFieldDisplays.DateOnly, + ShowTime = settings.Display == DateTimeFieldDisplays.DateAndTime || settings.Display == DateTimeFieldDisplays.TimeOnly, + Hint = settings.Hint, + Required = settings.Required + }; + + return ContentShape("Fields_DateTime_Edit", // this is just a key in the Shape Table + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: viewModel, Prefix: GetPrefix(field, part))); + } + + 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(); + + 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); + } + + protected override void Importing(ContentPart part, Fields.DateTimeField field, ImportContentContext context) { + context.ImportAttribute(GetPrefix(field, part), "Value", v => field.Storage.Set(null, XmlConvert.ToDateTime(v, XmlDateTimeSerializationMode.Utc))); + } + + protected override void Exporting(ContentPart part, Fields.DateTimeField field, ExportContentContext context) { + context.Element(GetPrefix(field, part)).SetAttributeValue("DateTime", XmlConvert.ToString(field.Storage.Get(null), XmlDateTimeSerializationMode.Utc)); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member(null, typeof(DateTime), T("Value"), T("The date time value of the field.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs new file mode 100644 index 000000000..8b6ec4d95 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs @@ -0,0 +1,65 @@ +using System; +using Orchard; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Fields.Settings; +using Orchard.Fields.Fields; +using Orchard.Localization; +using Orchard.Utility.Extensions; + +namespace Orchard.Fields.Drivers { + public class EnumerationFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/Enumeration.Edit"; + + public EnumerationFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(Fields.EnumerationField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, Fields.EnumerationField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Enumeration", GetDifferentiator(field, part), + () => shapeHelper.Fields_Enumeration()); + } + + protected override DriverResult Editor(ContentPart part, Fields.EnumerationField field, dynamic shapeHelper) { + return ContentShape("Fields_Enumeration_Edit", GetDifferentiator(field, part), + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part))); + } + + protected override DriverResult Editor(ContentPart part, Fields.EnumerationField field, IUpdateModel updater, dynamic shapeHelper) { + if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + if (settings.Required && field.SelectedValues.Length == 0) { + updater.AddModelError(field.Name, T("The field {0} is mandatory", T(field.DisplayName))); + } + } + + return Editor(part, field, shapeHelper); + } + + protected override void Importing(ContentPart part, EnumerationField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Value", v => field.Value = v); + } + + protected override void Exporting(ContentPart part, EnumerationField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member(null, typeof(string), T("Value"), T("The selected values of the field.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs new file mode 100644 index 000000000..f5788e007 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs @@ -0,0 +1,67 @@ +using System; +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; + +namespace Orchard.Fields.Drivers { + public class InputFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/Input.Edit"; + + public InputFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(InputField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, InputField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Input", GetDifferentiator(field, part), () => { + var settings = field.PartFieldDefinition.Settings.GetModel(); + return shapeHelper.Fields_Input().Settings(settings); + }); + } + + protected override DriverResult Editor(ContentPart part, InputField field, dynamic shapeHelper) { + return ContentShape("Fields_Input_Edit", GetDifferentiator(field, part), + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part))); + } + + protected override DriverResult Editor(ContentPart part, InputField field, IUpdateModel updater, dynamic shapeHelper) { + if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + + if (settings.Required && string.IsNullOrWhiteSpace(field.Value)) { + updater.AddModelError(GetPrefix(field, part), T("The field {0} is mandatory.", T(field.DisplayName))); + } + } + + return Editor(part, field, shapeHelper); + } + + protected override void Importing(ContentPart part, InputField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Value", v => field.Value = v); + } + + protected override void Exporting(ContentPart part, InputField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member(null, typeof(string), T("Value"), T("The value of the field.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs new file mode 100644 index 000000000..193ce9433 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs @@ -0,0 +1,76 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Fields.Fields; +using Orchard.Fields.Settings; +using Orchard.Localization; + +namespace Orchard.Fields.Drivers { + public class LinkFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/Link.Edit"; + + public LinkFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(ContentField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, LinkField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Link", GetDifferentiator(field, part), () => { + var settings = field.PartFieldDefinition.Settings.GetModel(); + return shapeHelper.Fields_Link().Settings(settings); + }); + } + + protected override DriverResult Editor(ContentPart part, LinkField field, dynamic shapeHelper) { + return ContentShape("Fields_Link_Edit", + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part))); + } + + 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(); + 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); + } + + protected override void Importing(ContentPart part, LinkField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Text", v => field.Text = v); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Url", v => field.Value = v); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Target", v => field.Target = v); + } + + protected override void Exporting(ContentPart part, LinkField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Text); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Target", field.Target); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member("Text", typeof(string), T("Text"), T("The text of the link.")) + .Member(null, typeof(string), T("Url"), T("The url of the link.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/MediaPickerFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/MediaPickerFieldDriver.cs new file mode 100644 index 000000000..df0e51c28 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/MediaPickerFieldDriver.cs @@ -0,0 +1,86 @@ +using System; +using System.Linq; +using Orchard.Fields.Settings; +using Orchard.FileSystems.WebSite; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Localization; +using Orchard.Utility.Extensions; + +namespace Orchard.Fields.Drivers { + public class MediaPickerFieldDriver : ContentFieldDriver { + private readonly IWebSiteFolder _webSiteFolder; + + public MediaPickerFieldDriver(IWebSiteFolder webSiteFolder) { + _webSiteFolder = webSiteFolder; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(Fields.MediaPickerField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(Fields.MediaPickerField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, Fields.MediaPickerField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_MediaPicker", GetDifferentiator(field, part), + () => shapeHelper.Fields_MediaPicker()); + } + + protected override DriverResult Editor(ContentPart part, Fields.MediaPickerField field, dynamic shapeHelper) { + return ContentShape("Fields_MediaPicker_Edit", GetDifferentiator(field, part), + () => shapeHelper.EditorTemplate(TemplateName: "Fields/MediaPicker.Edit", Model: field, Prefix: GetPrefix(field, part))); + } + + protected override DriverResult Editor(ContentPart part, Fields.MediaPickerField field, IUpdateModel updater, dynamic shapeHelper) { + // if the model could not be bound, don't try to validate its properties + if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + + var extensions = String.IsNullOrWhiteSpace(settings.AllowedExtensions) + ? new string[0] + : settings.AllowedExtensions.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); + + if (extensions.Any() && field.Url != null && !extensions.Any(x => field.Url.EndsWith(x, StringComparison.OrdinalIgnoreCase))) { + updater.AddModelError("Url", T("The field {0} must have one of these extensions: {1}", field.Name.CamelFriendly(), settings.AllowedExtensions)); + } + + if (settings.Required && String.IsNullOrWhiteSpace(field.Url)) { + updater.AddModelError("Url", T("The field {0} is mandatory", field.Name.CamelFriendly())); + } + } + + return Editor(part, field, shapeHelper); + } + + protected override void Importing(ContentPart part, Fields.MediaPickerField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Url", value => field.Url = value); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "AlternateText", value => field.AlternateText = value); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Class", value => field.Class = value); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Style", value => field.Style = value); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Alignment", value => field.Alignment = value); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Width", value => field.Width = Int32.Parse(value)); + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Height", value => field.Height = Int32.Parse(value)); + } + + protected override void Exporting(ContentPart part, Fields.MediaPickerField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Url); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("AlternateText", field.AlternateText); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Class", field.Class); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Style", field.Style); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Alignment", field.Alignment); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Width", field.Width); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Height", field.Height); + } + + protected override void Describe(DescribeMembersContext context) { + context + .Member(null, typeof(string), T("Url"), T("The url of the media.")); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs new file mode 100644 index 000000000..4a3cf0615 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs @@ -0,0 +1,85 @@ +using System; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.ContentManagement.Handlers; +using Orchard.Fields.Fields; +using Orchard.Fields.Settings; +using Orchard.Localization; + +namespace Orchard.Fields.Drivers { + public class NumericFieldDriver : ContentFieldDriver { + public IOrchardServices Services { get; set; } + private const string TemplateName = "Fields/Numeric.Edit"; + + public NumericFieldDriver(IOrchardServices services) { + Services = services; + T = NullLocalizer.Instance; + } + + public Localizer T { get; set; } + + private static string GetPrefix(ContentField field, ContentPart part) { + return part.PartDefinition.Name + "." + field.Name; + } + + private static string GetDifferentiator(NumericField field, ContentPart part) { + return field.Name; + } + + protected override DriverResult Display(ContentPart part, NumericField field, string displayType, dynamic shapeHelper) { + return ContentShape("Fields_Numeric", GetDifferentiator(field, part), () => { + var settings = field.PartFieldDefinition.Settings.GetModel(); + return shapeHelper.Fields_Numeric().Settings(settings); + }); + } + + protected override DriverResult Editor(ContentPart part, NumericField field, dynamic shapeHelper) { + return ContentShape("Fields_Numeric_Edit", GetDifferentiator(field, part), + () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: field, Prefix: GetPrefix(field, part))); + } + + protected override DriverResult Editor(ContentPart part, NumericField field, IUpdateModel updater, dynamic shapeHelper) { + if (updater.TryUpdateModel(field, GetPrefix(field, part), null, null)) { + var settings = field.PartFieldDefinition.Settings.GetModel(); + + if (settings.Required && !field.Value.HasValue) { + updater.AddModelError(GetPrefix(field, part), T("The field {0} is mandatory.", T(field.DisplayName))); + } + + if (settings.Minimum.HasValue && field.Value.HasValue && field.Value.Value < settings.Minimum.Value) { + updater.AddModelError(GetPrefix(field, part), T("The value must be greater than {0}", settings.Minimum.Value)); + } + + if (settings.Maximum.HasValue && field.Value.HasValue && field.Value.Value > settings.Maximum.Value) { + updater.AddModelError(GetPrefix(field, part), T("The value must be less than {0}", settings.Maximum.Value)); + } + + // checking the number of decimals + if(field.Value.HasValue && Math.Round(field.Value.Value, settings.Scale) != field.Value.Value) { + if(settings.Scale == 0) { + updater.AddModelError(GetPrefix(field, part), T("The field {0} must be an integer", field.DisplayName)); + } + else { + updater.AddModelError(GetPrefix(field, part), T("Invalid number of digits for {0}, max allowed: {1}", field.DisplayName, settings.Scale)); + } + + } + } + + return Editor(part, field, shapeHelper); + } + + protected override void Importing(ContentPart part, NumericField field, ImportContentContext context) { + context.ImportAttribute(field.FieldDefinition.Name + "." + field.Name, "Value", v => field.Value = decimal.Parse(v, CultureInfo.InvariantCulture), () => field.Value = (decimal?)null); + } + + protected override void Exporting(ContentPart part, NumericField field, ExportContentContext context) { + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", !field.Value.HasValue ? String.Empty : field.Value.Value.ToString(CultureInfo.InvariantCulture)); + } + + protected override void Describe(DescribeMembersContext context) { + context.Member(null, typeof(decimal), T("Value"), T("The value of the field.")); + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/BooleanField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/BooleanField.cs new file mode 100644 index 000000000..4f8a6c79c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/BooleanField.cs @@ -0,0 +1,14 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class BooleanField : ContentField { + + public Boolean? Value { + get { return Storage.Get(); } + + set { Storage.Set(value); } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/DateTimeField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/DateTimeField.cs new file mode 100644 index 000000000..58d7c69fd --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/DateTimeField.cs @@ -0,0 +1,17 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class DateTimeField : ContentField { + + public DateTime DateTime { + get { + var value = Storage.Get(); + return value; + } + + set { Storage.Set(value); } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/EnumerationField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/EnumerationField.cs new file mode 100644 index 000000000..7c45f3da6 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/EnumerationField.cs @@ -0,0 +1,34 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class EnumerationField : ContentField { + private const char Separator = ';'; + + public string Value { + get { return Storage.Get(); } + set { Storage.Set(value ?? String.Empty); } + } + + public string[] SelectedValues { + get { + var value = Value; + if(string.IsNullOrWhiteSpace(value)) { + return new string[0]; + } + + return value.Split(new [] { Separator }, StringSplitOptions.RemoveEmptyEntries); + } + + set { + if (value == null || value.Length == 0) { + Value = String.Empty; + } + else { + Value = Separator + string.Join(Separator.ToString(), value) + Separator; + } + } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/InputField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/InputField.cs new file mode 100644 index 000000000..e21a46bc8 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/InputField.cs @@ -0,0 +1,13 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class InputField : ContentField { + + public string Value { + get { return Storage.Get(); } + set { Storage.Set(value ?? String.Empty); } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/LinkField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/LinkField.cs new file mode 100644 index 000000000..792e1e046 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/LinkField.cs @@ -0,0 +1,23 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class LinkField : ContentField { + + public string Value { + get { return Storage.Get(); } + set { Storage.Set(value ?? String.Empty); } + } + + public string Text { + get { return Storage.Get("Text"); } + set { Storage.Set("Text", value ?? String.Empty); } + } + + public string Target { + get { return Storage.Get("Target"); } + set { Storage.Set("Target", value ?? String.Empty); } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/MediaPickerField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/MediaPickerField.cs new file mode 100644 index 000000000..a3c9a2ec8 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/MediaPickerField.cs @@ -0,0 +1,42 @@ +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class MediaPickerField : ContentField { + public string Url { + get { return Storage.Get(); } + set { Storage.Set(value); } + } + + public string AlternateText { + get { return Storage.Get("AlternateText"); } + set { Storage.Set("AlternateText", value); } + } + + public string Class { + get { return Storage.Get("Class"); } + set { Storage.Set("Class", value); } + } + + public string Style { + get { return Storage.Get("Style"); } + set { Storage.Set("Style", value); } + } + + public string Alignment { + get { return Storage.Get("Alignment"); } + set { Storage.Set("Alignment", value); } + } + + public int Width { + get { return Storage.Get("Width"); } + set { Storage.Set("Width", value); } + } + + public int Height { + get { return Storage.Get("Height"); } + set { Storage.Set("Height", value); } + } + + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Fields/NumericField.cs b/src/Orchard.Web/Modules/Orchard.Fields/Fields/NumericField.cs new file mode 100644 index 000000000..5375df450 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Fields/NumericField.cs @@ -0,0 +1,13 @@ +using System; +using Orchard.ContentManagement; +using Orchard.ContentManagement.FieldStorage; + +namespace Orchard.Fields.Fields { + public class NumericField : ContentField { + + public Decimal? Value { + get { return Storage.Get(); } + set { Storage.Set(value); } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Module.txt b/src/Orchard.Web/Modules/Orchard.Fields/Module.txt new file mode 100644 index 000000000..c50e5dbfa --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Module.txt @@ -0,0 +1,12 @@ +Name: Fields +AntiForgery: enabled +Author: Antoine Griffard, Sébastien Ros +Website: http://orchardfields.codeplex.com +Version: 1.5 +OrchardVersion: 1.4 +Description: Some content fields +Features: + Orchard.Fields: + Description: Contains the following fields: Input, Boolean, DateTime, Numeric, Link, Enumeration, Media Picker + Category: Fields + Dependencies: Orchard.jQuery, Orchard.Media, Orchard.MediaPicker diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Orchard.Fields.csproj b/src/Orchard.Web/Modules/Orchard.Fields/Orchard.Fields.csproj new file mode 100644 index 000000000..2195e2170 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Orchard.Fields.csproj @@ -0,0 +1,203 @@ + + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {3787DDE5-E5C8-4841-BDA7-DCB325388064} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Orchard.Fields + Orchard.Fields + v4.0 + false + + + 4.0 + + + + false + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + + + pdbonly + true + bin\ + TRACE + prompt + 4 + AllRules.ruleset + + + + + + + 3.5 + + + + False + ..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll + + + + + + + + + + + + + + + + + + + + + + + {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} + Orchard.Framework + + + {9916839C-39FC-4CEB-A5AF-89CA7E87119F} + Orchard.Core + + + {D9A7B330-CD22-4DA1-A95A-8DE1982AD8EB} + Orchard.Media + + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + $(ProjectDir)\..\Manifests + + + + + + + + + + + + False + True + 33679 + / + + + False + True + http://orchard.codeplex.com + False + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Placement.info b/src/Orchard.Web/Modules/Orchard.Fields/Placement.info new file mode 100644 index 000000000..12d0379d9 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Placement.info @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Properties/AssemblyInfo.cs b/src/Orchard.Web/Modules/Orchard.Fields/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d324e02be --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Security; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Orchard.Fields")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("Orchard")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c69946e0-8957-4591-ae0a-8ca8084617af")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.5")] +[assembly: AssemblyFileVersion("1.5")] diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Scripts/Web.config b/src/Orchard.Web/Modules/Orchard.Fields/Scripts/Web.config new file mode 100644 index 000000000..178ff35ba --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Scripts/Web.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Scripts/hint.js b/src/Orchard.Web/Modules/Orchard.Fields/Scripts/hint.js new file mode 100644 index 000000000..2f24447f3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Scripts/hint.js @@ -0,0 +1,13 @@ +$(document).ready(function () { + $("label.forpicker").each(function () { + var $this = $(this); + var pickerInput = $("#" + $this.attr("for")); + pickerInput.data("hint", $this.text()); + if (!pickerInput.val()) { + pickerInput.addClass("hinted") + .val(pickerInput.data("hint")) + .focus(function () { var $this = $(this); if ($this.val() == $this.data("hint")) { $this.removeClass("hinted").val("") } }) + .blur(function () { var $this = $(this); setTimeout(function () { if (!$this.val()) { $this.addClass("hinted").val($this.data("hint")) } }, 300) }); + } + }); +}); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldEditorEvents.cs new file mode 100644 index 000000000..870d12f1a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldEditorEvents.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class BooleanFieldListModeEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "BooleanField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldSettings.cs new file mode 100644 index 000000000..1ef4f3182 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/BooleanFieldSettings.cs @@ -0,0 +1,23 @@ +namespace Orchard.Fields.Settings { + public class BooleanFieldSettings { + public string Hint { get; set; } + public bool Optional { get; set; } + public string NotSetLabel { get; set; } + public string OnLabel { get; set; } + public string OffLabel { get; set; } + public SelectionMode SelectionMode { get; set; } + public bool? DefaultValue { get; set; } + + public BooleanFieldSettings() { + OnLabel = "Yes"; + OffLabel = "No"; + SelectionMode = SelectionMode.Checkbox; + } + } + + public enum SelectionMode { + Checkbox, + Radiobutton, + Dropdown + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldEditorEvents.cs new file mode 100644 index 000000000..22de77994 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldEditorEvents.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class DateTimeFieldEditorEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "DateTimeField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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)); + + yield return DefinitionTemplate(model); + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldSettings.cs new file mode 100644 index 000000000..a4caf984c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/DateTimeFieldSettings.cs @@ -0,0 +1,14 @@ +namespace Orchard.Fields.Settings { + + public enum DateTimeFieldDisplays { + DateAndTime, + DateOnly, + TimeOnly + } + + public class DateTimeFieldSettings { + public DateTimeFieldDisplays Display { get; set; } + public string Hint { get; set; } + public bool Required { get; set; } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldEditorEvents.cs new file mode 100644 index 000000000..d0b33a66e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldEditorEvents.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class EnumerationFieldListModeEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "EnumerationField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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()); + } + + yield return DefinitionTemplate(model); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldSettings.cs new file mode 100644 index 000000000..555955de5 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/EnumerationFieldSettings.cs @@ -0,0 +1,20 @@ +namespace Orchard.Fields.Settings { + + public enum ListMode { + Dropdown, + Radiobutton, + Listbox, + Checkbox + } + + public class EnumerationFieldSettings { + public string Hint { get; set; } + public bool Required { get; set; } + public string Options { get; set; } + public ListMode ListMode { get; set; } + + public EnumerationFieldSettings() { + ListMode = ListMode.Dropdown; + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldEditorEvents.cs new file mode 100644 index 000000000..39de50cb0 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldEditorEvents.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class InputFieldListModeEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "InputField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) { + if (builder.FieldType != "InputField") { + yield break; + } + + var model = new InputFieldSettings(); + if (updateModel.TryUpdateModel(model, "InputFieldSettings", null, null)) { + builder.WithSetting("InputFieldSettings.Type", model.Type.ToString()); + builder.WithSetting("InputFieldSettings.Title", model.Title); + builder.WithSetting("InputFieldSettings.Hint", model.Hint); + builder.WithSetting("InputFieldSettings.Required", model.Required.ToString()); + builder.WithSetting("InputFieldSettings.AutoFocus", model.AutoFocus.ToString()); + builder.WithSetting("InputFieldSettings.AutoComplete", model.AutoComplete.ToString()); + builder.WithSetting("InputFieldSettings.Placeholder", model.Placeholder); + builder.WithSetting("InputFieldSettings.Pattern", model.Pattern); + builder.WithSetting("InputFieldSettings.EditorCssClass", model.EditorCssClass); + builder.WithSetting("InputFieldSettings.MaxLength", model.MaxLength.ToString()); + } + + yield return DefinitionTemplate(model); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldSettings.cs new file mode 100644 index 000000000..ac490eef2 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/InputFieldSettings.cs @@ -0,0 +1,26 @@ +namespace Orchard.Fields.Settings { + + public enum InputType { + Text, + Url, + Tel, + Email + } + + public class InputFieldSettings { + public InputType Type { get; set; } + public string Title { get; set; } + public string Hint { get; set; } + public bool Required { get; set; } + public bool AutoFocus { get; set; } + public bool AutoComplete { get; set; } + public string Placeholder { get; set; } + public string Pattern { get; set; } + public string EditorCssClass { get; set; } + public int MaxLength { get; set; } + + public InputFieldSettings() { + Type = InputType.Text; + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldEditorEvents.cs new file mode 100644 index 000000000..77c5f6ab1 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldEditorEvents.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class LinkFieldListModeEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "LinkField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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); + } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldSettings.cs new file mode 100644 index 000000000..03c50a46e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/LinkFieldSettings.cs @@ -0,0 +1,33 @@ +namespace Orchard.Fields.Settings { + public class LinkFieldSettings { + public string Hint { get; set; } + public bool Required { get; set; } + public TargetMode TargetMode { get; set; } + public LinkTextMode LinkTextMode { get; set; } + public string StaticText { get; set; } + + public LinkFieldSettings() { + TargetMode = TargetMode.None; + LinkTextMode = LinkTextMode.Optional; + } + } + + public enum TargetMode { + None, + NewWindow, + Parent, + Top, + UserChoice + } + + public enum LinkTextMode { + // some text can be entered or not, if not the url is used + Optional, + // some text must be entered + Required, + // the text is hard coded in the settings + Static, + // the url is used + Url + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldEditorEvents.cs new file mode 100644 index 000000000..2cf0e6c5b --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldEditorEvents.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class MediaPickerFieldEditorEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "MediaPickerField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldSettings.cs new file mode 100644 index 000000000..235147807 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/MediaPickerFieldSettings.cs @@ -0,0 +1,10 @@ +namespace Orchard.Fields.Settings { + public class MediaPickerFieldSettings { + public string Hint { get; set; } + public string AllowedExtensions { get; set; } + public bool Required { get; set; } + public string Custom1 { get; set; } + public string Custom2 { get; set; } + public string Custom3 { get; set; } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldEditorEvents.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldEditorEvents.cs new file mode 100644 index 000000000..6883eccdd --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldEditorEvents.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Globalization; +using Orchard.ContentManagement; +using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.MetaData.Builders; +using Orchard.ContentManagement.MetaData.Models; +using Orchard.ContentManagement.ViewModels; + +namespace Orchard.Fields.Settings { + public class NumericFieldListModeEvents : ContentDefinitionEditorEventsBase { + + public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) { + if (definition.FieldDefinition.Name == "NumericField") { + var model = definition.Settings.GetModel(); + yield return DefinitionTemplate(model); + } + } + + public override IEnumerable 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); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldSettings.cs b/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldSettings.cs new file mode 100644 index 000000000..8c94885bf --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Settings/NumericFieldSettings.cs @@ -0,0 +1,13 @@ +namespace Orchard.Fields.Settings { + public class NumericFieldSettings { + public string Hint { get; set; } + public bool Required { get; set; } + public int Scale { get; set; } + public decimal? Minimum { get; set; } + public decimal? Maximum { get; set; } + + public NumericFieldSettings() { + Scale = 0; + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/App.config b/src/Orchard.Web/Modules/Orchard.Fields/Specs/App.config new file mode 100644 index 000000000..520cffb54 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/App.config @@ -0,0 +1,12 @@ + + + +
+ + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature new file mode 100644 index 000000000..ac45e5fa6 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature @@ -0,0 +1,82 @@ +Feature: Boolean Field + In order to add boolean content to my types + As an administrator + I want to create, edit and publish boolean fields + +Scenario: Creating and using Boolean fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Boolean field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Active | + | Name | Active | + | FieldTypeName | BooleanField | + And I hit "Save" + And I am redirected + Then I should see "The \"Active\" field has been added." + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Active" + When I fill in + | name | value | + | Event.Active.Value | true | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Active:" + And I should see "Yes" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].BooleanFieldSettings.Hint | Check if the event is active | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Check if the event is active" + + # The default value should be selected + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].BooleanFieldSettings.DefaultValue | True | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "checked=\"checked\"" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].BooleanFieldSettings.Optional | false | + And I fill in + | name | value | + | Fields[0].BooleanFieldSettings.NotSetLabel | May be | + And I fill in + | name | value | + | Fields[0].BooleanFieldSettings.SelectionMode | Radiobutton | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.Active.Value | | + And I hit "Save" + Then I should see "The field Active is mandatory." \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature.cs new file mode 100644 index 000000000..2c58473a3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Boolean.feature.cs @@ -0,0 +1,239 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Boolean Field")] + public partial class BooleanFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Boolean.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Boolean Field", " In order to add boolean content to my types\r\nAs an administrator\r\n I want to c" + + "reate, edit and publish boolean fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using Boolean fields")] + public virtual void CreatingAndUsingBooleanFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Boolean fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Active"}); + table2.AddRow(new string[] { + "Name", + "Active"}); + table2.AddRow(new string[] { + "FieldTypeName", + "BooleanField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Active\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 36 + testRunner.Then("I should see \"Active\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Event.Active.Value", + "true"}); +#line 37 + testRunner.When("I fill in", ((string)(null)), table3, "When "); +#line 40 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 41 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 42 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 43 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 44 + testRunner.Then("I should see \"Active:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 45 + testRunner.And("I should see \"Yes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 48 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Fields[0].BooleanFieldSettings.Hint", + "Check if the event is active"}); +#line 49 + testRunner.And("I fill in", ((string)(null)), table4, "And "); +#line 52 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 53 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 54 + testRunner.Then("I should see \"Check if the event is active\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 57 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].BooleanFieldSettings.DefaultValue", + "True"}); +#line 58 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 61 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 62 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 63 + testRunner.Then("I should see \"checked=\\\"checked\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 66 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Fields[0].BooleanFieldSettings.Optional", + "false"}); +#line 67 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Fields[0].BooleanFieldSettings.NotSetLabel", + "May be"}); +#line 70 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Fields[0].BooleanFieldSettings.SelectionMode", + "Radiobutton"}); +#line 73 + testRunner.And("I fill in", ((string)(null)), table8, "And "); +#line 76 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 77 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table9.AddRow(new string[] { + "Event.Active.Value", + ""}); +#line 78 + testRunner.And("I fill in", ((string)(null)), table9, "And "); +#line 81 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 82 + testRunner.Then("I should see \"The field Active is mandatory.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Content/orchard.core.po b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Content/orchard.core.po new file mode 100644 index 000000000..ab5da0d48 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Content/orchard.core.po @@ -0,0 +1,16 @@ +# Orchard resource strings - fr-FR +# Copyright (c) 2010 Outercurve Foundation +# All rights reserved +# This file is distributed under the BSD license + +#: Orchard.Core.Shapes.Localization.DateTimeLocalization +#| msgid "h:mm tt" +msgctxt "Orchard.Core.Shapes.Localization.DateTimeLocalization" +msgid "h:mm tt" +msgstr "HH:mm" + +#: Orchard.Core.Shapes.Localization.DateTimeLocalization +#| msgid "M/d/yyyy" +msgctxt "Orchard.Core.Shapes.Localization.DateTimeLocalization" +msgid "M/d/yyyy" +msgstr "dd/MM/yyyy" diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature new file mode 100644 index 000000000..238954842 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature @@ -0,0 +1,193 @@ +Feature: DateTime Field + In order to add Date content to my types + As an administrator + I want to create, edit and publish DateTime fields + +Scenario: Creating and using Date fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Date field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Date of the event | + | Name | EventDate | + | FieldTypeName | DateTimeField | + And I hit "Save" + And I am redirected + Then I should see "The \"Date of the event\" field has been added." + + # Invalid Date + When I go to "Admin/Contents/Create/Event" + Then I should see "Date of the event" + When I fill in + | name | value | + | Event.EventDate.Date | 31/01/2012 | + | Event.EventDate.Time | 12:00 AM | + And I hit "Save" + Then I should see "Date of the event is an invalid date and time" + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Date of the event" + When I fill in + | name | value | + | Event.EventDate.Date | 01/31/2012 | + And I fill in + | name | value | + | Event.EventDate.Time | 12:00 AM | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Date of the event:" + And I should see "1/31/2012 12:00" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Hint | Enter the date of the event | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Enter the date of the event" + + # Display = DateOnly + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | DateOnly | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Event.EventDate.Date" + And I should not see "Event.EventDate.Time" + + # Display = TimeOnly + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | TimeOnly | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Event.EventDate.Time" + And I should not see "Event.EventDate.Date" + + # Required & Date and Time + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | DateAndTime | + | Fields[0].DateTimeFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Event.EventDate.Date" + When I fill in + | name | value | + | Event.EventDate.Date | 01/31/2012 | + | Event.EventDate.Time | 12:00 AM | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.EventDate.Date | 01/31/2012 | + And I hit "Save" + Then I should see "Date of the event is required." + When I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.EventDate.Time | 12:00 AM | + And I hit "Save" + Then I should see "Date of the event is required." + + # Required & Date only + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | DateOnly | + | Fields[0].DateTimeFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Event.EventDate.Date" + When I hit "Save" + Then I should see "Date of the event is required." + + # Required & Time only + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | TimeOnly | + | Fields[0].DateTimeFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Event.EventDate.Date" + When I hit "Save" + Then I should see "Date of the event is required." + +Scenario: Creating and using date time fields in another culture + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + And I have the file "Content\orchard.core.po" in "Core\App_Data\Localization\fr-FR\orchard.core.po" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Date field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Date of the event | + | Name | EventDate | + | FieldTypeName | DateTimeField | + And I hit "Save" + And I am redirected + Then I should see "The \"Date of the event\" field has been added." + + # Date & Time are inputted based on current culture + When I have "fr-FR" as the default culture + And I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].DateTimeFieldSettings.Display | DateAndTime | + | Fields[0].DateTimeFieldSettings.Required | true | + And I hit "Save" + When I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.EventDate.Date | 01/31/2012 | + | Event.EventDate.Time | 12:00 AM | + And I hit "Save" + Then I should see "Date of the event is an invalid date and time" + When I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.EventDate.Date | 31/01/2012 | + | Event.EventDate.Time | 18:00 | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature.cs new file mode 100644 index 000000000..9c6506387 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/DateTime.feature.cs @@ -0,0 +1,482 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("DateTime Field")] + public partial class DateTimeFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "DateTime.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "DateTime Field", " In order to add Date content to my types\r\nAs an administrator\r\n I want to crea" + + "te, edit and publish DateTime fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using Date fields")] + public virtual void CreatingAndUsingDateFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Date fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Date of the event"}); + table2.AddRow(new string[] { + "Name", + "EventDate"}); + table2.AddRow(new string[] { + "FieldTypeName", + "DateTimeField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Date of the event\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 36 + testRunner.Then("I should see \"Date of the event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Event.EventDate.Date", + "31/01/2012"}); + table3.AddRow(new string[] { + "Event.EventDate.Time", + "12:00 AM"}); +#line 37 + testRunner.When("I fill in", ((string)(null)), table3, "When "); +#line 41 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 42 + testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 45 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 46 + testRunner.Then("I should see \"Date of the event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Event.EventDate.Date", + "01/31/2012"}); +#line 47 + testRunner.When("I fill in", ((string)(null)), table4, "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Event.EventDate.Time", + "12:00 AM"}); +#line 50 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 53 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 54 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 55 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 56 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 57 + testRunner.Then("I should see \"Date of the event:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 58 + testRunner.And("I should see \"1/31/2012 12:00\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 61 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Hint", + "Enter the date of the event"}); +#line 62 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 65 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 66 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 67 + testRunner.Then("I should see \"Enter the date of the event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 70 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "DateOnly"}); +#line 71 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 74 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 75 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 76 + testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 77 + testRunner.And("I should not see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 80 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "TimeOnly"}); +#line 81 + testRunner.And("I fill in", ((string)(null)), table8, "And "); +#line 84 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 85 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 86 + testRunner.Then("I should see \"Event.EventDate.Time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 87 + testRunner.And("I should not see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 90 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table9.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "DateAndTime"}); + table9.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Required", + "true"}); +#line 91 + testRunner.And("I fill in", ((string)(null)), table9, "And "); +#line 95 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 96 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 97 + testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table10.AddRow(new string[] { + "Event.EventDate.Date", + "01/31/2012"}); + table10.AddRow(new string[] { + "Event.EventDate.Time", + "12:00 AM"}); +#line 98 + testRunner.When("I fill in", ((string)(null)), table10, "When "); +#line 102 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 103 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 104 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 105 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table11.AddRow(new string[] { + "Event.EventDate.Date", + "01/31/2012"}); +#line 106 + testRunner.And("I fill in", ((string)(null)), table11, "And "); +#line 109 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 110 + testRunner.Then("I should see \"Date of the event is required.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 111 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table12.AddRow(new string[] { + "Event.EventDate.Time", + "12:00 AM"}); +#line 112 + testRunner.And("I fill in", ((string)(null)), table12, "And "); +#line 115 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 116 + testRunner.Then("I should see \"Date of the event is required.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 119 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table13 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table13.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "DateOnly"}); + table13.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Required", + "true"}); +#line 120 + testRunner.And("I fill in", ((string)(null)), table13, "And "); +#line 124 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 125 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 126 + testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 127 + testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 128 + testRunner.Then("I should see \"Date of the event is required.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 131 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table14 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table14.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "TimeOnly"}); + table14.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Required", + "true"}); +#line 132 + testRunner.And("I fill in", ((string)(null)), table14, "And "); +#line 136 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 137 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 138 + testRunner.Then("I should see \"Event.EventDate.Date\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 139 + testRunner.When("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 140 + testRunner.Then("I should see \"Date of the event is required.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using date time fields in another culture")] + public virtual void CreatingAndUsingDateTimeFieldsInAnotherCulture() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using date time fields in another culture", ((string[])(null))); +#line 142 +this.ScenarioSetup(scenarioInfo); +#line 145 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 146 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 147 + testRunner.And("I have the file \"Content\\orchard.core.po\" in \"Core\\App_Data\\Localization\\fr-FR\\or" + + "chard.core.po\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 148 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 149 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 150 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table15 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table15.AddRow(new string[] { + "DisplayName", + "Event"}); + table15.AddRow(new string[] { + "Name", + "Event"}); +#line 151 + testRunner.And("I fill in", ((string)(null)), table15, "And "); +#line 155 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 156 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 157 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 160 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 161 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table16 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table16.AddRow(new string[] { + "DisplayName", + "Date of the event"}); + table16.AddRow(new string[] { + "Name", + "EventDate"}); + table16.AddRow(new string[] { + "FieldTypeName", + "DateTimeField"}); +#line 162 + testRunner.And("I fill in", ((string)(null)), table16, "And "); +#line 167 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 168 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 169 + testRunner.Then("I should see \"The \\\"Date of the event\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 172 + testRunner.When("I have \"fr-FR\" as the default culture", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 173 + testRunner.And("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table17 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table17.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Display", + "DateAndTime"}); + table17.AddRow(new string[] { + "Fields[0].DateTimeFieldSettings.Required", + "true"}); +#line 174 + testRunner.And("I fill in", ((string)(null)), table17, "And "); +#line 178 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 179 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table18 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table18.AddRow(new string[] { + "Event.EventDate.Date", + "01/31/2012"}); + table18.AddRow(new string[] { + "Event.EventDate.Time", + "12:00 AM"}); +#line 180 + testRunner.And("I fill in", ((string)(null)), table18, "And "); +#line 184 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 185 + testRunner.Then("I should see \"Date of the event is an invalid date and time\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 186 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table19 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table19.AddRow(new string[] { + "Event.EventDate.Date", + "31/01/2012"}); + table19.AddRow(new string[] { + "Event.EventDate.Time", + "18:00"}); +#line 187 + testRunner.And("I fill in", ((string)(null)), table19, "And "); +#line 191 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 192 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 193 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature new file mode 100644 index 000000000..cd3d7e476 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature @@ -0,0 +1,109 @@ +Feature: Enumeration Field + In order to add a list of elements to my types + As an administrator + I want to create, edit and publish Enumeration fields + +Scenario: Creating and using Enumeration fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Enumeration field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Location | + | Name | Location | + | FieldTypeName | EnumerationField | + And I hit "Save" + And I am redirected + Then I should see "The \"Location\" field has been added." + + # Specifying Options + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.Options | Seattle | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "" + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Location" + When I fill in + | name | value | + | Event.Location.Value | Seattle | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Location:" + And I should see "Seattle" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.Hint | Please select a location | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Please select a location" + + # The List Mode Dropdown + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.ListMode | Dropdown | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "select id=\"Event_Location_Value\" name=\"Event.Location.Value\"" + + # The List Mode Radiobutton + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.ListMode | Radiobutton | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "input id=\"Event_Location_Value\" name=\"Event.Location.Value\" type=\"radio\"" + + # The List Mode Listbox + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.ListMode | Listbox | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "select id=\"Event_Location_SelectedValues\" multiple=\"multiple\" name=\"Event.Location.SelectedValues\"" + + # The List Mode Checkbox + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.ListMode | Checkbox | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "input type=\"checkbox\" name=\"Event.Location.SelectedValues\"" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].EnumerationFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I hit "Save" + Then I should see "The field Location is mandatory." diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature.cs new file mode 100644 index 000000000..206fcb6ab --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Enumeration.feature.cs @@ -0,0 +1,282 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Enumeration Field")] + public partial class EnumerationFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Enumeration.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Enumeration Field", " In order to add a list of elements to my types\r\nAs an administrator\r\n I want t" + + "o create, edit and publish Enumeration fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using Enumeration fields")] + public virtual void CreatingAndUsingEnumerationFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Enumeration fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Location"}); + table2.AddRow(new string[] { + "Name", + "Location"}); + table2.AddRow(new string[] { + "FieldTypeName", + "EnumerationField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Location\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.Options", + "Seattle"}); +#line 36 + testRunner.And("I fill in", ((string)(null)), table3, "And "); +#line 39 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 40 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 41 + testRunner.Then("I should see \"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 44 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 45 + testRunner.Then("I should see \"Location\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Event.Location.Value", + "Seattle"}); +#line 46 + testRunner.When("I fill in", ((string)(null)), table4, "When "); +#line 49 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 50 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 51 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 52 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 53 + testRunner.Then("I should see \"Location:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 54 + testRunner.And("I should see \"Seattle\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 57 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.Hint", + "Please select a location"}); +#line 58 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 61 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 62 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 63 + testRunner.Then("I should see \"Please select a location\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 66 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.ListMode", + "Dropdown"}); +#line 67 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 70 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 71 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 72 + testRunner.Then("I should see \"select id=\\\"Event_Location_Value\\\" name=\\\"Event.Location.Value\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 75 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.ListMode", + "Radiobutton"}); +#line 76 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 79 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 80 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 81 + testRunner.Then("I should see \"input id=\\\"Event_Location_Value\\\" name=\\\"Event.Location.Value\\\" typ" + + "e=\\\"radio\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 84 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.ListMode", + "Listbox"}); +#line 85 + testRunner.And("I fill in", ((string)(null)), table8, "And "); +#line 88 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 89 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 90 + testRunner.Then("I should see \"select id=\\\"Event_Location_SelectedValues\\\" multiple=\\\"multiple\\\" n" + + "ame=\\\"Event.Location.SelectedValues\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 93 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table9.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.ListMode", + "Checkbox"}); +#line 94 + testRunner.And("I fill in", ((string)(null)), table9, "And "); +#line 97 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 98 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 99 + testRunner.Then("I should see \"input type=\\\"checkbox\\\" name=\\\"Event.Location.SelectedValues\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 102 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table10.AddRow(new string[] { + "Fields[0].EnumerationFieldSettings.Required", + "true"}); +#line 103 + testRunner.And("I fill in", ((string)(null)), table10, "And "); +#line 106 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 107 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 108 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 109 + testRunner.Then("I should see \"The field Location is mandatory.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature new file mode 100644 index 000000000..5d8f409c6 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature @@ -0,0 +1,130 @@ +Feature: Input Field + In order to add an input to my types + As an administrator + I want to create, edit and publish input fields + +Scenario: Creating and using Input fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Input field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Contact | + | Name | Contact | + | FieldTypeName | InputField | + And I hit "Save" + And I am redirected + Then I should see "The \"Contact\" field has been added." + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.Hint | Enter the contact email address | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Enter the contact email address" + + # The pattern should be effective + #When I go to "Admin/ContentTypes/Edit/Event" + # And I fill in + # | name | value | + # | Fields[0].InputFieldSettings.Pattern | [^@]*@[^@]* | + # And I hit "Save" + # And I go to "Admin/Contents/Create/Event" + #Then I should see "pattern=\"[^@]*@[^@]*\"" + + # The input type should be effective + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.Type | Email | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "type=\"email\"" + + # The title should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.Title | Enter an email address | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "title=\"Enter an email address\"" + + # The auto focus should be effective + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.AutoFocus | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "autofocus=\"autofocus\"" + + # The auto complete should be effective + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.AutoComplete | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "autocomplete=\"on\"" + + # The watermark should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.Placeholder | email@domain.com | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "placeholder=\"email@domain.com\"" + + # The maxlength should be effective + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.MaxLength | 100 | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "maxlength=\"100\"" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].InputFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.Contact.Value | | + And I hit "Save" + Then I should see "The field Contact is mandatory." + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Contact" + When I fill in + | name | value | + | Event.Contact.Value | contact@orchardproject.net | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Contact:" + And I should see "contact@orchardproject.net" diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature.cs new file mode 100644 index 000000000..8f6d09af3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Input.feature.cs @@ -0,0 +1,306 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Input Field")] + public partial class InputFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Input.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Input Field", " In order to add an input to my types\r\nAs an administrator\r\n I want to create, " + + "edit and publish input fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using Input fields")] + public virtual void CreatingAndUsingInputFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Input fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Contact"}); + table2.AddRow(new string[] { + "Name", + "Contact"}); + table2.AddRow(new string[] { + "FieldTypeName", + "InputField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Contact\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Fields[0].InputFieldSettings.Hint", + "Enter the contact email address"}); +#line 36 + testRunner.And("I fill in", ((string)(null)), table3, "And "); +#line 39 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 40 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 41 + testRunner.Then("I should see \"Enter the contact email address\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 53 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Fields[0].InputFieldSettings.Type", + "Email"}); +#line 54 + testRunner.And("I fill in", ((string)(null)), table4, "And "); +#line 57 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 58 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 59 + testRunner.Then("I should see \"type=\\\"email\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 62 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].InputFieldSettings.Title", + "Enter an email address"}); +#line 63 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 66 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 67 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 68 + testRunner.Then("I should see \"title=\\\"Enter an email address\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 71 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Fields[0].InputFieldSettings.AutoFocus", + "true"}); +#line 72 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 75 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 76 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 77 + testRunner.Then("I should see \"autofocus=\\\"autofocus\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 80 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Fields[0].InputFieldSettings.AutoComplete", + "true"}); +#line 81 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 84 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 85 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 86 + testRunner.Then("I should see \"autocomplete=\\\"on\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 89 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Fields[0].InputFieldSettings.Placeholder", + "email@domain.com"}); +#line 90 + testRunner.And("I fill in", ((string)(null)), table8, "And "); +#line 93 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 94 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 95 + testRunner.Then("I should see \"placeholder=\\\"email@domain.com\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 98 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table9.AddRow(new string[] { + "Fields[0].InputFieldSettings.MaxLength", + "100"}); +#line 99 + testRunner.And("I fill in", ((string)(null)), table9, "And "); +#line 102 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 103 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 104 + testRunner.Then("I should see \"maxlength=\\\"100\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 107 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table10.AddRow(new string[] { + "Fields[0].InputFieldSettings.Required", + "true"}); +#line 108 + testRunner.And("I fill in", ((string)(null)), table10, "And "); +#line 111 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 112 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table11 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table11.AddRow(new string[] { + "Event.Contact.Value", + ""}); +#line 113 + testRunner.And("I fill in", ((string)(null)), table11, "And "); +#line 116 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 117 + testRunner.Then("I should see \"The field Contact is mandatory.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 120 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 121 + testRunner.Then("I should see \"Contact\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table12 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table12.AddRow(new string[] { + "Event.Contact.Value", + "contact@orchardproject.net"}); +#line 122 + testRunner.When("I fill in", ((string)(null)), table12, "When "); +#line 125 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 126 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 127 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 128 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 129 + testRunner.Then("I should see \"Contact:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 130 + testRunner.And("I should see \"contact@orchardproject.net\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature new file mode 100644 index 000000000..d030b85a1 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature @@ -0,0 +1,70 @@ +Feature: Link Field + In order to add Link content to my types + As an administrator + I want to create, edit and publish Link fields + +Scenario: Creating and using Link fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a Link field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Site Url | + | Name | SiteUrl | + | FieldTypeName | LinkField | + And I hit "Save" + And I am redirected + Then I should see "The \"Site Url\" field has been added." + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Site Url" + When I fill in + | name | value | + | Event.SiteUrl.Value | http://www.orchardproject.net | + And I fill in + | name | value | + | Event.SiteUrl.Text | Orchard | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Site Url:" + And I should see "Orchard" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].LinkFieldSettings.Hint | Enter the url of the web site | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Enter the url of the web site" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].LinkFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.SiteUrl.Value | | + And I hit "Save" + Then I should see "Url is required for Site Url." \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature.cs new file mode 100644 index 000000000..ed078adad --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Link.feature.cs @@ -0,0 +1,213 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Link Field")] + public partial class LinkFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Link.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Link Field", " In order to add Link content to my types\r\nAs an administrator\r\n I want to crea" + + "te, edit and publish Link fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using Link fields")] + public virtual void CreatingAndUsingLinkFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Link fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Site Url"}); + table2.AddRow(new string[] { + "Name", + "SiteUrl"}); + table2.AddRow(new string[] { + "FieldTypeName", + "LinkField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Site Url\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 36 + testRunner.Then("I should see \"Site Url\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Event.SiteUrl.Value", + "http://www.orchardproject.net"}); +#line 37 + testRunner.When("I fill in", ((string)(null)), table3, "When "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Event.SiteUrl.Text", + "Orchard"}); +#line 40 + testRunner.And("I fill in", ((string)(null)), table4, "And "); +#line 43 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 44 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 45 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 46 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 47 + testRunner.Then("I should see \"Site Url:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 48 + testRunner.And("I should see \"Orchard\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 51 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].LinkFieldSettings.Hint", + "Enter the url of the web site"}); +#line 52 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 55 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 56 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 57 + testRunner.Then("I should see \"Enter the url of the web site\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 60 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Fields[0].LinkFieldSettings.Required", + "true"}); +#line 61 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 64 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 65 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Event.SiteUrl.Value", + ""}); +#line 66 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 69 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 70 + testRunner.Then("I should see \"Url is required for Site Url.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature new file mode 100644 index 000000000..98e2c3edc --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature @@ -0,0 +1,81 @@ +Feature: Media Picker Field + In order to add a media content to my types + As an administrator + I want to create, edit and publish media fields + +Scenario: Creating and using media fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a media field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | File | + | Name | File | + | FieldTypeName | MediaPickerField | + And I hit "Save" + And I am redirected + Then I should see "The \"File\" field has been added." + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "File" + When I fill in + | name | value | + | Event.File.Url | | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "File:" + And I should see "" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].MediaPickerFieldSettings.Hint | Please select a file | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Please select a file" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].MediaPickerFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.File.Url | | + And I hit "Save" + Then I should see "The field File is mandatory." + + # The value should be bound + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | ext-Fields[0].MediaPickerFieldSettings | true | + | Fields[0].MediaPickerFieldSettings.AllowedExtensions | jpg | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.File.Url | ~/Media/Default/images/Image.png | + And I hit "Save" + Then I should see "The field File must be have one of these extensions: jpg" \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature.cs new file mode 100644 index 000000000..18be4d8eb --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Media.feature.cs @@ -0,0 +1,235 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Media Picker Field")] + public partial class MediaPickerFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Media.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Media Picker Field", " In order to add a media content to my types\r\nAs an administrator\r\n I want to c" + + "reate, edit and publish media fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using media fields")] + public virtual void CreatingAndUsingMediaFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using media fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "File"}); + table2.AddRow(new string[] { + "Name", + "File"}); + table2.AddRow(new string[] { + "FieldTypeName", + "MediaPickerField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"File\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 36 + testRunner.Then("I should see \"File\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Event.File.Url", + ""}); +#line 37 + testRunner.When("I fill in", ((string)(null)), table3, "When "); +#line 40 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 41 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 42 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 43 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 44 + testRunner.Then("I should see \"File:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 45 + testRunner.And("I should see \"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 48 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Fields[0].MediaPickerFieldSettings.Hint", + "Please select a file"}); +#line 49 + testRunner.And("I fill in", ((string)(null)), table4, "And "); +#line 52 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 53 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 54 + testRunner.Then("I should see \"Please select a file\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 57 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].MediaPickerFieldSettings.Required", + "true"}); +#line 58 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 61 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 62 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Event.File.Url", + ""}); +#line 63 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 66 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 67 + testRunner.Then("I should see \"The field File is mandatory.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 70 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "ext-Fields[0].MediaPickerFieldSettings", + "true"}); + table7.AddRow(new string[] { + "Fields[0].MediaPickerFieldSettings.AllowedExtensions", + "jpg"}); +#line 71 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 75 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 76 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Event.File.Url", + "~/Media/Default/images/Image.png"}); +#line 77 + testRunner.And("I fill in", ((string)(null)), table8, "And "); +#line 80 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 81 + testRunner.Then("I should see \"The field File must be have one of these extensions: jpg\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature new file mode 100644 index 000000000..3cd906f8a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature @@ -0,0 +1,99 @@ +Feature: Numeric Field + In order to add numeric content to my types + As an administrator + I want to create, edit and publish numeric fields + +Scenario: Creating and using numeric fields + + # Creating an Event content type + Given I have installed Orchard + And I have installed "Orchard.Fields" + When I go to "Admin/ContentTypes" + Then I should see "]*>.*?Create new type" + When I go to "Admin/ContentTypes/Create" + And I fill in + | name | value | + | DisplayName | Event | + | Name | Event | + And I hit "Create" + And I go to "Admin/ContentTypes/" + Then I should see "Event" + + # Adding a numeric field + When I go to "Admin/ContentTypes/Edit/Event" + And I follow "Add Field" + And I fill in + | name | value | + | DisplayName | Guests | + | Name | Guests | + | FieldTypeName | NumericField | + And I hit "Save" + And I am redirected + Then I should see "The \"Guests\" field has been added." + + # Creating an Event content item + When I go to "Admin/Contents/Create/Event" + Then I should see "Guests" + When I fill in + | name | value | + | Event.Guests.Value | 3 | + And I hit "Save" + And I am redirected + Then I should see "Your Event has been created." + When I go to "Admin/Contents/List" + Then I should see "Guests:" + And I should see "3" + + # The hint should be displayed + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].NumericFieldSettings.Hint | Please enter a number | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "Please enter a number" + + # The value should be required + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].NumericFieldSettings.Required | true | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.Guests.Value | | + And I hit "Save" + Then I should see "The field Guests is mandatory." + + # The value should be bound + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].NumericFieldSettings.Minimum | -10 | + | Fields[0].NumericFieldSettings.Maximum | 100 | + And I hit "Save" + And I go to "Admin/Contents/Create/Event" + Then I should see "min=\"-10\"" + And I should see "max=\"100\"" + When I fill in + | name | value | + | Event.Guests.Value | -20 | + And I hit "Save" + Then I should see "The value must be greater than -10" + When I go to "Admin/Contents/Create/Event" + And I fill in + | name | value | + | Event.Guests.Value | 101 | + And I hit "Save" + Then I should see "The value must be less than 100" + + # Settings should be validated + When I go to "Admin/ContentTypes/Edit/Event" + And I fill in + | name | value | + | Fields[0].NumericFieldSettings.Minimum | a | + | Fields[0].NumericFieldSettings.Maximum | b | + And I hit "Save" + Then I should see "The value 'a' is not valid for Minimum." + And I should see "The value 'b' is not valid for Maximum." \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature.cs new file mode 100644 index 000000000..2430a8bb0 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Numeric.feature.cs @@ -0,0 +1,274 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.9.0.77 +// SpecFlow Generator Version:1.9.0.0 +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace Orchard.Fields.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Numeric Field")] + public partial class NumericFieldFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Numeric.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Numeric Field", " In order to add numeric content to my types\r\nAs an administrator\r\n I want to c" + + "reate, edit and publish numeric fields", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating and using numeric fields")] + public virtual void CreatingAndUsingNumericFields() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using numeric fields", ((string[])(null))); +#line 6 +this.ScenarioSetup(scenarioInfo); +#line 9 + testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 10 + testRunner.And("I have installed \"Orchard.Fields\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 11 + testRunner.When("I go to \"Admin/ContentTypes\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 12 + testRunner.Then("I should see \"]*>.*?Create new type\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 13 + testRunner.When("I go to \"Admin/ContentTypes/Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table1.AddRow(new string[] { + "DisplayName", + "Event"}); + table1.AddRow(new string[] { + "Name", + "Event"}); +#line 14 + testRunner.And("I fill in", ((string)(null)), table1, "And "); +#line 18 + testRunner.And("I hit \"Create\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.And("I go to \"Admin/ContentTypes/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 20 + testRunner.Then("I should see \"Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 23 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 24 + testRunner.And("I follow \"Add Field\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table2.AddRow(new string[] { + "DisplayName", + "Guests"}); + table2.AddRow(new string[] { + "Name", + "Guests"}); + table2.AddRow(new string[] { + "FieldTypeName", + "NumericField"}); +#line 25 + testRunner.And("I fill in", ((string)(null)), table2, "And "); +#line 30 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 32 + testRunner.Then("I should see \"The \\\"Guests\\\" field has been added.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 35 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 36 + testRunner.Then("I should see \"Guests\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table3.AddRow(new string[] { + "Event.Guests.Value", + "3"}); +#line 37 + testRunner.When("I fill in", ((string)(null)), table3, "When "); +#line 40 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 41 + testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 42 + testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 43 + testRunner.When("I go to \"Admin/Contents/List\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 44 + testRunner.Then("I should see \"Guests:\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 45 + testRunner.And("I should see \"3\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 48 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table4.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Hint", + "Please enter a number"}); +#line 49 + testRunner.And("I fill in", ((string)(null)), table4, "And "); +#line 52 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 53 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 54 + testRunner.Then("I should see \"Please enter a number\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 57 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table5.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Required", + "true"}); +#line 58 + testRunner.And("I fill in", ((string)(null)), table5, "And "); +#line 61 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 62 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table6 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table6.AddRow(new string[] { + "Event.Guests.Value", + ""}); +#line 63 + testRunner.And("I fill in", ((string)(null)), table6, "And "); +#line 66 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 67 + testRunner.Then("I should see \"The field Guests is mandatory.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 70 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table7.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Minimum", + "-10"}); + table7.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Maximum", + "100"}); +#line 71 + testRunner.And("I fill in", ((string)(null)), table7, "And "); +#line 75 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 76 + testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 77 + testRunner.Then("I should see \"min=\\\"-10\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 78 + testRunner.And("I should see \"max=\\\"100\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + TechTalk.SpecFlow.Table table8 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table8.AddRow(new string[] { + "Event.Guests.Value", + "-20"}); +#line 79 + testRunner.When("I fill in", ((string)(null)), table8, "When "); +#line 82 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 83 + testRunner.Then("I should see \"The value must be greater than -10\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 84 + testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table9 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table9.AddRow(new string[] { + "Event.Guests.Value", + "101"}); +#line 85 + testRunner.And("I fill in", ((string)(null)), table9, "And "); +#line 88 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 89 + testRunner.Then("I should see \"The value must be less than 100\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 92 + testRunner.When("I go to \"Admin/ContentTypes/Edit/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden + TechTalk.SpecFlow.Table table10 = new TechTalk.SpecFlow.Table(new string[] { + "name", + "value"}); + table10.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Minimum", + "a"}); + table10.AddRow(new string[] { + "Fields[0].NumericFieldSettings.Maximum", + "b"}); +#line 93 + testRunner.And("I fill in", ((string)(null)), table10, "And "); +#line 97 + testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 98 + testRunner.Then("I should see \"The value 'a' is not valid for Minimum.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 99 + testRunner.And("I should see \"The value 'b' is not valid for Maximum.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Orchard.Fields.Specs.csproj b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Orchard.Fields.Specs.csproj new file mode 100644 index 000000000..0ea38b9a0 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Orchard.Fields.Specs.csproj @@ -0,0 +1,132 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {34BE9011-A5A9-49DD-9E53-C3D5CA7D7CE3} + Library + Properties + Orchard.Fields.Specs + Orchard.Fields.Specs + v4.0 + 512 + + + true + full + false + bin + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin + TRACE + prompt + 4 + + + + ..\..\..\..\..\lib\nunit\nunit.framework.dll + + + + + + + + + + ..\..\..\..\..\lib\specflow\TechTalk.SpecFlow.dll + + + + + True + True + Boolean.feature + + + True + True + DateTime.feature + + + True + True + Enumeration.feature + + + True + True + Input.feature + + + True + True + Link.feature + + + True + True + Media.feature + + + True + True + Numeric.feature + + + + + + {7354DF37-934B-46CF-A13C-455D5F5F5413} + Orchard.Specs + + + + + + SpecFlowSingleFileGenerator + Boolean.feature.cs + + + + SpecFlowSingleFileGenerator + DateTime.feature.cs + + + SpecFlowSingleFileGenerator + Enumeration.feature.cs + + + SpecFlowSingleFileGenerator + Input.feature.cs + + + SpecFlowSingleFileGenerator + Link.feature.cs + + + SpecFlowSingleFileGenerator + Media.feature.cs + + + SpecFlowSingleFileGenerator + Numeric.feature.cs + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Specs/Properties/AssemblyInfo.cs b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..21f7737ee --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Specs/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Orchard.Fields.Specs")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Orchard")] +[assembly: AssemblyCopyright("Outercurve Foundation 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.4.1")] +[assembly: AssemblyFileVersion("1.4.1")] diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Styles/Images/move.gif b/src/Orchard.Web/Modules/Orchard.Fields/Styles/Images/move.gif new file mode 100644 index 000000000..b6b7e5158 Binary files /dev/null and b/src/Orchard.Web/Modules/Orchard.Fields/Styles/Images/move.gif differ diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Styles/Web.config b/src/Orchard.Web/Modules/Orchard.Fields/Styles/Web.config new file mode 100644 index 000000000..178ff35ba --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Styles/Web.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Styles/content-picker-admin.css b/src/Orchard.Web/Modules/Orchard.Fields/Styles/content-picker-admin.css new file mode 100644 index 000000000..9b3e59c0f --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Styles/content-picker-admin.css @@ -0,0 +1,12 @@ +table.content-picker tr td:nth-child(1) { + background: url(images/move.gif) no-repeat 12px 14px; + cursor: move; +} + +.content-picker-message { + display: none; +} + +.ui-sortable-helper .content-picker-remove { + display: none; +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Styles/datetime.css b/src/Orchard.Web/Modules/Orchard.Fields/Styles/datetime.css new file mode 100644 index 000000000..67f6e29a8 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Styles/datetime.css @@ -0,0 +1,14 @@ +html.dyn label.forpicker { + display:none; +} +/* todo: (heskew) let themes take care of this */ +html.dyn input.hinted { + color:#ccc; + font-style:italic; +} +.date input{ + width:10em; +} +.time input { + width:7em; +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Tokens/FieldTokens.cs b/src/Orchard.Web/Modules/Orchard.Fields/Tokens/FieldTokens.cs new file mode 100644 index 000000000..dd6b6ed25 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Tokens/FieldTokens.cs @@ -0,0 +1,71 @@ +using System; +using Orchard.Events; +using Orchard.Fields.Fields; +using Orchard.Localization; + +namespace Orchard.Fields.Tokens { + public interface ITokenProvider : IEventHandler { + void Describe(dynamic context); + void Evaluate(dynamic context); + } + + public class FieldTokens : ITokenProvider { + + public Localizer T { get; set; } + + public void Describe(dynamic context) { + + context.For("LinkField", T("Link Field"), T("Tokens for Link Fields")) + .Token("Text", T("Text"), T("The text of the link.")) + .Token("Url", T("Url"), T("The url of the link.")) + .Token("Target", T("Target"), T("The target of the link.")) + ; + + context.For("DateTimeField", T("Date Time Field"), T("Tokens for Date Time Fields")) + .Token("Date", T("Date"), T("The date only.")) + .Token("Time", T("Time"), T("The time only.")) + ; + + context.For("MediaPickerField", T("Media Picker Field"), T("Tokens for Media Picker Fields")) + .Token("Url", T("Url"), T("The url of the media.")) + .Token("AlternateText", T("Alternate Text"), T("The alternate text of the media.")) + .Token("Class", T("Class"), T("The class of the media.")) + .Token("Style", T("Style"), T("The style of the media.")) + .Token("Alignment", T("Alignment"), T("The alignment of the media.")) + .Token("Width", T("Width"), T("The width of the media.")) + .Token("Height", T("Height"), T("The height of the media.")) + ; + } + + public void Evaluate(dynamic context) { + context.For("LinkField") + .Token("Text", (Func)(field => field.Text)) + .Chain("Text", "Text", (Func)(field => field.Text)) + .Token("Url", (Func)(field => field.Value)) + .Chain("Url", "Url", (Func)(field => field.Value)) + .Token("Target", (Func)(field => field.Target)) + ; + + context.For("DateTimeField") + .Token("Date", (Func)(field => field.DateTime)) + .Chain("Date", "Date", (Func)(field => field.DateTime)) + ; + + context.For("MediaPickerField") + .Token("Url", (Func)(field => field.Url)) + .Chain("Url", "Url", (Func)(field => field.Url)) + .Token("AlternateText", (Func)(field => field.AlternateText)) + .Token("Class", (Func)(field => field.Class)) + .Token("Style", (Func)(field => field.Style)) + .Token("Alignment", (Func)(field => field.Alignment)) + .Token("Width", (Func)(field => field.Width)) + .Token("Height", (Func)(field => field.Height)) + ; + + context.For("DateTimeField") + .Token("Date", (Func)(field => field.DateTime)) + .Chain("Date", "Date", (Func)(field => field.DateTime)) + ; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/BooleanFieldViewModel.cs b/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/BooleanFieldViewModel.cs new file mode 100644 index 000000000..50d719687 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/BooleanFieldViewModel.cs @@ -0,0 +1,13 @@ +namespace Orchard.Fields.ViewModels { + + public class BooleanFieldViewModel { + + public string Name { get; set; } + + public bool? Value { get; set; } + + public string NotSetLabel { get; set; } + public string OnLabel { get; set; } + public string OffLabel { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/DateTimeFieldViewModel.cs b/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/DateTimeFieldViewModel.cs new file mode 100644 index 000000000..aba0ac0ae --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/ViewModels/DateTimeFieldViewModel.cs @@ -0,0 +1,16 @@ +namespace Orchard.Fields.ViewModels { + + public class DateTimeFieldViewModel { + + public string Name { get; set; } + + public string Date { get; set; } + public string Time { get; set; } + + public bool ShowDate { get; set; } + public bool ShowTime { get; set; } + + public string Hint { get; set; } + public bool Required { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/BooleanFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/BooleanFieldSettings.cshtml new file mode 100644 index 000000000..f8e38f405 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/BooleanFieldSettings.cshtml @@ -0,0 +1,59 @@ +@model Orchard.Fields.Settings.BooleanFieldSettings +@using Orchard.Fields.Settings; + +
+
+ @Html.CheckBoxFor(m => m.Optional) + @T("Check to allow the user to enter a neutral value, like 'Maybe'.") +
+
+
+
+ + @Html.TextBoxFor(m => m.NotSetLabel, new { @class = "text" }) + @Html.ValidationMessageFor(m => m.NotSetLabel) + @T("The text displayed when the field is not selected.") +
+
+
+
+ + @Html.TextBoxFor(m => m.OnLabel, new { @class = "text"}) + @Html.ValidationMessageFor(m => m.OnLabel) + @T("The text displayed when the field is selected.") +
+
+
+ +
+ @Html.TextBoxFor(m => m.OffLabel, new { @class = "text" }) + @Html.ValidationMessageFor(m => m.OffLabel) + @T("The text displayed when the field is unselected.") +
+
+
+ + + @T("When Checkbox is selected, the label for 'on' will be used.") +
+
+ + + @T("When Checkbox is selected, the label for 'on' will be used.") +
+
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" } ) + @T("The help text is written under the field when the user is selecting a value.") + @Html.ValidationMessageFor(m => m.Hint) +
+
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/DateTimeFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/DateTimeFieldSettings.cshtml new file mode 100644 index 000000000..35bbca0de --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/DateTimeFieldSettings.cshtml @@ -0,0 +1,29 @@ +@model Orchard.Fields.Settings.DateTimeFieldSettings +@using Orchard.Fields.Settings; + +
+ + + + @Html.ValidationMessageFor(m => m.Display) +
+ +
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Check if the field is required.") +
+
+ +
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" }) + @T("The help text is written under the field when the user is entering a value.") + @Html.ValidationMessageFor(m => m.Hint) +
+
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/EnumerationFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/EnumerationFieldSettings.cshtml new file mode 100644 index 000000000..bd6f3b599 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/EnumerationFieldSettings.cshtml @@ -0,0 +1,30 @@ +@model Orchard.Fields.Settings.EnumerationFieldSettings +@using Orchard.Fields.Settings; +
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Check to ensure the user is providing an option for this field.") +
+
+
+ +
+ @Html.TextAreaFor(m => m.Options, new { @class = "textMedium", rows = "5" }) + @Html.ValidationMessageFor(m => m.Options) + @T("Enter an option per line.") +
+ + + +
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" } ) + @T("The help text is written under the field when users are selecting an option.") + @Html.ValidationMessageFor(m => m.Hint) +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/InputFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/InputFieldSettings.cshtml new file mode 100644 index 000000000..b10858f7a --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/InputFieldSettings.cshtml @@ -0,0 +1,79 @@ +@model Orchard.Fields.Settings.InputFieldSettings +@using Orchard.Fields.Settings; + +
+
+ + + @T("Defines what format should be applied to the text.") +
+
+ + @Html.TextBoxFor(m => m.Pattern, new { @class = "textMedium" }) + @Html.ValidationMessageFor(m => m.Pattern) + @T("Declaring what pattern should be used for validating a field’s value, in the form of a regular expression. (optional)") +
+
+
+
+ + @Html.TextBoxFor(m => m.Title, new { @class = "text"}) + @Html.ValidationMessageFor(m => m.Title) + @T("The title attribute of the field. (optional)") +
+
+
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Check if the field is required.") +
+
+
+
+ @Html.CheckBoxFor(m => m.AutoFocus) + @T("Whether focus should be set to this field as soon as it has loaded.") +
+
+
+
+ @Html.CheckBoxFor(m => m.AutoComplete) + @T("An option to turn off automatic form completion of values. Leave unchecked to disable automatic completion.") +
+
+
+
+ + @Html.TextBoxFor(m => m.Placeholder, new { @class = "text" }) + @Html.ValidationMessageFor(m => m.Placeholder) + @T("A hint to display when the input is empty. (optional)") +
+
+
+
+ + @Html.TextBoxFor(m => m.EditorCssClass, new { @class = "text" }) + @Html.ValidationMessageFor(m => m.EditorCssClass) + @T("The css class to use for the editor. (optional)") +
+
+
+
+ + @Html.TextBoxFor(m => m.MaxLength, new { @class = "small text" }) + @Html.ValidationMessageFor(m => m.MaxLength) + @T("The maximum number of chars allowed. (optional)") +
+
+
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" }) + @T("The help text is written under the field when the user is entering a value.") + @Html.ValidationMessageFor(m => m.Hint) +
+
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/LinkFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/LinkFieldSettings.cshtml new file mode 100644 index 000000000..e3439eafe --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/LinkFieldSettings.cshtml @@ -0,0 +1,46 @@ +@model Orchard.Fields.Settings.LinkFieldSettings +@using Orchard.Fields.Settings; + +
+
+ + +
+
+
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Whether the url is required.") +
+
+
+
+ + + @T("Define how the title field should behave in the editor.") +
+
+ @Html.TextBoxFor(m => m.StaticText, new { @class = "textMedium" }) + @T("The title to display for the link") + @Html.ValidationMessageFor(m => m.Hint) +
+
+
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" } ) + @T("The help text is written under the field.") + @Html.ValidationMessageFor(m => m.Hint) +
+
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/MediaPickerFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/MediaPickerFieldSettings.cshtml new file mode 100644 index 000000000..8a914633c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/MediaPickerFieldSettings.cshtml @@ -0,0 +1,48 @@ +@model Orchard.Fields.Settings.MediaPickerFieldSettings + +
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Check to ensure the user is providing a valid media for this field.") +
+
+
+
+ checked="checked" } /> + +
+
+
+ @Html.TextBoxFor(m => m.AllowedExtensions, new { @class = "textMedium" }) + @T("You can define a set of extensions the user will be able to pick, separated by spaces, e.g. jpg png gif") + @T("Leave it empty if you don't want to apply any restriction.") +
+
+
+
+
+ checked="checked" } /> + +
+
+ @T("Custom parameters can be used if your own views.") +
+ + @Html.TextBoxFor(m => m.Custom1, new { @class = "textMedium" }) +
+
+ + @Html.TextBoxFor(m => m.Custom2, new { @class = "textMedium" }) +
+
+ + @Html.TextBoxFor(m => m.Custom3, new { @class = "textMedium" }) +
+
+
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" } ) + @T("The help text is written under the field when authors are selecting a media.") + @Html.ValidationMessageFor(m => m.Hint) +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/NumericFieldSettings.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/NumericFieldSettings.cshtml new file mode 100644 index 000000000..4fedcc3e5 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/DefinitionTemplates/NumericFieldSettings.cshtml @@ -0,0 +1,41 @@ +@model Orchard.Fields.Settings.NumericFieldSettings +@using Orchard.Fields.Settings; + +
+
+ @Html.CheckBoxFor(m => m.Required) + @T("Check if the field is required.") +
+
+
+
+ + @Html.TextBoxFor(m => m.Scale, new { @class = "text-small" }) + @Html.ValidationMessageFor(m => m.Scale) + @T("The number of digits to the right of the decimal. Put 0 for integers.") +
+
+
+
+ + @Html.TextBoxFor(m => m.Minimum, new { @class = "text-small" }) + @Html.ValidationMessageFor(m => m.Minimum) + @T("The minimum value allowed. (optional)") +
+
+
+
+ + @Html.TextBoxFor(m => m.Maximum, new { @class = "text-small" }) + @Html.ValidationMessageFor(m => m.Maximum) + @T("The maximum value allowed. (optional)") +
+
+
+
+ + @Html.TextAreaFor(m => m.Hint, new { @class = "textMedium", rows = "5" } ) + @T("The help text is written under the field when the user is entering a value.") + @Html.ValidationMessageFor(m => m.Hint) +
+
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Boolean.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Boolean.Edit.cshtml new file mode 100644 index 000000000..5d213757e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Boolean.Edit.cshtml @@ -0,0 +1,44 @@ +@model Orchard.Fields.Fields.BooleanField +@using Orchard.Utility.Extensions; +@using Orchard.Fields.Settings; +@{ + var settings = Model.PartFieldDefinition.Settings.GetModel(); +} +
+ + @switch (settings.SelectionMode) { + case SelectionMode.Checkbox: + checked="checked" } /> + + break; + case SelectionMode.Radiobutton: + if (settings.Optional) { +
+ checked="checked" } /> + +
+ } +
+ checked="checked" } /> + +
+
+ checked="checked" } /> + +
+ break; + case SelectionMode.Dropdown: + + break; + default: + break; + } + @Html.ValidationMessageFor(m => m.Value) + @settings.Hint +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/DateTime.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/DateTime.Edit.cshtml new file mode 100644 index 000000000..4bf401e7d --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/DateTime.Edit.cshtml @@ -0,0 +1,46 @@ +@model Orchard.Fields.ViewModels.DateTimeFieldViewModel + +@{ + Style.Include("datetime.css"); + + Script.Require("jQuery").AtFoot(); + Script.Require("jQueryUI_Core").AtFoot(); + Script.Require("jQueryUI_Widget").AtFoot(); + Style.Require("jQueryUI_Orchard").AtFoot(); + Script.Include("hint.js").AtFoot(); +} + +
+ + + @if ( Model.ShowDate ) { + + @Html.EditorFor(m => m.Date) + } + + @if ( Model.ShowTime ) { + + @Html.EditorFor(m => m.Time) + } + @if(Model.ShowDate) { @Html.ValidationMessageFor(m=>m.Date) } @if(Model.ShowTime) { @Html.ValidationMessageFor(m=>m.Time) } + + @Model.Hint +
+ +@using(Script.Foot()) { + + @* generates the localization script *@ + if (Model.ShowDate) { @Display.DatePickerLocalization() } + if (Model.ShowTime) { @Display.TimePickerLocalization() } + + +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Enumeration.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Enumeration.Edit.cshtml new file mode 100644 index 000000000..a4aab0b47 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Enumeration.Edit.cshtml @@ -0,0 +1,47 @@ +@model Orchard.Fields.Fields.EnumerationField +@using Orchard.Fields.Settings; +@{ + var settings = Model.PartFieldDefinition.Settings.GetModel(); + string[] options = (!String.IsNullOrWhiteSpace(settings.Options)) ? settings.Options.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None) : new string[] { T("Select an option").ToString() }; +} +
+ + @switch (settings.ListMode) { + case ListMode.Dropdown: + @Html.DropDownListFor(m => m.Value, new SelectList(options, Model.Value)) + break; + + case ListMode.Radiobutton: + foreach (var option in options) { + if (string.IsNullOrWhiteSpace(option)) { + + } + else { + + } + } + break; + + case ListMode.Listbox: + + @Html.ListBoxFor(m => m.SelectedValues, new MultiSelectList(options, Model.SelectedValues)) + break; + + case ListMode.Checkbox: + int index = 0; + + foreach (var option in options) { + index++; + if (!string.IsNullOrWhiteSpace(option)) { +
+ + +
+ } + } + break; + } + + @Html.ValidationMessageFor(m => m.SelectedValues) + @settings.Hint +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Input.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Input.Edit.cshtml new file mode 100644 index 000000000..5f0624dae --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Input.Edit.cshtml @@ -0,0 +1,12 @@ +@model Orchard.Fields.Fields.InputField +@using Orchard.Utility.Extensions; +@using Orchard.Fields.Settings; +@{ + var settings = Model.PartFieldDefinition.Settings.GetModel(); +} +
+ + title="@settings.Title"} value="@Model.Value"@if(settings.Required) { required="required" }@if(settings.AutoFocus) { autofocus="autofocus" }@if(settings.AutoComplete) { autocomplete="on" }@if(!string.IsNullOrWhiteSpace(settings.Placeholder)) { placeholder="@settings.Placeholder"}@if(!string.IsNullOrEmpty(settings.Pattern)) { pattern="@settings.Pattern"}@if(!string.IsNullOrEmpty(settings.EditorCssClass)) { class="@settings.EditorCssClass"} else { class="textMedium"} @if(settings.MaxLength > 1) { maxlength="@settings.MaxLength.ToString()"} /> + @Html.ValidationMessageFor(m => m.Value) + @settings.Hint +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Link.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Link.Edit.cshtml new file mode 100644 index 000000000..522a8f6c3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Link.Edit.cshtml @@ -0,0 +1,51 @@ +@model Orchard.Fields.Fields.LinkField +@using Orchard.Fields.Settings; +@{ + var settings = Model.PartFieldDefinition.Settings.GetModel(); + string target = string.Empty; + switch (settings.TargetMode) { + case TargetMode.NewWindow: + target = "_blank"; + break; + case TargetMode.Parent: + target = "_parent"; + break; + case TargetMode.Top: + target = "_top"; + break; + } +} +
+ + @settings.Hint + +
+ +
+
+ @Html.TextBoxFor(m => m.Value, new { @class = "large text" }) + @T("A valid url, i.e. http://orchardproject.net, /content/file.pdf, ...") +
+ @if (settings.LinkTextMode == LinkTextMode.Optional || settings.LinkTextMode == LinkTextMode.Required) { +
+ +
+
+ @Html.TextBoxFor(m => m.Text, new {@class = "textMedium"}) + @T("The text of the link. If left empty, the url will be used instead.") +
+ } + + @if (settings.TargetMode == TargetMode.UserChoice) { +
+ +
+
+ @Html.TextBoxFor(m => m.Target, new { @class = "text"}) + @T("A valid HTML target attribute value. e.g., _blank, _parent, _top, or an anchor. ") +
+ } + else { + @Html.Hidden(Html.FieldNameFor(m => m.Target), target) + } +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml new file mode 100644 index 000000000..5dc9d3f53 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml @@ -0,0 +1,79 @@ +@model Orchard.Fields.Fields.MediaPickerField +@using Orchard.Utility.Extensions; +@using Orchard.Fields.Settings; + +@{ + Script.Require("jQuery").AtFoot(); + var settings = Model.PartFieldDefinition.Settings.GetModel(); +} + +
+ + @Html.TextBoxFor(m => m.Url, new { @class = "textMedium", @readonly = "readonly" }) @T("Browse") + + @if(!settings.Required) { + @T("Clear") + } + + @settings.Hint + + @Html.HiddenFor(m => m.AlternateText) + @Html.HiddenFor(m => m.Class) + @Html.HiddenFor(m => m.Style) + @Html.HiddenFor(m => m.Alignment) + @Html.HiddenFor(m => m.Alignment) + @Html.HiddenFor(m => m.Width) + @Html.HiddenFor(m => m.Height) + +
+ +@using (Script.Foot()) +{ + +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Numeric.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Numeric.Edit.cshtml new file mode 100644 index 000000000..8ec89698e --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/Numeric.Edit.cshtml @@ -0,0 +1,12 @@ +@model Orchard.Fields.Fields.NumericField +@using System.Globalization +@using Orchard.Fields.Settings; +@{ + var settings = Model.PartFieldDefinition.Settings.GetModel(); +} +
+ + @Html.TextBoxFor(m => m.Value, new { @class = "text-small", type = "number", min = (settings.Minimum.HasValue) ? settings.Minimum.Value : 0, max = (settings.Maximum.HasValue) ? settings.Maximum.Value : 1000000, step = Math.Pow(10, 0 - settings.Scale).ToString(CultureInfo.InvariantCulture) }) + @Html.ValidationMessageFor(m => m.Value) + @settings.Hint +
diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Boolean.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Boolean.cshtml new file mode 100644 index 000000000..93ca75c1b --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Boolean.cshtml @@ -0,0 +1,20 @@ +@using Orchard.Utility.Extensions +@{ + string valueToDisplay; + bool? booleanValue = Model.ContentField.Value; + if (booleanValue.HasValue) { + valueToDisplay = booleanValue.Value + ? T(Model.Settings.OnLabel).ToString() + : T(Model.Settings.OffLabel).ToString(); + } + else { + valueToDisplay = T(Model.Settings.NotSetLabel).ToString(); + } + if (!string.IsNullOrEmpty(valueToDisplay)) { + string name = Model.ContentField.DisplayName; +

+ @name: + @valueToDisplay +

+ } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/DateTime.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/DateTime.cshtml new file mode 100644 index 000000000..693e1efcf --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/DateTime.cshtml @@ -0,0 +1,9 @@ +@using Orchard.Utility.Extensions; + +@{ + string name = Model.ContentField.DisplayName; +} +

+ @name.CamelFriendly(): + @if (Model.Model.ShowDate) { @Model.Model.Date } @if (Model.Model.ShowTime) { @Model.Model.Time } +

diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Enumeration.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Enumeration.cshtml new file mode 100644 index 000000000..0e4ab11fd --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Enumeration.cshtml @@ -0,0 +1,20 @@ +@using Orchard.Utility.Extensions; +@using System.Linq; +@{ + string valueToDisplay = string.Empty; + string[] selectedValues = Model.ContentField.SelectedValues; + if (selectedValues != null) { + string valueFormat = T("{0}").ToString(); + string[] translatedValues = selectedValues.Select(v => string.Format(valueFormat, T(v).Text)).ToArray(); + string separator = T(", ").ToString(); + valueToDisplay = string.Join(separator, translatedValues); + } + if (!string.IsNullOrEmpty(valueToDisplay)) { + string name = Model.ContentField.DisplayName; +

+ @name: + @Html.Raw(valueToDisplay) +

+ + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Input.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Input.cshtml new file mode 100644 index 000000000..9d38555bc --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Input.cshtml @@ -0,0 +1,9 @@ +@using Orchard.Fields.Settings; +@using Orchard.Utility.Extensions; +@{ + string value = (string)Model.ContentField.Value; + if (!string.IsNullOrEmpty(value)) { + string name = Model.ContentField.DisplayName; +

@T(name): @value

+ } +} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Link.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Link.cshtml new file mode 100644 index 000000000..531d13cfc --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Link.cshtml @@ -0,0 +1,24 @@ +@using Orchard.Fields.Settings +@using Orchard.Utility.Extensions; +@{ + string name = Model.ContentField.DisplayName; + LinkFieldSettings settings = Model.ContentField.PartFieldDefinition.Settings.GetModel(); + string text = Model.ContentField.Text; + switch(settings.LinkTextMode) { + case LinkTextMode.Static: + text = settings.StaticText; + break; + case LinkTextMode.Url: + text = Model.ContentField.Value; + break; + case LinkTextMode.Optional: + if (String.IsNullOrWhiteSpace(text)) { + text = Model.ContentField.Value; + } + break; + } +} + diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/MediaPicker.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/MediaPicker.cshtml new file mode 100644 index 000000000..53db581da --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/MediaPicker.cshtml @@ -0,0 +1,39 @@ +@using Orchard.Utility.Extensions; +@using Orchard.Media.Helpers; + +@{ + string name = Model.ContentField.DisplayName; +} +

+ @if (Html.IsPicture((string)Model.ContentField.Url)) { + class="@Model.ContentField.Class" + }@if (!String.IsNullOrWhiteSpace(Model.ContentField.Style)) { + style="@Model.ContentField.Style" + }@if (!String.IsNullOrWhiteSpace(Model.ContentField.AlternateText)) { + alt="@Model.ContentField.AlternateText" + }@if (!String.IsNullOrWhiteSpace(Model.ContentField.Alignment)) { + align="@Model.ContentField.Alignment" + }@if (Model.ContentField.Width > 0) { + width="@Model.ContentField.Width" + }@if (Model.ContentField.Height > 0) { + height="@Model.ContentField.Height" + }/> + } + else if (!String.IsNullOrWhiteSpace(Model.ContentField.Url)) { + @name + } +

+ +@* Other available properties *@ +@* + Alternate Text: @Model.ContentField.AlternateText + Class: @Model.ContentField.Class + Style: @Model.ContentField.Style + Alignment @Model.ContentField.Alignment + Width: @Model.ContentField.Width + Height: @Model.ContentField.Height + + You can also display an image using this example, and add the attributes you need: + +*@ \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Numeric.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Numeric.cshtml new file mode 100644 index 000000000..6958fbf3d --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Fields/Numeric.cshtml @@ -0,0 +1,12 @@ +@using Orchard.Utility.Extensions +@{ + decimal? number = Model.ContentField.Value; + string name = Model.ContentField.DisplayName; +} + +@if (number.HasValue) { +

+ @name: + @(number.Value) +

+} diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/Web.config b/src/Orchard.Web/Modules/Orchard.Fields/Views/Web.config new file mode 100644 index 000000000..b7d215131 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/Web.config @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Web.config b/src/Orchard.Web/Modules/Orchard.Fields/Web.config new file mode 100644 index 000000000..67ab6afeb --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Fields/Web.config @@ -0,0 +1,41 @@ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +