From de1b57d8d951f263632b35dc5d59e9bc4819496d Mon Sep 17 00:00:00 2001 From: lotte Date: Fri, 3 Apr 2020 18:13:22 +0200 Subject: [PATCH] workflow delete/sendback --- resources/i18n/en.json5 | 43 +++++++++++- ...search-result-grid-element.component.html} | 1 + ...search-result-grid-element.component.scss} | 0 ...rch-result-grid-element.component.spec.ts} | 10 +-- ...w-search-result-grid-element.component.ts} | 38 +++++------ ...admin-workflow-grid-element.component.html | 6 +- ...m-admin-workflow-grid-element.component.ts | 50 +++++++++----- ...search-result-list-element.component.html} | 0 ...search-result-list-element.component.scss} | 0 ...rch-result-list-element.component.spec.ts} | 10 +-- ...w-search-result-list-element.component.ts} | 9 ++- ...item-admin-workflow-actions.component.html | 8 +-- src/app/+admin/admin.module.ts | 12 ++-- .../workflow-item-action-page.component.html | 6 ++ .../workflow-item-action-page.component.ts | 65 +++++++++++++++++++ .../workflow-item-delete.component.html | 6 -- .../workflow-item-delete.component.scss | 0 .../workflow-item-delete.component.ts | 63 +++++------------- .../workflow-item-send-back.component.spec.ts | 25 +++++++ .../workflow-item-send-back.component.ts | 31 +++++++++ .../workflowitems-edit-page-routing.module.ts | 5 +- .../workflowitems-edit-page.module.ts | 3 +- .../lookup/dynamic-lookup.component.spec.ts | 2 - .../publication-grid-element.component.html | 5 +- 24 files changed, 271 insertions(+), 127 deletions(-) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/{pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.html => task-search-result/task-admin-workflow-search-result-grid-element.component.html} (87%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/{pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.scss => task-search-result/task-admin-workflow-search-result-grid-element.component.scss} (100%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/{pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.spec.ts => task-search-result/task-admin-workflow-search-result-grid-element.component.spec.ts} (89%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/{pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.ts => task-search-result/task-admin-workflow-search-result-grid-element.component.ts} (52%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/{pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.html => task-item-search-result/task-admin-workflow-search-result-list-element.component.html} (100%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/{pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.scss => task-item-search-result/task-admin-workflow-search-result-list-element.component.scss} (100%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/{pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.spec.ts => task-item-search-result/task-admin-workflow-search-result-list-element.component.spec.ts} (86%) rename src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/{pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.ts => task-item-search-result/task-admin-workflow-search-result-list-element.component.ts} (83%) create mode 100644 src/app/+workflowitems-edit-page/workflow-item-action-page.component.html create mode 100644 src/app/+workflowitems-edit-page/workflow-item-action-page.component.ts delete mode 100644 src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.html delete mode 100644 src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.scss create mode 100644 src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.spec.ts create mode 100644 src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.ts diff --git a/resources/i18n/en.json5 b/resources/i18n/en.json5 index f874a02bdf..a515113445 100644 --- a/resources/i18n/en.json5 +++ b/resources/i18n/en.json5 @@ -267,6 +267,12 @@ "admin.workflow.title": "Admin Workflow", + "admin.workflow.item.workflow": "Workflow", + + "admin.workflow.item.delete": "Delete", + + "admin.workflow.item.send-back": "Send back", + @@ -2224,8 +2230,43 @@ "virtual-metadata.delete-relationship.modal-head": "Select the items for which you want to save the virtual metadata as real metadata", - "workflowAdmin.search.results.head": "Active Workflows", + "workflowAdmin.search.results.head": "Active Workflows", + + + + "workflow-item.delete.notification.success.title": "Deleted", + + "workflow-item.delete.notification.success.content": "This workflow item was successfully deleted", + + "workflow-item.delete.notification.error.title": "Something went wrong", + + "workflow-item.delete.notification.error.content": "The workflow item could not be deleted", + + "workflow-item.delete.title": "Delete workflow item", + + "workflow-item.delete.header": "Delete workflow item", + + "workflow-item.delete.button.cancel": "Cancel", + + "workflow-item.delete.button.confirm": "Delete", + + + "workflow-item.send-back.notification.success.title": "Sent back to submitter", + + "workflow-item.send-back.notification.success.content": "This workflow item was successfully sent back to the submitter", + + "workflow-item.send-back.notification.error.title": "Something went wrong", + + "workflow-item.send-back.notification.error.content": "The workflow item could not be sent back to the submitter", + + "workflow-item.send-back.title": "Send workflow item back to submitter", + + "workflow-item.send-back.header": "Send workflow item back to submitter", + + "workflow-item.send-back.button.cancel": "Cancel", + + "workflow-item.send-back.button.confirm": "Send back", } diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.html b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.html similarity index 87% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.html rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.html index c73a5f5a02..8403e632db 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.html +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.html @@ -1,4 +1,5 @@ { - let component: PoolTaskAdminWorkflowSearchResultGridElementComponent; - let fixture: ComponentFixture; + let component: TaskAdminWorkflowSearchResultGridElementComponent; + let fixture: ComponentFixture; let id; let searchResult; @@ -42,7 +42,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => { init(); TestBed.configureTestingModule( { - declarations: [PoolTaskAdminWorkflowSearchResultGridElementComponent], + declarations: [TaskAdminWorkflowSearchResultGridElementComponent], imports: [ NoopAnimationsModule, TranslateModule.forRoot(), @@ -59,7 +59,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => { })); beforeEach(() => { - fixture = TestBed.createComponent(PoolTaskAdminWorkflowSearchResultGridElementComponent); + fixture = TestBed.createComponent(TaskAdminWorkflowSearchResultGridElementComponent); component = fixture.componentInstance; component.object = searchResult; component.linkTypes = CollectionElementLinkType; diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.ts b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.ts similarity index 52% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.ts rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.ts index 70659a3f03..1f394fe134 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component.ts +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component.ts @@ -1,26 +1,9 @@ -import { Component, ComponentFactoryResolver, ElementRef, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; -import { Item } from '../../../../../core/shared/item.model'; +import { Component, OnInit } from '@angular/core'; import { ViewMode } from '../../../../../core/shared/view-mode.model'; -import { getListableObjectComponent, listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; +import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator'; import { Context } from '../../../../../core/shared/context.model'; -import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; -import { getItemEditPath } from '../../../../../+item-page/item-page-routing.module'; -import { URLCombiner } from '../../../../../core/url-combiner/url-combiner'; -import { - ITEM_EDIT_DELETE_PATH, - ITEM_EDIT_MOVE_PATH, - ITEM_EDIT_PRIVATE_PATH, - ITEM_EDIT_PUBLIC_PATH, - ITEM_EDIT_REINSTATE_PATH, - ITEM_EDIT_WITHDRAW_PATH -} from '../../../../../+item-page/edit-item-page/edit-item-page.routing.module'; import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component'; -import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; -import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service'; -import { GenericConstructor } from '../../../../../core/shared/generic-constructor'; -import { ListableObjectDirective } from '../../../../../shared/object-collection/shared/listable-object/listable-object.directive'; import { PoolTaskSearchResult } from '../../../../../shared/object-collection/shared/pool-task-search-result.model'; -import { PoolTask } from '../../../../../core/tasks/models/pool-task-object.model'; import { Observable } from 'rxjs'; import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model'; import { RemoteData } from '../../../../../core/data/remote-data'; @@ -28,22 +11,31 @@ import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../../../../ import { SearchResult } from '../../../../../shared/search/search-result.model'; import { TaskObject } from '../../../../../core/tasks/models/task-object.model'; import { ClaimedTaskSearchResult } from '../../../../../shared/object-collection/shared/claimed-task-search-result.model'; +import { LinkService } from '../../../../../core/cache/builders/link.service'; +import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; +import { followLink } from '../../../../../shared/utils/follow-link-config.model'; +import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service'; @listableObjectComponent(PoolTaskSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch) @listableObjectComponent(ClaimedTaskSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch) @Component({ - selector: 'ds-pool-task-admin-workflow-search-result-grid-element', - styleUrls: ['./pool-task-admin-workflow-search-result-grid-element.component.scss'], - templateUrl: './pool-task-admin-workflow-search-result-grid-element.component.html' + selector: 'ds-task-admin-workflow-search-result-grid-element', + styleUrls: ['./task-admin-workflow-search-result-grid-element.component.scss'], + templateUrl: './task-admin-workflow-search-result-grid-element.component.html' }) /** * The component for displaying a list element for an pool task search result on the admin search page */ -export class PoolTaskAdminWorkflowSearchResultGridElementComponent extends SearchResultGridElementComponent, TaskObject> implements OnInit { +export class TaskAdminWorkflowSearchResultGridElementComponent extends SearchResultGridElementComponent, TaskObject> implements OnInit { public wfi$: Observable; + constructor(private linkService: LinkService, protected truncatableService: TruncatableService, protected bitstreamService: BitstreamDataService) { + super(truncatableService, bitstreamService); + } + ngOnInit(): void { super.ngOnInit(); + this.dso = this.linkService.resolveLink(this.dso, followLink('workflowitem')); this.wfi$ = (this.dso.workflowitem as Observable>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload()); } } diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.html b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.html index 6f940d097e..d6b76c0a8d 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.html +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.html @@ -6,7 +6,7 @@
    -
  • - -
  • +
  • + +
diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.ts b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.ts index f00dc4fdb4..2ee9f16f52 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.ts +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/workflow-item/workflow-item-admin-workflow-grid-element.component.ts @@ -22,6 +22,12 @@ import { ListableObjectDirective } from '../../../../../shared/object-collection import { WorkflowItemSearchResult } from '../../../../../shared/object-collection/shared/workflow-item-search-result.model'; import { WorkflowItem } from '../../../../../core/submission/models/workflowitem.model'; import { AbstractListableElementComponent } from '../../../../../shared/object-collection/shared/object-collection-element/abstract-listable-element.component'; +import { Observable } from 'rxjs'; +import { LinkService } from '../../../../../core/cache/builders/link.service'; +import { followLink } from '../../../../../shared/utils/follow-link-config.model'; +import { RemoteData } from '../../../../../core/data/remote-data'; +import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../../../../core/shared/operators'; +import { take } from 'rxjs/operators'; @listableObjectComponent(ItemSearchResult, ViewMode.GridElement, Context.AdminWorkflowSearch) @Component({ @@ -36,8 +42,9 @@ export class WorkflowItemAdminWorkflowGridElementComponent extends AbstractLista @ViewChild(ListableObjectDirective, { static: true }) listableObjectDirective: ListableObjectDirective; @ViewChild('badges', { static: true }) badges: ElementRef; @ViewChild('buttons', { static: true }) buttons: ElementRef; + public item$: Observable; - constructor(private componentFactoryResolver: ComponentFactoryResolver) { + constructor(private componentFactoryResolver: ComponentFactoryResolver, private linkService: LinkService) { super(); } @@ -45,30 +52,37 @@ export class WorkflowItemAdminWorkflowGridElementComponent extends AbstractLista * Setup the dynamic child component */ ngOnInit(): void { - const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent()); + this.object = this.linkService.resolveLink(this.object, followLink('item')); + this.item$ = (this.object.item as Observable>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload()); + this.item$.pipe(take(1)).subscribe((item: Item) => { + const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent(item)); - const viewContainerRef = this.listableObjectDirective.viewContainerRef; - viewContainerRef.clear(); + const viewContainerRef = this.listableObjectDirective.viewContainerRef; + viewContainerRef.clear(); - const componentRef = viewContainerRef.createComponent( - componentFactory, - 0, - undefined, - [ - [this.badges.nativeElement], - [this.buttons.nativeElement] - ]); - (componentRef.instance as any).object = this.object; - (componentRef.instance as any).index = this.index; - (componentRef.instance as any).linkType = this.linkType; - (componentRef.instance as any).listID = this.listID; + const componentRef = viewContainerRef.createComponent( + componentFactory, + 0, + undefined, + [ + [this.badges.nativeElement], + [this.buttons.nativeElement] + ]); + (componentRef.instance as any).object = item; + (componentRef.instance as any).index = this.index; + (componentRef.instance as any).linkType = this.linkType; + (componentRef.instance as any).listID = this.listID; + componentRef.changeDetectorRef.detectChanges(); + } + ) } /** * Fetch the component depending on the item's relationship type, view mode and context * @returns {GenericConstructor} */ - private getComponent(): GenericConstructor { - return getListableObjectComponent(this.object.getRenderTypes(), ViewMode.GridElement, undefined) + private getComponent(item: Item): GenericConstructor { + return getListableObjectComponent(item.getRenderTypes(), ViewMode.GridElement, undefined) } + } diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.html b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.html similarity index 100% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.html rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.html diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.scss b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.scss similarity index 100% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.scss rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.scss diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.spec.ts b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.spec.ts similarity index 86% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.spec.ts rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.spec.ts index 63f36ea033..684dd8f108 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.spec.ts +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.spec.ts @@ -8,12 +8,12 @@ import { ViewMode } from '../../../../../core/shared/view-mode.model'; import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; -import { PoolTaskAdminWorkflowSearchResultListElementComponent } from './pool-task-admin-workflow-search-result-list-element.component'; +import { TaskAdminWorkflowSearchResultListElementComponent } from './task-admin-workflow-search-result-list-element.component'; import { Item } from '../../../../../core/shared/item.model'; describe('ItemAdminSearchResultListElementComponent', () => { - let component: PoolTaskAdminWorkflowSearchResultListElementComponent; - let fixture: ComponentFixture; + let component: TaskAdminWorkflowSearchResultListElementComponent; + let fixture: ComponentFixture; let id; let searchResult; @@ -31,7 +31,7 @@ describe('ItemAdminSearchResultListElementComponent', () => { TranslateModule.forRoot(), RouterTestingModule.withRoutes([]) ], - declarations: [PoolTaskAdminWorkflowSearchResultListElementComponent], + declarations: [TaskAdminWorkflowSearchResultListElementComponent], providers: [{ provide: TruncatableService, useValue: {} }], schemas: [NO_ERRORS_SCHEMA] }) @@ -39,7 +39,7 @@ describe('ItemAdminSearchResultListElementComponent', () => { })); beforeEach(() => { - fixture = TestBed.createComponent(PoolTaskAdminWorkflowSearchResultListElementComponent); + fixture = TestBed.createComponent(TaskAdminWorkflowSearchResultListElementComponent); component = fixture.componentInstance; component.object = searchResult; component.linkTypes = CollectionElementLinkType; diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.ts b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.ts similarity index 83% rename from src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.ts rename to src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.ts index db23a3c4aa..2de768b747 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component.ts +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component.ts @@ -14,19 +14,18 @@ import { SearchResult } from '../../../../../shared/search/search-result.model'; import { followLink } from '../../../../../shared/utils/follow-link-config.model'; import { LinkService } from '../../../../../core/cache/builders/link.service'; import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service'; -import { tap } from 'rxjs/operators'; @listableObjectComponent(PoolTaskSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch) @listableObjectComponent(ClaimedTaskSearchResult, ViewMode.ListElement, Context.AdminWorkflowSearch) @Component({ - selector: 'ds-pooltask-admin-workflow-search-result-list-element', - styleUrls: ['./pool-task-admin-workflow-search-result-list-element.component.scss'], - templateUrl: './pool-task-admin-workflow-search-result-list-element.component.html' + selector: 'ds-task-admin-workflow-search-result-list-element', + styleUrls: ['./task-admin-workflow-search-result-list-element.component.scss'], + templateUrl: './task-admin-workflow-search-result-list-element.component.html' }) /** * The component for displaying a list element for an pool task search result on the admin search page */ -export class PoolTaskAdminWorkflowSearchResultListElementComponent extends SearchResultListElementComponent, TaskObject> { +export class TaskAdminWorkflowSearchResultListElementComponent extends SearchResultListElementComponent, TaskObject> { public wfi$: Observable; constructor(private linkService: LinkService, protected truncatableService: TruncatableService) { diff --git a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.html b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.html index 3004eb925c..1a90a4cff4 100644 --- a/src/app/+admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.html +++ b/src/app/+admin/admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component.html @@ -1,7 +1,7 @@ - - {{"admin.search.item.delete" | translate}} + + {{"admin.workflow.item.delete" | translate}} - - {{"admin.search.item.send-back" | translate}} + + {{"admin.workflow.item.send-back" | translate}} diff --git a/src/app/+admin/admin.module.ts b/src/app/+admin/admin.module.ts index b829c8d868..cd10aad1ca 100644 --- a/src/app/+admin/admin.module.ts +++ b/src/app/+admin/admin.module.ts @@ -16,8 +16,8 @@ import { WorkflowItemAdminWorkflowGridElementComponent } from './admin-workflow- import { WorkflowItemAdminWorkflowActionsComponent } from './admin-workflow-page/admin-workflow-search-results/workflow-item-admin-workflow-actions.component'; import { WorkflowItemAdminWorkflowListElementComponent } from './admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/workflow-item/workflow-item-admin-workflow-list-element.component'; import { AdminWorkflowPageComponent } from './admin-workflow-page/admin-workflow-page.component'; -import { PoolTaskAdminWorkflowSearchResultListElementComponent } from './admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/pool-task-item-search-result/pool-task-admin-workflow-search-result-list-element.component'; -import { PoolTaskAdminWorkflowSearchResultGridElementComponent } from './admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/pool-task-search-result/pool-task-admin-workflow-search-result-grid-element.component'; +import { TaskAdminWorkflowSearchResultGridElementComponent } from './admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-grid-element/task-search-result/task-admin-workflow-search-result-grid-element.component'; +import { TaskAdminWorkflowSearchResultListElementComponent } from './admin-workflow-page/admin-workflow-search-results/admin-workflow-search-result-list-element/task-item-search-result/task-admin-workflow-search-result-list-element.component'; @NgModule({ imports: [ @@ -42,8 +42,8 @@ import { PoolTaskAdminWorkflowSearchResultGridElementComponent } from './admin-w WorkflowItemAdminWorkflowGridElementComponent, WorkflowItemAdminWorkflowActionsComponent, - PoolTaskAdminWorkflowSearchResultListElementComponent, - PoolTaskAdminWorkflowSearchResultGridElementComponent, + TaskAdminWorkflowSearchResultGridElementComponent, + TaskAdminWorkflowSearchResultListElementComponent, ], entryComponents: [ ItemAdminSearchResultListElementComponent, @@ -58,8 +58,8 @@ import { PoolTaskAdminWorkflowSearchResultGridElementComponent } from './admin-w WorkflowItemAdminWorkflowGridElementComponent, WorkflowItemAdminWorkflowActionsComponent, - PoolTaskAdminWorkflowSearchResultListElementComponent, - PoolTaskAdminWorkflowSearchResultGridElementComponent, + TaskAdminWorkflowSearchResultGridElementComponent, + TaskAdminWorkflowSearchResultListElementComponent, ] }) export class AdminModule { diff --git a/src/app/+workflowitems-edit-page/workflow-item-action-page.component.html b/src/app/+workflowitems-edit-page/workflow-item-action-page.component.html new file mode 100644 index 0000000000..76808c7e14 --- /dev/null +++ b/src/app/+workflowitems-edit-page/workflow-item-action-page.component.html @@ -0,0 +1,6 @@ +
+

{{'workflow-item.' + type + '.header' | translate}}

+ + + +
diff --git a/src/app/+workflowitems-edit-page/workflow-item-action-page.component.ts b/src/app/+workflowitems-edit-page/workflow-item-action-page.component.ts new file mode 100644 index 0000000000..fcc943a741 --- /dev/null +++ b/src/app/+workflowitems-edit-page/workflow-item-action-page.component.ts @@ -0,0 +1,65 @@ +import { OnInit } from '@angular/core'; +import { Observable } from 'rxjs'; +import { map, switchMap, take } from 'rxjs/operators'; +import { TranslateService } from '@ngx-translate/core'; +import { WorkflowItem } from '../core/submission/models/workflowitem.model'; +import { Item } from '../core/shared/item.model'; +import { ActivatedRoute, Data, Router } from '@angular/router'; +import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service'; +import { RouteService } from '../core/services/route.service'; +import { NotificationsService } from '../shared/notifications/notifications.service'; +import { RemoteData } from '../core/data/remote-data'; +import { getAllSucceededRemoteData, getRemoteDataPayload } from '../core/shared/operators'; +import { isEmpty } from '../shared/empty.util'; + +export abstract class WorkflowItemActionPageComponent implements OnInit { + public type; + public wfi$: Observable; + public item$: Observable; + + constructor(protected route: ActivatedRoute, + protected workflowItemService: WorkflowItemDataService, + protected router: Router, + protected routeService: RouteService, + protected notificationsService: NotificationsService, + protected translationService: TranslateService) { + } + + ngOnInit() { + this.type = this.getType(); + this.wfi$ = this.route.data.pipe(map((data: Data) => data.wfi as RemoteData), getRemoteDataPayload()); + this.item$ = this.wfi$.pipe(switchMap((wfi: WorkflowItem) => (wfi.item as Observable>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload()))); + } + + performAction() { + this.wfi$.pipe( + take(1), + switchMap((wfi: WorkflowItem) => this.sendRequest(wfi.id)) + ).subscribe((successful: boolean) => { + if (successful) { + const title = this.translationService.get('workflow-item.' + this.type + '.notification.success.title'); + const content = this.translationService.get('workflow-item.' + this.type + '.notification.success.content'); + this.notificationsService.success(title, content) + } else { + const title = this.translationService.get('workflow-item.' + this.type + '.notification.error.title'); + const content = this.translationService.get('workflow-item.' + this.type + '.notification.error.content'); + this.notificationsService.error(title, content) + } + this.previousPage(); + }) + } + + previousPage() { + this.routeService.getPreviousUrl().pipe(take(1)) + .subscribe((url) => { + if (isEmpty(url)) { + url = '/mydspace'; + } + this.router.navigateByUrl(url); + + } + ); + } + abstract sendRequest(id: string): Observable; + abstract getType(): string; +} diff --git a/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.html b/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.html deleted file mode 100644 index 5b1b8c45b3..0000000000 --- a/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.html +++ /dev/null @@ -1,6 +0,0 @@ -
- - - - -
diff --git a/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.scss b/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.ts b/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.ts index 4c6f0ff885..171aeb27d1 100644 --- a/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.ts +++ b/src/app/+workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component.ts @@ -1,58 +1,31 @@ -import { Component, OnInit } from '@angular/core'; -import { WorkflowItem } from '../../core/submission/models/workflowitem.model'; -import { Item } from '../../core/shared/item.model'; +import { Component } from '@angular/core'; import { Observable } from 'rxjs'; -import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../core/shared/operators'; -import { RemoteData } from '../../core/data/remote-data'; -import { ActivatedRoute, Data, Router } from '@angular/router'; -import { map, switchMap, take } from 'rxjs/operators'; +import { WorkflowItemActionPageComponent } from '../workflow-item-action-page.component'; +import { ActivatedRoute, Router } from '@angular/router'; import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service'; -import { TranslateService } from '@ngx-translate/core'; -import { NotificationsService } from '../../shared/notifications/notifications.service'; import { RouteService } from '../../core/services/route.service'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'ds-workflow-item-delete', - templateUrl: './workflow-item-delete.component.html', - styleUrls: ['./workflow-item-delete.component.scss'] + templateUrl: '../workflow-item-action-page.component.html' }) -export class WorkflowItemDeleteComponent implements OnInit { - public wfi$: Observable; - public item$: Observable; - - constructor(private route: ActivatedRoute, - private workflowItemService: WorkflowItemDataService, - private router: Router, - private routeService: RouteService, - private notificationsService: NotificationsService, - private translationService: TranslateService) { +export class WorkflowItemDeleteComponent extends WorkflowItemActionPageComponent { + constructor(protected route: ActivatedRoute, + protected workflowItemService: WorkflowItemDataService, + protected router: Router, + protected routeService: RouteService, + protected notificationsService: NotificationsService, + protected translationService: TranslateService) { + super(route, workflowItemService, router, routeService, notificationsService, translationService); } - ngOnInit() { - this.route.data.subscribe((t) => console.log(t)); - this.wfi$ = this.route.data.pipe(map((data: Data) => data.wfi as RemoteData), getRemoteDataPayload()); - this.item$ = this.wfi$.pipe(switchMap((wfi: WorkflowItem) => (wfi.item as Observable>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload()))); + getType(): string { + return 'delete'; } - delete() { - this.wfi$.pipe( - take(1), - switchMap((wfi: WorkflowItem) => this.workflowItemService.delete(wfi.id)) - ).subscribe((successful: boolean) => { - if (successful) { - const title = this.translationService.get('workflowitem.delete.notification.success.title'); - const content = this.translationService.get('workflowitem.delete.notification.success.content'); - this.notificationsService.success(title, content) - } else { - const title = this.translationService.get('workflowitem.delete.notification.error.title'); - const content = this.translationService.get('workflowitem.delete.notification.error.content'); - this.notificationsService.error(title, content) - } - this.previousPage(); - }) - } - - previousPage() { - this.routeService.getPreviousUrl(); + sendRequest(id: string): Observable { + return this.workflowItemService.delete(id); } } diff --git a/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.spec.ts b/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.spec.ts new file mode 100644 index 0000000000..ba293845d9 --- /dev/null +++ b/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WorkflowItemDeleteComponent } from './workflow-item-send-back.component'; + +describe('WorkflowItemDeleteComponent', () => { + let component: WorkflowItemDeleteComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WorkflowItemDeleteComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WorkflowItemDeleteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.ts b/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.ts new file mode 100644 index 0000000000..c4006811d9 --- /dev/null +++ b/src/app/+workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component.ts @@ -0,0 +1,31 @@ +import { Component } from '@angular/core'; +import { WorkflowItemActionPageComponent } from '../workflow-item-action-page.component'; +import { Observable } from 'rxjs'; +import { ActivatedRoute, Router } from '@angular/router'; +import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service'; +import { RouteService } from '../../core/services/route.service'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { TranslateService } from '@ngx-translate/core'; + +@Component({ + selector: 'ds-workflow-item-send-back', + templateUrl: '../workflow-item-action-page.component.html' +}) +export class WorkflowItemSendBackComponent extends WorkflowItemActionPageComponent { + constructor(protected route: ActivatedRoute, + protected workflowItemService: WorkflowItemDataService, + protected router: Router, + protected routeService: RouteService, + protected notificationsService: NotificationsService, + protected translationService: TranslateService) { + super(route, workflowItemService, router, routeService, notificationsService, translationService); + } + + getType(): string { + return 'send-back'; + } + + sendRequest(id: string): Observable { + return this.workflowItemService.sendBack(id); + } +} diff --git a/src/app/+workflowitems-edit-page/workflowitems-edit-page-routing.module.ts b/src/app/+workflowitems-edit-page/workflowitems-edit-page-routing.module.ts index 88402ec177..e9989bf947 100644 --- a/src/app/+workflowitems-edit-page/workflowitems-edit-page-routing.module.ts +++ b/src/app/+workflowitems-edit-page/workflowitems-edit-page-routing.module.ts @@ -7,6 +7,7 @@ import { URLCombiner } from '../core/url-combiner/url-combiner'; import { getWorkflowItemModulePath } from '../app-routing.module'; import { WorkflowItemDeleteComponent } from './workflow-item-delete/workflow-item-delete.component'; import { WorkflowItemPageResolver } from './workflow-item-page.resolver'; +import { WorkflowItemSendBackComponent } from './workflow-item-send-back/workflow-item-send-back.component'; export function getWorkflowItemPageRoute(wfiId: string) { return new URLCombiner(getWorkflowItemModulePath(), wfiId).toString(); @@ -50,8 +51,8 @@ const WORKFLOW_ITEM_SEND_BACK_PATH = 'sendback'; { canActivate: [AuthenticatedGuard], path: WORKFLOW_ITEM_SEND_BACK_PATH, - component: WorkflowItemDeleteComponent, - data: { title: 'workflow-item.sendback.title' } + component: WorkflowItemSendBackComponent, + data: { title: 'workflow-item.send-back.title' } } ] }] diff --git a/src/app/+workflowitems-edit-page/workflowitems-edit-page.module.ts b/src/app/+workflowitems-edit-page/workflowitems-edit-page.module.ts index 8e301390ae..ef1e49abf5 100644 --- a/src/app/+workflowitems-edit-page/workflowitems-edit-page.module.ts +++ b/src/app/+workflowitems-edit-page/workflowitems-edit-page.module.ts @@ -4,6 +4,7 @@ import { SharedModule } from '../shared/shared.module'; import { WorkflowItemsEditPageRoutingModule } from './workflowitems-edit-page-routing.module'; import { SubmissionModule } from '../submission/submission.module'; import { WorkflowItemDeleteComponent } from './workflow-item-delete/workflow-item-delete.component'; +import { WorkflowItemSendBackComponent } from './workflow-item-send-back/workflow-item-send-back.component'; @NgModule({ imports: [ @@ -12,7 +13,7 @@ import { WorkflowItemDeleteComponent } from './workflow-item-delete/workflow-ite SharedModule, SubmissionModule, ], - declarations: [WorkflowItemDeleteComponent] + declarations: [WorkflowItemDeleteComponent, WorkflowItemSendBackComponent] }) /** * This module handles all modules that need to access the workflowitems edit page. diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts index c1f8ad69ba..c249c797a6 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts @@ -27,8 +27,6 @@ import { AuthorityConfidenceStateDirective } from '../../../../../authority-conf import { ObjNgFor } from '../../../../../utils/object-ngfor.pipe'; import { GLOBAL_CONFIG, GlobalConfig } from '../../../../../../../config'; import { MOCK_SUBMISSION_CONFIG } from '../../../../../testing/mock-submission-config'; -import { WorkspaceitemsEditPageModule } from '../../../../../../+workspaceitems-edit-page/workspaceitems-edit-page.module'; -import { WorkspaceItem } from '../../../../../../core/submission/models/workspaceitem.model'; let LOOKUP_TEST_MODEL_CONFIG = { authorityOptions: { diff --git a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html index 81ee3ebcce..a9b5d0bdaa 100644 --- a/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html +++ b/src/app/shared/object-grid/item-grid-element/item-types/publication/publication-grid-element.component.html @@ -1 +1,4 @@ - + + + +