Fix workflow instance details view

This commit is contained in:
Sipke Schoorstra 2019-09-29 10:43:11 +02:00
parent 9bef97fd0e
commit 8d7d72f177
7 changed files with 15 additions and 5 deletions

View file

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Elsa.Dashboard.Areas.Elsa.ViewModels;
using Elsa.Dashboard.Extensions;
using Elsa.Dashboard.Models;
using Elsa.Dashboard.Options;
using Elsa.Dashboard.Services;
using Elsa.Extensions;
using Elsa.Models;
@ -12,6 +13,7 @@ using Elsa.Serialization;
using Elsa.Serialization.Formatters;
using Jint.Native.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace Elsa.Dashboard.Areas.Elsa.Controllers
{
@ -21,17 +23,20 @@ namespace Elsa.Dashboard.Areas.Elsa.Controllers
{
private readonly IWorkflowInstanceStore workflowInstanceStore;
private readonly IWorkflowDefinitionStore workflowDefinitionStore;
private readonly IOptions<ElsaDashboardOptions> options;
private readonly IWorkflowSerializer serializer;
private readonly INotifier notifier;
public WorkflowInstanceController(
IWorkflowInstanceStore workflowInstanceStore,
IWorkflowDefinitionStore workflowDefinitionStore,
IOptions<ElsaDashboardOptions> options,
IWorkflowSerializer serializer,
INotifier notifier)
{
this.workflowInstanceStore = workflowInstanceStore;
this.workflowDefinitionStore = workflowDefinitionStore;
this.options = options;
this.serializer = serializer;
this.notifier = notifier;
}
@ -92,7 +97,8 @@ namespace Elsa.Dashboard.Areas.Elsa.Controllers
ReturnUrl = returnUrl,
Json = json,
WorkflowDefinition = definition,
WorkflowInstance = instance
WorkflowInstance = instance,
ActivityDefinitions = options.Value.ActivityDefinitions.ToArray()
};
return View(model);

View file

@ -1,4 +1,5 @@
using Elsa.Models;
using ActivityDefinition = Elsa.WorkflowDesigner.Models.ActivityDefinition;
namespace Elsa.Dashboard.Areas.Elsa.ViewModels
{
@ -8,5 +9,6 @@ namespace Elsa.Dashboard.Areas.Elsa.ViewModels
public string Json { get; set; }
public WorkflowDefinitionVersion WorkflowDefinition { get; set; }
public WorkflowInstance WorkflowInstance { get; set; }
public ActivityDefinition[] ActivityDefinitions { get; set; }
}
}

View file

@ -25,7 +25,7 @@
<div class="card-body">
<form asp-action="@formAction">
<input asp-for="Json" id="workflowData" type="hidden"/>
<vc:workflow-designer activity-definitions="@Model.ActivityDefinitions" />
<vc:workflow-designer id="designerHost" activity-definitions="@Model.ActivityDefinitions" />
<div class="text-center">
<button asp-for="SubmitAction" name="SubmitAction" type="submit" value="draft" class="btn btn-primary mt-4">Save Draft</button>
<button asp-for="SubmitAction" name="SubmitAction" type="submit" value="publish" class="btn btn-success mt-4">Publish</button>

View file

@ -18,7 +18,7 @@
</div>
</div>
<div class="card-body">
<wf-designer-host id="designerHost" canvas-height="300vh"></wf-designer-host>
<vc:workflow-designer id="designerHost" activity-definitions="@Model.ActivityDefinitions" />
<div class="text-center">
<a href="@Model.ReturnUrl" class="btn btn-primary mt-4">Back</a>
</div>

View file

@ -8,10 +8,11 @@ namespace Elsa.WorkflowDesigner.ViewComponents
{
public class WorkflowDesignerViewComponent : ViewComponent
{
public IViewComponentResult Invoke(ActivityDefinition[] activityDefinitions)
public IViewComponentResult Invoke(ActivityDefinition[] activityDefinitions, string id)
{
var model = new WorkflowDesignerViewComponentModel
{
Id = id,
ActivityDefinitionsJson = GetActivityDefinitionOptions(activityDefinitions)
};

View file

@ -2,6 +2,7 @@ namespace Elsa.WorkflowDesigner.ViewModels
{
public class WorkflowDesignerViewComponentModel
{
public string Id { get; set; }
public string ActivityDefinitionsJson { get; set; }
}
}

View file

@ -1,3 +1,3 @@
@model Elsa.WorkflowDesigner.ViewModels.WorkflowDesignerViewComponentModel
<wf-designer-host id="designerHost" canvas-height="300vh" activity-definitions="@Model.ActivityDefinitionsJson"></wf-designer-host>
<wf-designer-host id="@Model.Id" canvas-height="300vh" activity-definitions="@Model.ActivityDefinitionsJson"></wf-designer-host>