mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Editing activity properties
--HG-- branch : 1.x extra : rebase_source : d5dcc4ea0d93a2d70a3b04619bdc603c6f54df33
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
@@ -172,7 +171,7 @@ namespace Orchard.Workflows.Controllers {
|
||||
|
||||
var viewModel = new AdminEditViewModel {
|
||||
LocalId = localId,
|
||||
AllActivities = _activitiesManager.GetActivities()
|
||||
AllActivities = _activitiesManager.GetActivities(),
|
||||
};
|
||||
|
||||
return View("Edit", viewModel);
|
||||
@@ -191,12 +190,18 @@ namespace Orchard.Workflows.Controllers {
|
||||
}
|
||||
|
||||
IShape shape = New.Activity(activity);
|
||||
|
||||
if (model.State != null) {
|
||||
var dynamicState = FormParametersHelper.ToDynamic(FormParametersHelper.ToString(model.State));
|
||||
((dynamic)shape).State(dynamicState);
|
||||
}
|
||||
|
||||
shape.Metadata.Alternates.Add("Activity__" + activity.Name);
|
||||
|
||||
return new ShapeResult(this, shape);
|
||||
}
|
||||
|
||||
public ActionResult EditActivity(string localId, ActivityViewModel model) {
|
||||
public ActionResult EditActivity(string localId, string clientId, ActivityViewModel model) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
@@ -209,12 +214,9 @@ namespace Orchard.Workflows.Controllers {
|
||||
// build the form, and let external components alter it
|
||||
var form = activity.Form == null ? null : _formManager.Build(activity.Form);
|
||||
|
||||
// bind form with existing values.
|
||||
if (model.State != null) {
|
||||
_formManager.Bind(form, new DictionaryValueProvider<string>(model.State, CultureInfo.InvariantCulture));
|
||||
}
|
||||
// form is bound on client side
|
||||
|
||||
var viewModel = New.ViewModel(LocalId: localId, Form: form);
|
||||
var viewModel = New.ViewModel(LocalId: localId, ClientId: clientId, Form: form);
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
@@ -248,7 +250,16 @@ namespace Orchard.Workflows.Controllers {
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
return RedirectToAction("EditLocal", new {localId});
|
||||
var model = new UpdatedActivityModel {
|
||||
ClientId = clientId,
|
||||
Data = formValues
|
||||
};
|
||||
|
||||
TempData["UpdatedViewModel"] = model;
|
||||
|
||||
return RedirectToAction("EditLocal", new {
|
||||
localId
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("EditActivity")]
|
||||
|
@@ -65,6 +65,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Scripts\jquery.jsPlumb-1.3.16-all-min.js" />
|
||||
<Content Include="Scripts\orchard-workflows-serialize.js" />
|
||||
<Content Include="Scripts\orchard-workflows.js" />
|
||||
<Content Include="Styles\admin-workflows.css" />
|
||||
<Content Include="Styles\images\blocking.png" />
|
||||
@@ -148,6 +149,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ActivityToolbox.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Activity-Notify.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
var saveLocal = function () {
|
||||
var saveLocal = function (localId) {
|
||||
var wokflow = {
|
||||
activities: [],
|
||||
connections: []
|
||||
@@ -33,19 +33,21 @@ var saveLocal = function () {
|
||||
sessionStorage.setItem(localId, JSON.stringify(wokflow));
|
||||
};
|
||||
|
||||
var loadActivities = function () {
|
||||
var workflow = sessionStorage.getItem(localId);
|
||||
|
||||
if (!workflow) {
|
||||
var loadActivities = function (localId) {
|
||||
var workflow = loadWorkflow(localId);
|
||||
if (workflow == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// deserialize
|
||||
workflow = JSON.parse(workflow);
|
||||
|
||||
// activities
|
||||
for (var i = 0; i < workflow.activities.length; i++) {
|
||||
var activity = workflow.activities[i];
|
||||
|
||||
// if an activity has been modified, update it
|
||||
if (updatedActivityState != null && updatedActivityClientId == activity.clientId) {
|
||||
activity.state = JSON.parse(updatedActivityState);
|
||||
}
|
||||
|
||||
renderActivity(activity.clientId, activity.name, activity.state, activity.top, activity.left);
|
||||
}
|
||||
|
||||
@@ -63,4 +65,99 @@ var loadActivities = function () {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var loadWorkflow = function(localId) {
|
||||
var workflow = sessionStorage.getItem(localId);
|
||||
|
||||
if (!workflow) {
|
||||
return;
|
||||
}
|
||||
|
||||
// deserialize
|
||||
workflow = JSON.parse(workflow);
|
||||
|
||||
|
||||
return workflow;
|
||||
};
|
||||
|
||||
var getActivity = function(localId, clientId) {
|
||||
|
||||
var workflow = loadWorkflow(localId);
|
||||
if (workflow == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var activity = null;
|
||||
for (var i = 0; i < workflow.activities.length; i++) {
|
||||
var a = workflow.activities[i];
|
||||
if (a.clientId == clientId) {
|
||||
activity = a;
|
||||
}
|
||||
}
|
||||
|
||||
return activity;
|
||||
};
|
||||
|
||||
var loadForm = function(localId, clientId) {
|
||||
|
||||
// bind state to form
|
||||
|
||||
var activity = getActivity(localId, clientId);
|
||||
bindForm($('form'), activity.state);
|
||||
};
|
||||
|
||||
var bindForm = function(form, data) {
|
||||
|
||||
$.each(data, function (name, val) {
|
||||
var $el = $('[name="' + name + '"]'),
|
||||
type = $el.attr('type');
|
||||
|
||||
switch (type) {
|
||||
case 'checkbox':
|
||||
$el.attr('checked', 'checked');
|
||||
break;
|
||||
case 'radio':
|
||||
$el.filter('[value="' + val + '"]').attr('checked', 'checked');
|
||||
break;
|
||||
default:
|
||||
$el.val(val);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
var serializeForm = function(form) {
|
||||
var data = {};
|
||||
|
||||
$(form).find('select, input, textarea').each(function(index, el) {
|
||||
var $el = $(el);
|
||||
var name = $el.attr('name');
|
||||
var type = $el.attr('type');
|
||||
|
||||
switch (type) {
|
||||
case 'checkbox':
|
||||
data[name] = $el.attr('checked') ? 'true' : false;
|
||||
break;
|
||||
case 'radio':
|
||||
var value = $el.filter('checked').attr('value');
|
||||
if (value) {
|
||||
data[name] = value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
data[name] = $el.val();
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
var saveState = function(localId, clientId, data) {
|
||||
var activity = getActivity(localId, clientId);
|
||||
activity.state = data;
|
||||
|
||||
sessionStorage.setItem(localId, JSON.stringify(wokflow));
|
||||
};
|
||||
*/
|
@@ -126,7 +126,7 @@
|
||||
|
||||
if (activities[name].hasForm) {
|
||||
dom.dblclick(function() {
|
||||
saveLocal();
|
||||
saveLocal(localId);
|
||||
window.location.href = editActivityUrl + "/0?name=" + name + "&clientId=" + elt.viewModel.clientId + "&localId=" + localId;
|
||||
});
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Workflows.Models;
|
||||
using Orchard.Workflows.Services;
|
||||
|
||||
@@ -8,4 +9,10 @@ namespace Orchard.Workflows.ViewModels {
|
||||
public IEnumerable<IActivity> AllActivities { get; set; }
|
||||
public WorkflowDefinitionViewModel WorkflowDefinition { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatedActivityModel {
|
||||
public string ClientId { get; set; }
|
||||
public FormCollection Data { get; set; }
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
@using Orchard.Utility.Extensions
|
||||
|
||||
@{
|
||||
string name = Model.Name;
|
||||
bool blocking = Model.IsBlocking;
|
||||
string blockingClass = blocking ? "blocking" : null;
|
||||
}
|
||||
|
||||
<div class="@blockingClass" title="@Model.State.Message">
|
||||
@name.CamelFriendly()
|
||||
@if (Model.State.Notification != null) {
|
||||
@:- @Model.State.Notification
|
||||
}
|
||||
|
||||
</div>
|
@@ -1,6 +1,7 @@
|
||||
@model Orchard.Workflows.ViewModels.AdminEditViewModel
|
||||
@using ClaySharp.Implementation
|
||||
@using Orchard.ContentManagement
|
||||
@using Orchard.Forms.Services
|
||||
@using Orchard.Localization
|
||||
@using Orchard.Utility.Extensions
|
||||
@using Orchard.Workflows.Models;
|
||||
@@ -36,7 +37,18 @@
|
||||
var editActivityUrl = '@Url.Action("EditActivity", "Admin", new { area = "Orchard.Workflows" })';
|
||||
var requestAntiForgeryToken = '@Html.AntiForgeryTokenValueOrchard()';
|
||||
var localId = '@Model.LocalId';
|
||||
var updatedActivityClientId = null;
|
||||
var updatedActivityState = null;
|
||||
|
||||
@if (TempData.ContainsKey("UpdatedViewModel")) {
|
||||
var model = TempData["UpdatedViewModel"] as UpdatedActivityModel;
|
||||
if (model != null) {
|
||||
<text>
|
||||
updatedActivityClientId = '@(model.ClientId)';
|
||||
updatedActivityState = '@Html.Raw(FormParametersHelper.ToJsonString(model.Data))';
|
||||
</text>
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@
|
||||
Style.Include("~/themes/theadmin/styles/ie6.css").UseCondition("lte IE 6").SetAttribute("media", "screen, projection");
|
||||
|
||||
Layout.Title = @T("Edit Activity");
|
||||
Script.Require("jQueryUI");
|
||||
Script.Include("orchard-workflows-serialize.js");
|
||||
}
|
||||
|
||||
@Html.ValidationSummary()
|
||||
@@ -26,3 +28,18 @@
|
||||
<button class="cancel" type="submit" name="submit.Cancel" value="@T("Cancel")">@T("Cancel")</button>
|
||||
</fieldset>
|
||||
}
|
||||
|
||||
@using (Script.Head()) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var requestAntiForgeryToken = '@Html.AntiForgeryTokenValueOrchard()';
|
||||
var localId = '@Model.LocalId';
|
||||
//]]>
|
||||
</script>
|
||||
}
|
||||
|
||||
@using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
loadForm('@Model.LocalId', '@Model.ClientId');
|
||||
</script>
|
||||
}
|
@@ -160,8 +160,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Memcached", "Orchard.Web\Mo
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Caching.Memcached", "Orchard.Web\Modules\Orchard.Caching.Memcached\Orchard.Caching.Memcached.csproj", "{A2C5BAE0-E4A0-4B41-BC44-D4099E471111}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Taxonomies", "Orchard.Web\Modules\Contrib.Taxonomies\Contrib.Taxonomies.csproj", "{E649EA64-D213-461B-87F7-D67035801443}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeCoverage|Any CPU = CodeCoverage|Any CPU
|
||||
@@ -891,16 +889,6 @@ Global
|
||||
{A2C5BAE0-E4A0-4B41-BC44-D4099E471111}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2C5BAE0-E4A0-4B41-BC44-D4099E471111}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2C5BAE0-E4A0-4B41-BC44-D4099E471111}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.CodeCoverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.CodeCoverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Coverage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Coverage|Any CPU.Build.0 = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.FxCop|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.FxCop|Any CPU.Build.0 = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E649EA64-D213-461B-87F7-D67035801443}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -963,7 +951,6 @@ Global
|
||||
{7528BF74-25C7-4ABE-883A-443B4EEC4776} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{4A037ACB-A79A-43A9-9E7D-E8F1BF7AEB91} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{A2C5BAE0-E4A0-4B41-BC44-D4099E471111} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{E649EA64-D213-461B-87F7-D67035801443} = {E9C9F120-07BA-4DFB-B9C3-3AFB9D44C9D5}
|
||||
{ABC826D4-2FA1-4F2F-87DE-E6095F653810} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{F112851D-B023-4746-B6B1-8D2E5AD8F7AA} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
{6CB3EB30-F725-45C0-9742-42599BA8E8D2} = {74E681ED-FECC-4034-B9BD-01B0BB1BDECA}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
|
||||
namespace Orchard.Data.Bags {
|
||||
public class Bag : DynamicObject, IEnumerable<KeyValuePair<string, object>>, ISItem {
|
||||
internal readonly Dictionary<string, ISItem> _properties = new Dictionary<string, ISItem>();
|
||||
internal readonly Dictionary<string, ISItem> _properties = new Dictionary<string, ISItem>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static dynamic New() {
|
||||
return new Bag();
|
||||
|
Reference in New Issue
Block a user