workflow delete/sendback

This commit is contained in:
lotte
2020-04-03 18:13:22 +02:00
parent 2eb3d11cd2
commit de1b57d8d9
24 changed files with 271 additions and 127 deletions

View File

@@ -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",
}

View File

@@ -17,11 +17,11 @@ 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 { PoolTaskAdminWorkflowSearchResultGridElementComponent } from './pool-task-admin-workflow-search-result-grid-element.component';
import { TaskAdminWorkflowSearchResultGridElementComponent } from './task-admin-workflow-search-result-grid-element.component';
describe('ItemAdminSearchResultGridElementComponent', () => {
let component: PoolTaskAdminWorkflowSearchResultGridElementComponent;
let fixture: ComponentFixture<PoolTaskAdminWorkflowSearchResultGridElementComponent>;
let component: TaskAdminWorkflowSearchResultGridElementComponent;
let fixture: ComponentFixture<TaskAdminWorkflowSearchResultGridElementComponent>;
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;

View File

@@ -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<SearchResult<TaskObject>, TaskObject> implements OnInit {
export class TaskAdminWorkflowSearchResultGridElementComponent extends SearchResultGridElementComponent<SearchResult<TaskObject>, TaskObject> implements OnInit {
public wfi$: Observable<WorkflowItem>;
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<RemoteData<WorkflowItem>>).pipe(getAllSucceededRemoteData(), getRemoteDataPayload());
}
}

View File

@@ -7,6 +7,6 @@
</div>
<ul #buttons class="list-group list-group-flush">
<li class="list-group-item">
<ds-workflow-item-admin-workflow-actions-element class="d-flex justify-content-between" [wfi]="object" [small]="true"></ds-workflow-item-admin-workflow-actions-element>
<ds-workflow-item-admin-workflow-actions-element *ngIf="object" class="d-flex justify-content-between" [wfi]="object" [small]="true"></ds-workflow-item-admin-workflow-actions-element>
</li>
</ul>

View File

@@ -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<Item>;
constructor(private componentFactoryResolver: ComponentFactoryResolver) {
constructor(private componentFactoryResolver: ComponentFactoryResolver, private linkService: LinkService) {
super();
}
@@ -45,7 +52,10 @@ 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<RemoteData<Item>>).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();
@@ -58,17 +68,21 @@ export class WorkflowItemAdminWorkflowGridElementComponent extends AbstractLista
[this.badges.nativeElement],
[this.buttons.nativeElement]
]);
(componentRef.instance as any).object = this.object;
(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<Component>}
*/
private getComponent(): GenericConstructor<Component> {
return getListableObjectComponent(this.object.getRenderTypes(), ViewMode.GridElement, undefined)
private getComponent(item: Item): GenericConstructor<Component> {
return getListableObjectComponent(item.getRenderTypes(), ViewMode.GridElement, undefined)
}
}

View File

@@ -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<PoolTaskAdminWorkflowSearchResultListElementComponent>;
let component: TaskAdminWorkflowSearchResultListElementComponent;
let fixture: ComponentFixture<TaskAdminWorkflowSearchResultListElementComponent>;
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;

View File

@@ -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<SearchResult<TaskObject>, TaskObject> {
export class TaskAdminWorkflowSearchResultListElementComponent extends SearchResultListElementComponent<SearchResult<TaskObject>, TaskObject> {
public wfi$: Observable<WorkflowItem>;
constructor(private linkService: LinkService, protected truncatableService: TruncatableService) {

View File

@@ -1,7 +1,7 @@
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.search.item.delete' | translate">
<i class="fa fa-edit"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.delete" | translate}}</span>
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.workflow.item.delete' | translate">
<i class="fa fa-trash"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.workflow.item.delete" | translate}}</span>
</a>
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 send-back-link" [routerLink]="[getSendBackPath()]" [title]="'admin.search.item.send-back' | translate">
<i class="fa fa-ban"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.send-back" | translate}}</span>
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 send-back-link" [routerLink]="[getSendBackPath()]" [title]="'admin.workflow.item.send-back' | translate">
<i class="fa fa-hand-point-left"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.workflow.item.send-back" | translate}}</span>
</a>

View File

@@ -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 {

View File

@@ -0,0 +1,6 @@
<div class="container" *ngVar="item$ | async as item">
<h2>{{'workflow-item.' + type + '.header' | translate}}</h2>
<ds-modify-item-overview *ngIf="item" [item]="item"></ds-modify-item-overview>
<button class="btn btn-default" (click)="previousPage()">{{'workflow-item.' + type + '.button.cancel' | translate}}</button>
<button class="btn btn-danger" (click)="performAction()">{{'workflow-item.' + type + '.button.confirm' | translate}}</button>
</div>

View File

@@ -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<WorkflowItem>;
public item$: Observable<Item>;
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<WorkflowItem>), getRemoteDataPayload());
this.item$ = this.wfi$.pipe(switchMap((wfi: WorkflowItem) => (wfi.item as Observable<RemoteData<Item>>).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<boolean>;
abstract getType(): string;
}

View File

@@ -1,6 +0,0 @@
<div class="container" *ngVar="item$ | async as item">
<ds-modify-item-overview *ngIf="item" [item]="item"></ds-modify-item-overview>
<button class="btn btn-default" (click)="previousPage()">Cancel</button>
<button class="btn btn-danger" (click)="delete()">Delete</button>
</div>

View File

@@ -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<WorkflowItem>;
public item$: Observable<Item>;
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<WorkflowItem>), getRemoteDataPayload());
this.item$ = this.wfi$.pipe(switchMap((wfi: WorkflowItem) => (wfi.item as Observable<RemoteData<Item>>).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<boolean> {
return this.workflowItemService.delete(id);
}
}

View File

@@ -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<WorkflowItemDeleteComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ WorkflowItemDeleteComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WorkflowItemDeleteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -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<boolean> {
return this.workflowItemService.sendBack(id);
}
}

View File

@@ -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' }
}
]
}]

View File

@@ -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.

View File

@@ -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: {

View File

@@ -1 +1,4 @@
<ds-publication-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType"></ds-publication-search-result-grid-element>
<ds-publication-search-result-grid-element [object]="{ indexableObject: object, hitHighlights: {} }" [linkType]="linkType">
<ng-content></ng-content>
<ng-content></ng-content>
</ds-publication-search-result-grid-element>