#21075: Fixing outcome labels.

Work Item: 21075
This commit is contained in:
Sipke Schoorstra
2014-11-16 02:24:38 -08:00
parent 61b73d84ea
commit 3fb84f80ef
7 changed files with 44 additions and 30 deletions

View File

@@ -1,11 +1,10 @@
@using Orchard.Utility.Extensions
@using Orchard.Workflows.Helpers
@{
string name = Model.Name;
string actions = Model.State.Actions;
var outcomes = String.Join(",", actions == null ? new string[0] : actions.Split(new []{','}, StringSplitOptions.RemoveEmptyEntries).Select(x => "'" + x.Trim() + "'").ToArray());
var name = (string)Model.Name;
var outcomes = ((string)Model.State.Actions).FormatOutcomesJson();
}
<div class="event activity-@name.HtmlClassify()" title="@Model.Description" data-outcomes="@outcomes">
<div>@name.CamelFriendly()</div>
</div>
</div>

View File

@@ -1,13 +1,8 @@
@using Orchard.Utility.Extensions
@using Orchard.Workflows.Helpers
@{
string name = Model.Name;
string actions = Model.State.Outcomes;
var outcomes = String.Join(",", actions == null ? new string[0] : actions.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => "'" + x.Trim() + "'").ToArray());
var outcomes = ((string)Model.State.Outcomes).FormatOutcomesJson();
}
<div data-outcomes="@outcomes">
<div class="diamond"></div>
@*@name.CamelFriendly()*@
</div>
</div>

View File

@@ -0,0 +1,29 @@
using System;
using System.Linq;
using System.Web;
namespace Orchard.Workflows.Helpers {
public static class OutcomeSerializerExtensions {
/// <summary>
/// Returns a JSON formatted string.
/// </summary>
/// <param name="outcomesText">A comma separated string containing outcomes.</param>
public static string FormatOutcomesJson(this string outcomesText) {
var items = outcomesText != null
? outcomesText.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())
: Enumerable.Empty<string>();
var query =
from item in items
let outcome = Encode(item)
select "{label:'" + outcome + "', value:'" + outcome + "'}";
var outcomes = String.Join(",", query);
return outcomes;
}
private static string Encode(string value) {
return HttpUtility.JavaScriptStringEncode(value);
}
}
}

View File

@@ -104,6 +104,7 @@
<Content Include="Styles\Web.config" />
<Compile Include="Activities\LoggingActivity.cs" />
<Compile Include="Forms\LoggingActivityForms.cs" />
<Compile Include="Helpers\OutcomeSerializerExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>

View File

@@ -1,4 +1,4 @@
var connectorPaintStyle = {
 var connectorPaintStyle = {
lineWidth: 2,
strokeStyle: "#999",
joinstyle: "round",

View File

@@ -1,13 +1,8 @@
@using Orchard.Utility.Extensions
@using Orchard.Workflows.Helpers
@{
string name = Model.Name;
string branches = Model.State.Branches;
var outcomes = String.Join(",", branches == null ? new string[0] : branches.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => "'" + x.Trim() + "'").ToArray());
var outcomes = ((string)Model.State.Branches).FormatOutcomesJson();
}
<div data-outcomes="@outcomes">
<div class="branch" ></div>
@*@name.CamelFriendly()*@
</div>
</div>

View File

@@ -1,13 +1,8 @@
@using Orchard.Utility.Extensions
@using Orchard.Workflows.Helpers
@{
string name = Model.Name;
string branches = Model.State.Branches;
var outcomes = String.Join(",", branches == null ? new string[0] : branches.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => "'" + x.Trim() + "'").ToArray());
var outcomes = ((string)Model.State.Branches).FormatOutcomesJson();
}
<div data-outcomes="@outcomes" title="First of @outcomes">
<div class="exclusive-branch" ></div>
@*@name.CamelFriendly()*@
</div>
</div>