mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding the ability to rename workflows, fixes #3570
This commit is contained in:
@@ -175,19 +175,29 @@ namespace Orchard.Workflows.Controllers {
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to create workflows")))
|
||||
public ActionResult EditProperties(int id = 0)
|
||||
{
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return View();
|
||||
if (id == 0) {
|
||||
return View();
|
||||
}
|
||||
else {
|
||||
var workflowDefinition = _workflowDefinitionRecords.Get(id);
|
||||
|
||||
return View(new AdminEditViewModel { WorkflowDefinition = new WorkflowDefinitionViewModel { Name = workflowDefinition.Name, Id = workflowDefinition.Id } });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost, ActionName("Create")]
|
||||
public ActionResult CreatePost(string name) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to create workflows")))
|
||||
|
||||
[HttpPost, ActionName("EditProperties")]
|
||||
public ActionResult EditPropertiesPost(AdminEditViewModel adminEditViewModel, int id = 0) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
if (String.IsNullOrWhiteSpace(name)) {
|
||||
|
||||
if (String.IsNullOrWhiteSpace(adminEditViewModel.WorkflowDefinition.Name)) {
|
||||
ModelState.AddModelError("Name", T("The Name can't be empty.").Text);
|
||||
}
|
||||
|
||||
@@ -195,21 +205,22 @@ namespace Orchard.Workflows.Controllers {
|
||||
return View();
|
||||
}
|
||||
|
||||
var workflowDefinitionRecord = new WorkflowDefinitionRecord {
|
||||
Name = name
|
||||
};
|
||||
if (id == 0) {
|
||||
var workflowDefinitionRecord = new WorkflowDefinitionRecord {
|
||||
Name = adminEditViewModel.WorkflowDefinition.Name
|
||||
};
|
||||
|
||||
if (ModelState.IsValid) {
|
||||
_workflowDefinitionRecords.Create(workflowDefinitionRecord);
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return RedirectToAction("Edit", new { workflowDefinitionRecord.Id });
|
||||
}
|
||||
else {
|
||||
var workflowDefinition = _workflowDefinitionRecords.Get(id);
|
||||
|
||||
workflowDefinition.Name = adminEditViewModel.WorkflowDefinition.Name;
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
return RedirectToAction("Edit", new { workflowDefinitionRecord.Id });
|
||||
}
|
||||
|
||||
public ActionResult Edit(int id, string localId, int? workflowId) {
|
||||
|
@@ -0,0 +1,19 @@
|
||||
@model Orchard.Workflows.ViewModels.AdminEditViewModel
|
||||
@using Orchard.Workflows.Models;
|
||||
@using Orchard.Workflows.ViewModels;
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
|
||||
<fieldset>
|
||||
<div>
|
||||
<label for="name">@T("Name")</label>
|
||||
@Html.TextBoxFor(m => m.WorkflowDefinition.Name, new { @class = "text medium" })
|
||||
<span class="hint">@T("The name of the Workflow.")</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
</fieldset>
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
<h1>@Html.TitleForPage(T("Manage Workflow Definitions").ToString()) </h1>
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<div class="manage">@Html.ActionLink(T("Create new Workflow Definition").ToString(), "Create", new { Area = "Orchard.Workflows", returnurl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
<div class="manage">@Html.ActionLink(T("Create new Workflow Definition").Text, "EditProperties", new { Area = "Orchard.Workflows", returnurl = HttpContext.Current.Request.RawUrl }, new { @class = "button primaryAction" })</div>
|
||||
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="publishActions">@T("Actions:")</label>
|
||||
@@ -65,9 +65,9 @@
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@* TODO: As WD is not a Content Item, an EditProperties action is necessary @Html.ActionLink(T("Properties").ToString(), "Edit", new { Area = "Contents", id = entry.WokflowDefinitionId, returnurl = HttpContext.Current.Request.RawUrl }) |*@
|
||||
@Html.ActionLink(T("Edit").ToString(), "Edit", new { id = entry.WokflowDefinitionId }) |
|
||||
@Html.ActionLink(T("Delete").ToString(), "Delete", new { id = entry.WokflowDefinitionId }, new { itemprop = "RemoveUrl UnsafeUrl" })
|
||||
@Html.ActionLink(T("Properties").Text, "EditProperties", new { Id = entry.WokflowDefinitionId, ReturnUrl = HttpContext.Current.Request.RawUrl }) |
|
||||
@Html.ActionLink(T("Edit").Text, "Edit", new { Id = entry.WokflowDefinitionId }) |
|
||||
@Html.ActionLink(T("Delete").Text, "Delete", new { Id = entry.WokflowDefinitionId }, new { ItemProp = "RemoveUrl UnsafeUrl" })
|
||||
</td>
|
||||
</tr>
|
||||
index++;
|
||||
|
Reference in New Issue
Block a user