mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 09:42:29 +08:00
Merge pull request #6616 from jtkech/text-field
Removing required attribute for default value on TextField
This commit is contained in:
@@ -205,6 +205,11 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Text.feature.cs">
|
||||
<DependentUpon>Text.feature</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Input.feature.cs">
|
||||
<DependentUpon>Input.feature</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -371,6 +376,10 @@
|
||||
<None Include="Hosting\Orchard.Web\Config\HostComponents.Release.config">
|
||||
<DependentUpon>HostComponents.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Text.feature">
|
||||
<Generator>SpecFlowSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Text.feature.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Input.feature">
|
||||
<Generator>SpecFlowSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Input.feature.cs</LastGenOutput>
|
||||
|
||||
126
src/Orchard.Specs/Text.feature
Normal file
126
src/Orchard.Specs/Text.feature
Normal file
@@ -0,0 +1,126 @@
|
||||
Feature: Text Field
|
||||
In order to add Text content to my types
|
||||
As an administrator
|
||||
I want to create, edit and publish Text fields
|
||||
|
||||
Scenario: Creating and using Text 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 "<a[^>]*>.*?Create new type</a>"
|
||||
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 Text field
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I follow "Add Field"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| DisplayName | Subject |
|
||||
| Name | Subject |
|
||||
| FieldTypeName | TextField |
|
||||
And I hit "Save"
|
||||
And I am redirected
|
||||
Then I should see "The \"Subject\" field has been added."
|
||||
|
||||
# The display option should be effective
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Flavor | Large |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
Then I should see "class=\"text large\""
|
||||
|
||||
# The value should be required
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Required | true |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Event.Subject.Text | |
|
||||
And I hit "Save"
|
||||
Then I should see "The field Subject is mandatory."
|
||||
|
||||
# The hint should be displayed
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Hint | Subject of the event |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
Then I should see "Subject of the event"
|
||||
|
||||
# Creating an Event content item
|
||||
When I go to "Admin/Contents/Create/Event"
|
||||
Then I should see "Subject"
|
||||
When I fill in
|
||||
| name | value |
|
||||
| Event.Subject.Text | Orchard Harvest 2013 |
|
||||
And I hit "Save"
|
||||
And I am redirected
|
||||
Then I should see "Your Event has been created."
|
||||
And I should see "Orchard Harvest 2013"
|
||||
|
||||
# If not required and no value, the default value should be used
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Required | false |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue | Orchard Harvest 2014 |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Event.Subject.Text | |
|
||||
And I hit "Save"
|
||||
And I am redirected
|
||||
Then I should see "Your Event has been created."
|
||||
And I should see "Orchard Harvest 2014"
|
||||
|
||||
# If required and no value, the default value should be used
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Required | true |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue | Orchard Harvest 2015 |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Event.Subject.Text | |
|
||||
And I hit "Save"
|
||||
And I am redirected
|
||||
Then I should see "Your Event has been created."
|
||||
And I should see "Orchard Harvest 2015"
|
||||
|
||||
# If required and no default value, the required attribute should be used
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Required | true |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue | |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
Then I should see "required=\"required\""
|
||||
|
||||
# If required and a default value is set, the required attribute should not be used
|
||||
When I go to "Admin/ContentTypes/Edit/Event"
|
||||
And I fill in
|
||||
| name | value |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.Required | true |
|
||||
| Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue | Orchard Harvest 2015 |
|
||||
And I hit "Save"
|
||||
And I go to "Admin/Contents/Create/Event"
|
||||
Then I should not see "required=\"required\""
|
||||
327
src/Orchard.Specs/Text.feature.cs
generated
Normal file
327
src/Orchard.Specs/Text.feature.cs
generated
Normal file
@@ -0,0 +1,327 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
// ------------------------------------------------------------------------------
|
||||
#region Designer generated code
|
||||
#pragma warning disable
|
||||
namespace Orchard.Specs
|
||||
{
|
||||
using TechTalk.SpecFlow;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[NUnit.Framework.TestFixtureAttribute()]
|
||||
[NUnit.Framework.DescriptionAttribute("Text Field")]
|
||||
public partial class TextFieldFeature
|
||||
{
|
||||
|
||||
private static TechTalk.SpecFlow.ITestRunner testRunner;
|
||||
|
||||
#line 1 "Text.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"), "Text Field", " In order to add Text content to my types\r\n As an administrator\r\n I want to cr" +
|
||||
"eate, edit and publish Text 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 Text fields")]
|
||||
public virtual void CreatingAndUsingTextFields()
|
||||
{
|
||||
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Creating and using Text 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 \"<a[^>]*>.*?Create new type</a>\"", ((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",
|
||||
"Subject"});
|
||||
table2.AddRow(new string[] {
|
||||
"Name",
|
||||
"Subject"});
|
||||
table2.AddRow(new string[] {
|
||||
"FieldTypeName",
|
||||
"TextField"});
|
||||
#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 \\\"Subject\\\" 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].TextFieldSettingsEventsViewModel.Settings.Flavor",
|
||||
"Large"});
|
||||
#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 \"class=\\\"text large\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 44
|
||||
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].TextFieldSettingsEventsViewModel.Settings.Required",
|
||||
"true"});
|
||||
#line 45
|
||||
testRunner.And("I fill in", ((string)(null)), table4, "And ");
|
||||
#line 48
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 49
|
||||
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table5 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
"value"});
|
||||
table5.AddRow(new string[] {
|
||||
"Event.Subject.Text",
|
||||
""});
|
||||
#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.Then("I should see \"The field Subject is mandatory.\"", ((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 table6 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
"value"});
|
||||
table6.AddRow(new string[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.Hint",
|
||||
"Subject of the event"});
|
||||
#line 58
|
||||
testRunner.And("I fill in", ((string)(null)), table6, "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 \"Subject of the event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 66
|
||||
testRunner.When("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
|
||||
#line 67
|
||||
testRunner.Then("I should see \"Subject\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line hidden
|
||||
TechTalk.SpecFlow.Table table7 = new TechTalk.SpecFlow.Table(new string[] {
|
||||
"name",
|
||||
"value"});
|
||||
table7.AddRow(new string[] {
|
||||
"Event.Subject.Text",
|
||||
"Orchard Harvest 2013"});
|
||||
#line 68
|
||||
testRunner.When("I fill in", ((string)(null)), table7, "When ");
|
||||
#line 71
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 72
|
||||
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 73
|
||||
testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 74
|
||||
testRunner.And("I should see \"Orchard Harvest 2013\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 77
|
||||
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].TextFieldSettingsEventsViewModel.Settings.Required",
|
||||
"false"});
|
||||
table8.AddRow(new string[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue",
|
||||
"Orchard Harvest 2014"});
|
||||
#line 78
|
||||
testRunner.And("I fill in", ((string)(null)), table8, "And ");
|
||||
#line 82
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 83
|
||||
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.Subject.Text",
|
||||
""});
|
||||
#line 84
|
||||
testRunner.And("I fill in", ((string)(null)), table9, "And ");
|
||||
#line 87
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 88
|
||||
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 89
|
||||
testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 90
|
||||
testRunner.And("I should see \"Orchard Harvest 2014\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 93
|
||||
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].TextFieldSettingsEventsViewModel.Settings.Required",
|
||||
"true"});
|
||||
table10.AddRow(new string[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue",
|
||||
"Orchard Harvest 2015"});
|
||||
#line 94
|
||||
testRunner.And("I fill in", ((string)(null)), table10, "And ");
|
||||
#line 98
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 99
|
||||
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.Subject.Text",
|
||||
""});
|
||||
#line 100
|
||||
testRunner.And("I fill in", ((string)(null)), table11, "And ");
|
||||
#line 103
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 104
|
||||
testRunner.And("I am redirected", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 105
|
||||
testRunner.Then("I should see \"Your Event has been created.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line 106
|
||||
testRunner.And("I should see \"Orchard Harvest 2015\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 109
|
||||
testRunner.When("I go to \"Admin/ContentTypes/Edit/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[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.Required",
|
||||
"true"});
|
||||
table12.AddRow(new string[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue",
|
||||
""});
|
||||
#line 110
|
||||
testRunner.And("I fill in", ((string)(null)), table12, "And ");
|
||||
#line 114
|
||||
testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 115
|
||||
testRunner.And("I go to \"Admin/Contents/Create/Event\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
|
||||
#line 116
|
||||
testRunner.Then("I should see \"required=\\\"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].TextFieldSettingsEventsViewModel.Settings.Required",
|
||||
"true"});
|
||||
table13.AddRow(new string[] {
|
||||
"Fields[0].TextFieldSettingsEventsViewModel.Settings.DefaultValue",
|
||||
"Orchard Harvest 2015"});
|
||||
#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 not see \"required=\\\"required\\\"\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
|
||||
#line hidden
|
||||
this.ScenarioCleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endregion
|
||||
@@ -58,28 +58,19 @@ namespace Orchard.Core.Common.Drivers {
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
|
||||
var viewModel = new TextFieldDriverViewModel {
|
||||
Field = field,
|
||||
Text = field.Value,
|
||||
Settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>(),
|
||||
ContentItem = part.ContentItem
|
||||
};
|
||||
var viewModel = new TextFieldDriverViewModel();
|
||||
|
||||
if (updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) {
|
||||
if (viewModel.Settings.Required && string.IsNullOrWhiteSpace(viewModel.Text)) {
|
||||
updater.AddModelError("Text", T("The field {0} is mandatory", T(field.DisplayName)));
|
||||
return ContentShape("Fields_Common_Text_Edit", GetDifferentiator(field, part),
|
||||
() => shapeHelper.EditorTemplate(TemplateName: "Fields.Common.Text.Edit", Model: viewModel, Prefix: GetPrefix(field, part)));
|
||||
}
|
||||
|
||||
field.Value = viewModel.Text;
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>();
|
||||
|
||||
if (String.IsNullOrEmpty(field.Value) && !String.IsNullOrEmpty(settings.DefaultValue)) {
|
||||
field.Value = viewModel.Text;
|
||||
|
||||
if (String.IsNullOrWhiteSpace(field.Value) && !String.IsNullOrWhiteSpace(settings.DefaultValue)) {
|
||||
field.Value = settings.DefaultValue;
|
||||
}
|
||||
else {
|
||||
field.Value = viewModel.Text;
|
||||
|
||||
if (settings.Required && String.IsNullOrWhiteSpace(field.Value)) {
|
||||
updater.AddModelError("Text", T("The field {0} is mandatory", T(field.DisplayName)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
@model Orchard.Core.Common.ViewModels.TextFieldDriverViewModel
|
||||
|
||||
@{
|
||||
var isRequired = Model.Settings.Required && String.IsNullOrWhiteSpace(Model.Settings.DefaultValue);
|
||||
}
|
||||
<fieldset>
|
||||
<label for="@Html.FieldIdFor(m => m.Text)" @if(Model.Settings.Required) { <text>class="required"</text> }>@Model.Field.DisplayName</label>
|
||||
@if (String.IsNullOrWhiteSpace(Model.Settings.Flavor)) {
|
||||
@(Model.Settings.Required ? Html.TextBoxFor(m => m.Text, new {@class = "text", required = "required"}) : Html.TextBoxFor(m => m.Text, new {@class = "text"}))
|
||||
@(isRequired ? Html.TextBoxFor(m => m.Text, new {@class = "text", required = "required"}) : Html.TextBoxFor(m => m.Text, new {@class = "text"}))
|
||||
@Html.ValidationMessageFor(m => m.Text)
|
||||
}
|
||||
else {
|
||||
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem)
|
||||
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: isRequired, ContentItem: Model.ContentItem)
|
||||
}
|
||||
@if (HasText(Model.Settings.Hint)) {
|
||||
<span class="hint">@Model.Settings.Hint</span>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common.Fields;
|
||||
using Orchard.Core.Common.Settings;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,13 +15,20 @@ namespace Orchard.Fields.Drivers {
|
||||
|
||||
public TextFieldDriver(ITokenizer tokenizer) {
|
||||
_tokenizer = tokenizer;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(ContentPart part, TextField field, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>();
|
||||
|
||||
if (!String.IsNullOrEmpty(settings.DefaultValue) && (String.IsNullOrEmpty(field.Value) || field.Value.Equals(settings.DefaultValue))) {
|
||||
if (!String.IsNullOrWhiteSpace(settings.DefaultValue) && (String.IsNullOrWhiteSpace(field.Value) || field.Value.Equals(settings.DefaultValue))) {
|
||||
field.Value = _tokenizer.Replace(settings.DefaultValue, new Dictionary<string, object> { { "Content", part.ContentItem } });
|
||||
|
||||
if (settings.Required && String.IsNullOrWhiteSpace(field.Value)) {
|
||||
updater.AddModelError("Text", T("The field {0} is mandatory", T(field.DisplayName)));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user