mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge pull request #5256 from jtkech/patch-4
#5235: Awaiting activities not cleared on saving
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
@@ -159,6 +160,15 @@ namespace Orchard.Workflows.Controllers {
|
||||
return RedirectToAction("Edit", new { workflowDefinitionRecord.Id });
|
||||
}
|
||||
|
||||
public JsonResult State(int? id) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows")))
|
||||
throw new AuthenticationException("");
|
||||
|
||||
var workflowDefinitionRecord = id.HasValue ? _workflowDefinitionRecords.Get(id.Value) : null;
|
||||
var isRunning = workflowDefinitionRecord != null && workflowDefinitionRecord.WorkflowRecords.Any();
|
||||
return Json(new { isRunning = isRunning }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public ActionResult Edit(int id, string localId, int? workflowId) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows")))
|
||||
return new HttpUnauthorizedResult();
|
||||
@@ -265,6 +275,7 @@ namespace Orchard.Workflows.Controllers {
|
||||
var activitiesIndex = new Dictionary<string, ActivityRecord>();
|
||||
|
||||
workflowDefinitionRecord.ActivityRecords.Clear();
|
||||
workflowDefinitionRecord.WorkflowRecords.Clear();
|
||||
|
||||
foreach (var activity in state.Activities) {
|
||||
ActivityRecord activityRecord;
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
//<![CDATA[
|
||||
var renderActivityUrl = '@HttpUtility.JavaScriptStringEncode(Url.Action("RenderActivity", "Admin", new { area = "Orchard.Workflows" }))';
|
||||
var editActivityUrl = '@HttpUtility.JavaScriptStringEncode(Url.Action("EditActivity", "Admin", new { area = "Orchard.Workflows" }))';
|
||||
var stateUrl = '@HttpUtility.JavaScriptStringEncode(Url.Action("State", "Admin", new { area = "Orchard.Workflows" }))';
|
||||
var requestAntiForgeryToken = '@HttpUtility.JavaScriptStringEncode(Html.AntiForgeryTokenValueOrchard().ToString())';
|
||||
var localId = '@HttpUtility.JavaScriptStringEncode(Model.LocalId)';
|
||||
var updatedActivityClientId = null;
|
||||
@@ -73,6 +74,7 @@
|
||||
@Html.Hidden("data", String.Empty)
|
||||
|
||||
@Html.Hidden("confirm-delete-activity", T("Are you sure you want to remove this activity?"))
|
||||
@Html.Hidden("confirm-delete-instances", T("Are you sure you want to remove running instances of this workflow?"))
|
||||
|
||||
using (Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
@@ -82,6 +84,16 @@
|
||||
var workflow = loadWorkflow(localId);
|
||||
var data = JSON.stringify(workflow);
|
||||
$("[name='data']").val(data);
|
||||
|
||||
$.ajax({
|
||||
url: stateUrl + "/" + $("#id").val(),
|
||||
async: false,
|
||||
success: function(state) {
|
||||
if(state.isRunning && !confirm($("#confirm-delete-instances").val())) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
@@ -100,4 +112,4 @@
|
||||
@using (Capture(Layout.Messages)) {
|
||||
<div id="save-message" class="message message-Warning" style="display:none">@T("You need to hit \"Save\" in order to save your changes.")</div>
|
||||
<div id="start-message" class="message message-Warning" style="display:none">@T("The workflow needs at least one activity to be set as a starting state.")</div>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user