mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing widget layer editing and tidying up the widget management index template.
work item: 16837 --HG-- branch : dev
This commit is contained in:
@@ -170,8 +170,10 @@ namespace Orchard.Specs.Bindings {
|
|||||||
[When(@"I follow ""(.*)""")]
|
[When(@"I follow ""(.*)""")]
|
||||||
public void WhenIFollow(string linkText) {
|
public void WhenIFollow(string linkText) {
|
||||||
var link = _doc.DocumentNode
|
var link = _doc.DocumentNode
|
||||||
.SelectNodes("//a")
|
.SelectNodes("//a")
|
||||||
.Single(elt => elt.InnerText == linkText);
|
.SingleOrDefault(elt => elt.InnerText == linkText)
|
||||||
|
?? _doc.DocumentNode
|
||||||
|
.SelectSingleNode(string.Format("//a[@title='{0}']", linkText));
|
||||||
|
|
||||||
var urlPath = link.Attributes["href"].Value;
|
var urlPath = link.Attributes["href"].Value;
|
||||||
|
|
||||||
|
@@ -206,6 +206,11 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>WebHosting.feature</DependentUpon>
|
<DependentUpon>WebHosting.feature</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Widgets.feature.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Widgets.feature</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Hosting\Orchard.Web\Web.config">
|
<Content Include="Hosting\Orchard.Web\Web.config">
|
||||||
@@ -278,6 +283,10 @@
|
|||||||
<Generator>SpecFlowSingleFileGenerator</Generator>
|
<Generator>SpecFlowSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>UsingSpecFlow.feature.cs</LastGenOutput>
|
<LastGenOutput>UsingSpecFlow.feature.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Widgets.feature">
|
||||||
|
<Generator>SpecFlowSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Widgets.feature.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
|
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
|
||||||
|
17
src/Orchard.Specs/Widgets.feature
Normal file
17
src/Orchard.Specs/Widgets.feature
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
Feature: Widgets
|
||||||
|
In order to add and manage widgets on my site
|
||||||
|
As an author
|
||||||
|
I want to create and edit widgets and layers
|
||||||
|
|
||||||
|
Scenario: I can edit a default layer
|
||||||
|
Given I have installed Orchard
|
||||||
|
When I go to "admin/widgets"
|
||||||
|
And I follow "Edit Default layer"
|
||||||
|
And I fill in
|
||||||
|
| name | value |
|
||||||
|
| Description | This is the default layer. |
|
||||||
|
And I hit "Save"
|
||||||
|
And I am redirected
|
||||||
|
Then I should see "Your Layer has been saved"
|
||||||
|
When I follow "Edit Default layer"
|
||||||
|
Then I should see "<textarea[^>]*>\s*This is the default layer.\s*</textarea>"
|
93
src/Orchard.Specs/Widgets.feature.cs
generated
Normal file
93
src/Orchard.Specs/Widgets.feature.cs
generated
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||||
|
// SpecFlow Version:1.4.0.0
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
#region Designer generated code
|
||||||
|
namespace Orchard.Specs
|
||||||
|
{
|
||||||
|
using TechTalk.SpecFlow;
|
||||||
|
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.4.0.0")]
|
||||||
|
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[NUnit.Framework.TestFixtureAttribute()]
|
||||||
|
[NUnit.Framework.DescriptionAttribute("Widgets")]
|
||||||
|
public partial class WidgetsFeature
|
||||||
|
{
|
||||||
|
|
||||||
|
private static TechTalk.SpecFlow.ITestRunner testRunner;
|
||||||
|
|
||||||
|
#line 1 "Widgets.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"), "Widgets", "In order to add and manage widgets on my site\r\nAs an author\r\nI want to create and" +
|
||||||
|
" edit widgets and layers", GenerationTargetLanguage.CSharp, ((string[])(null)));
|
||||||
|
testRunner.OnFeatureStart(featureInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TestFixtureTearDownAttribute()]
|
||||||
|
public virtual void FeatureTearDown()
|
||||||
|
{
|
||||||
|
testRunner.OnFeatureEnd();
|
||||||
|
testRunner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
|
||||||
|
{
|
||||||
|
testRunner.OnScenarioStart(scenarioInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TearDownAttribute()]
|
||||||
|
public virtual void ScenarioTearDown()
|
||||||
|
{
|
||||||
|
testRunner.OnScenarioEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
[NUnit.Framework.TestAttribute()]
|
||||||
|
[NUnit.Framework.DescriptionAttribute("I can edit a default layer")]
|
||||||
|
public virtual void ICanEditADefaultLayer()
|
||||||
|
{
|
||||||
|
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("I can edit a default layer", ((string[])(null)));
|
||||||
|
#line 6
|
||||||
|
this.ScenarioSetup(scenarioInfo);
|
||||||
|
#line 7
|
||||||
|
testRunner.Given("I have installed Orchard");
|
||||||
|
#line 8
|
||||||
|
testRunner.When("I go to \"admin/widgets\"");
|
||||||
|
#line 9
|
||||||
|
testRunner.And("I follow \"Edit Default layer\"");
|
||||||
|
#line hidden
|
||||||
|
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
|
"name",
|
||||||
|
"value"});
|
||||||
|
table1.AddRow(new string[] {
|
||||||
|
"Description",
|
||||||
|
"This is the default layer."});
|
||||||
|
#line 10
|
||||||
|
testRunner.And("I fill in", ((string)(null)), table1);
|
||||||
|
#line 13
|
||||||
|
testRunner.And("I hit \"Save\"");
|
||||||
|
#line 14
|
||||||
|
testRunner.And("I am redirected");
|
||||||
|
#line 15
|
||||||
|
testRunner.Then("I should see \"Your Layer has been saved\"");
|
||||||
|
#line 16
|
||||||
|
testRunner.When("I follow \"Edit Default layer\"");
|
||||||
|
#line 17
|
||||||
|
testRunner.Then("I should see \"<textarea[^>]*>\\s*This is the default layer.\\s*</textarea>\"");
|
||||||
|
#line hidden
|
||||||
|
testRunner.CollectScenarioErrors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
@@ -33,18 +33,21 @@ namespace Orchard.Widgets.Drivers {
|
|||||||
|
|
||||||
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
|
protected override DriverResult Editor(LayerPart layerPart, IUpdateModel updater, dynamic shapeHelper) {
|
||||||
if(updater.TryUpdateModel(layerPart, Prefix, null, null)) {
|
if(updater.TryUpdateModel(layerPart, Prefix, null, null)) {
|
||||||
if ( String.IsNullOrWhiteSpace(layerPart.LayerRule) ) {
|
if (String.IsNullOrWhiteSpace(layerPart.LayerRule)) {
|
||||||
layerPart.LayerRule = "true";
|
layerPart.LayerRule = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _widgetsService.GetLayers().Any(l => String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
|
if (_widgetsService.GetLayers()
|
||||||
|
.Any(l =>
|
||||||
|
l.Id != layerPart.Id
|
||||||
|
&& String.Equals(l.Name, layerPart.Name, StringComparison.InvariantCultureIgnoreCase))) {
|
||||||
updater.AddModelError("Name", T("A Layer with the same name already exists"));
|
updater.AddModelError("Name", T("A Layer with the same name already exists"));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_ruleManager.Matches(layerPart.LayerRule);
|
_ruleManager.Matches(layerPart.LayerRule);
|
||||||
}
|
}
|
||||||
catch ( Exception e ) {
|
catch (Exception e) {
|
||||||
updater.AddModelError("Description", T("The rule is not valid: {0}", e.Message));
|
updater.AddModelError("Description", T("The rule is not valid: {0}", e.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,21 +52,16 @@
|
|||||||
<div class="widgets-layers">
|
<div class="widgets-layers">
|
||||||
<ul>
|
<ul>
|
||||||
@foreach (var layer in Model.Layers) {
|
@foreach (var layer in Model.Layers) {
|
||||||
|
var layerClass = "widgets-editLayer";
|
||||||
if (layer.Id == Model.CurrentLayer.Id) {
|
if (layer.Id == Model.CurrentLayer.Id) {
|
||||||
<li class="widgets-currentLayer widgets-editLayer">
|
layerClass += " widgets-currentLayer";
|
||||||
<a href="@Url.Action("EditLayer", new { @layer.Id })">
|
|
||||||
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
|
|
||||||
</a>
|
|
||||||
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
|
|
||||||
</li>
|
|
||||||
} else {
|
|
||||||
<li class="widgets-editLayer">
|
|
||||||
<a href="@Url.Action("EditLayer", new { @layer.Id })">
|
|
||||||
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
|
|
||||||
</a>
|
|
||||||
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
|
|
||||||
</li>
|
|
||||||
}
|
}
|
||||||
|
<li class="@layerClass">
|
||||||
|
<a href="@Url.Action("EditLayer", new { @layer.Id })" title="@T("Edit {0} layer", layer.Name)">
|
||||||
|
<img width="15" height="15" src="@Url.Content("~/modules/orchard.widgets/Content/Admin/images/edit.png")" />
|
||||||
|
</a>
|
||||||
|
@Html.ActionLink(@layer.Name, "Index", new { @layer.Id })
|
||||||
|
</li>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
<div class="new-layer">
|
<div class="new-layer">
|
||||||
|
Reference in New Issue
Block a user