Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: workflow overview toggle enable button (#7818)

shamoon0b829cab327c
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index e0d30bdc2..f5d270376 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -1565,11 +1565,11 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">41</context>
+ <context context-type="linenumber">48</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">52</context>
+ <context context-type="linenumber">59</context>
</context-group>
</trans-unit>
<trans-unit id="6338800642797811873" datatype="html">
@@ -2470,11 +2470,11 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">40</context>
+ <context context-type="linenumber">47</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">49</context>
+ <context context-type="linenumber">56</context>
</context-group>
</trans-unit>
<trans-unit id="9124347207158517893" datatype="html">
@@ -3700,7 +3700,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">30</context>
+ <context context-type="linenumber">34</context>
</context-group>
</trans-unit>
<trans-unit id="4348351765075925931" datatype="html">
@@ -5059,11 +5059,11 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">42</context>
+ <context context-type="linenumber">49</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">57</context>
+ <context context-type="linenumber">64</context>
</context-group>
</trans-unit>
<trans-unit id="595732867213154214" datatype="html">
@@ -7533,7 +7533,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">30</context>
+ <context context-type="linenumber">34</context>
</context-group>
</trans-unit>
<trans-unit id="6751234988479444294" datatype="html">
@@ -7927,7 +7927,7 @@
<source>No workflows defined.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
- <context context-type="linenumber">66</context>
+ <context context-type="linenumber">73</context>
</context-group>
</trans-unit>
<trans-unit id="4200688335642457098" datatype="html">
@@ -7972,6 +7972,27 @@
<context context-type="linenumber">128</context>
</context-group>
</trans-unit>
+ <trans-unit id="5459159218551862653" datatype="html">
+ <source>Enabled workflow</source>
+ <context-group purpose="location">
+ <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
+ <context context-type="linenumber">139</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="6035681056091592756" datatype="html">
+ <source>Disabled workflow</source>
+ <context-group purpose="location">
+ <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
+ <context context-type="linenumber">140</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="1376040678213338380" datatype="html">
+ <source>Error toggling workflow.</source>
+ <context-group purpose="location">
+ <context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
+ <context context-type="linenumber">146</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="2649252321173430744" datatype="html">
<source>Not Found</source>
<context-group purpose="location">
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.html b/src-ui/src/app/components/manage/workflows/workflows.component.html
index 1e83efd36..ddb8a8654 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.html
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.html
@@ -15,9 +15,9 @@
<li class="list-group-item">
<div class="row">
<div class="col" i18n>Name</div>
- <div class="col d-none d-sm-block" i18n>Sort order</div>
+ <div class="col d-none d-sm-flex" i18n>Sort order</div>
<div class="col" i18n>Status</div>
- <div class="col d-none d-sm-block" i18n>Triggers</div>
+ <div class="col d-none d-sm-flex" i18n>Triggers</div>
<div class="col" i18n>Actions</div>
</div>
</li>
@@ -26,9 +26,16 @@
<li class="list-group-item">
<div class="row">
<div class="col d-flex align-items-center"><button class="btn btn-link p-0 text-start" type="button" (click)="editWorkflow(workflow)" [disabled]="!permissionsService.currentUserCan(PermissionAction.Change, PermissionType.Workflow)">{{workflow.name}}</button></div>
- <div class="col d-flex align-items-center d-none d-sm-block"><code>{{workflow.order}}</code></div>
- <div class="col d-flex align-items-center"><code> @if(workflow.enabled) { <ng-container i18n>Enabled</ng-container> } @else { <span i18n class="text-muted">Disabled</span> }</code></div>
- <div class="col d-flex align-items-center d-none d-sm-block">{{getTypesList(workflow)}}</div>
+ <div class="col d-flex align-items-center d-none d-sm-flex"><code>{{workflow.order}}</code></div>
+ <div class="col d-flex align-items-center">
+ <div class="form-check form-switch mb-0">
+ <input #inputField type="checkbox" class="form-check-input cursor-pointer" [id]="workflow.id+'_enable'" [(ngModel)]="workflow.enabled" (change)="onWorkflowEnableToggled(workflow)" *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Workflow }">
+ <label class="form-check-label cursor-pointer" [for]="workflow.id+'_enable'">
+ <code> @if(workflow.enabled) { <ng-container i18n>Enabled</ng-container> } @else { <span i18n class="text-muted">Disabled</span> }</code>
+ </label>
+ </div>
+ </div>
+ <div class="col d-flex align-items-center d-none d-sm-flex">{{getTypesList(workflow)}}</div>
<div class="col">
<div class="btn-group d-block d-sm-none">
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
index 0bccbad2d..9d92d9ba7 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.spec.ts
@@ -211,4 +211,27 @@ describe('WorkflowsComponent', () => {
editDialog.confirmClicked.emit()
expect(reloadSpy).toHaveBeenCalled()
})
+
+ it('should update workflow when enable is toggled', () => {
+ const patchSpy = jest.spyOn(workflowService, 'patch')
+ const toggleInput = fixture.debugElement.query(
+ By.css('input[type="checkbox"]')
+ )
+ const toastErrorSpy = jest.spyOn(toastService, 'showError')
+ const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
+ // fail first
+ patchSpy.mockReturnValueOnce(
+ throwError(() => new Error('Error getting config'))
+ )
+ toggleInput.nativeElement.click()
+ expect(patchSpy).toHaveBeenCalled()
+ expect(toastErrorSpy).toHaveBeenCalled()
+ // succeed second
+ patchSpy.mockReturnValueOnce(of(workflows[0]))
+ toggleInput.nativeElement.click()
+ patchSpy.mockReturnValueOnce(of({ ...workflows[0], enabled: false }))
+ toggleInput.nativeElement.click()
+ expect(patchSpy).toHaveBeenCalled()
+ expect(toastInfoSpy).toHaveBeenCalled()
+ })
})
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.ts b/src-ui/src/app/components/manage/workflows/workflows.component.ts
index 92b421e9f..592dd3efe 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.ts
@@ -130,4 +130,21 @@ export class WorkflowsComponent
})
})
}
+
+ onWorkflowEnableToggled(workflow: Workflow) {
+ this.workflowService.patch(workflow).subscribe({
+ next: () => {
+ this.toastService.showInfo(
+ workflow.enabled
+ ? $localize`Enabled workflow`
+ : $localize`Disabled workflow`
+ )
+ this.workflowService.clearCache()
+ this.reload()
+ },
+ error: (e) => {
+ this.toastService.showError($localize`Error toggling workflow.`, e)
+ },
+ })
+ }
}