update folder structure based on style guide

This commit is contained in:
Art Lowel
2021-07-23 17:18:51 +02:00
parent 146ec49a32
commit 124845bee1
667 changed files with 280 additions and 280 deletions

View File

@@ -0,0 +1,36 @@
import { first } from 'rxjs/operators';
import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service';
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
import { ItemFromWorkflowResolver } from './item-from-workflow.resolver';
describe('ItemFromWorkflowResolver', () => {
describe('resolve', () => {
let resolver: ItemFromWorkflowResolver;
let wfiService: WorkflowItemDataService;
const uuid = '1234-65487-12354-1235';
const itemUuid = '8888-8888-8888-8888';
const wfi = {
id: uuid,
item: createSuccessfulRemoteDataObject$({ id: itemUuid })
};
beforeEach(() => {
wfiService = {
findById: (id: string) => createSuccessfulRemoteDataObject$(wfi)
} as any;
resolver = new ItemFromWorkflowResolver(wfiService, null);
});
it('should resolve a an item from from the workflow item with the correct id', (done) => {
resolver.resolve({ params: { id: uuid } } as any, undefined)
.pipe(first())
.subscribe(
(resolved) => {
expect(resolved.payload.id).toEqual(itemUuid);
done();
}
);
});
});
});

View File

@@ -0,0 +1,43 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { Item } from '../core/shared/item.model';
import { followLink } from '../shared/utils/follow-link-config.model';
import { getFirstCompletedRemoteData } from '../core/shared/operators';
import { Store } from '@ngrx/store';
import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service';
import { WorkflowItem } from '../core/submission/models/workflowitem.model';
import { switchMap } from 'rxjs/operators';
/**
* This class represents a resolver that requests a specific item before the route is activated
*/
@Injectable()
export class ItemFromWorkflowResolver implements Resolve<RemoteData<Item>> {
constructor(
private workflowItemService: WorkflowItemDataService,
protected store: Store<any>
) {
}
/**
* Method for resolving an item based on the parameters in the current route
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route,
* or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
const itemRD$ = this.workflowItemService.findById(route.params.id,
true,
false,
followLink('item'),
).pipe(
getFirstCompletedRemoteData(),
switchMap((wfiRD: RemoteData<WorkflowItem>) => wfiRD.payload.item as Observable<RemoteData<Item>>),
getFirstCompletedRemoteData()
);
return itemRD$;
}
}

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,124 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { WorkflowItemActionPageComponent } from './workflow-item-action-page.component';
import { NotificationsService } from '../shared/notifications/notifications.service';
import { RouteService } from '../core/services/route.service';
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service';
import { ActivatedRoute, Router } from '@angular/router';
import { WorkflowItem } from '../core/submission/models/workflowitem.model';
import { Observable, of as observableOf } from 'rxjs';
import { VarDirective } from '../shared/utils/var.directive';
import { By } from '@angular/platform-browser';
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock';
import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
import { RouterStub } from '../shared/testing/router.stub';
import { NotificationsServiceStub } from '../shared/testing/notifications-service.stub';
const type = 'testType';
describe('WorkflowItemActionPageComponent', () => {
let component: WorkflowItemActionPageComponent;
let fixture: ComponentFixture<WorkflowItemActionPageComponent>;
let wfiService;
let wfi;
let itemRD$;
let id;
function init() {
wfiService = jasmine.createSpyObj('workflowItemService', {
sendBack: observableOf(true)
});
itemRD$ = createSuccessfulRemoteDataObject$(itemRD$);
wfi = new WorkflowItem();
wfi.item = itemRD$;
id = 'de11b5e5-064a-4e98-a7ac-a1a6a65ddf80';
}
beforeEach(waitForAsync(() => {
init();
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock
}
})],
declarations: [TestComponent, VarDirective],
providers: [
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub({}, { wfi: createSuccessfulRemoteDataObject(wfi) }) },
{ provide: Router, useClass: RouterStub },
{ provide: RouteService, useValue: {} },
{ provide: NotificationsService, useClass: NotificationsServiceStub },
{ provide: WorkflowItemDataService, useValue: wfiService },
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should set the initial type correctly', () => {
expect(component.type).toEqual(type);
});
describe('clicking the button with class btn-danger', () => {
beforeEach(() => {
spyOn(component, 'performAction');
});
it('should call performAction on clicking the btn-danger', () => {
const button = fixture.debugElement.query(By.css('.btn-danger')).nativeElement;
button.click();
fixture.detectChanges();
expect(component.performAction).toHaveBeenCalled();
});
});
describe('clicking the button with class btn-default', () => {
beforeEach(() => {
spyOn(component, 'previousPage');
});
it('should call performAction on clicking the btn-default', () => {
const button = fixture.debugElement.query(By.css('.btn-default')).nativeElement;
button.click();
fixture.detectChanges();
expect(component.previousPage).toHaveBeenCalled();
});
});
});
@Component({
selector: 'ds-workflow-item-test-action-page',
templateUrl: 'workflow-item-action-page.component.html'
}
)
class TestComponent 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 type;
}
sendRequest(id: string): Observable<boolean> {
return observableOf(true);
}
}

View File

@@ -0,0 +1,90 @@
import { Component, 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';
/**
* Abstract component representing a page to perform an action on a workflow item
*/
@Component({
selector: 'ds-workflowitem-action-page',
template: ''
})
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) {
}
/**
* Sets up the type, workflow item and its item object
*/
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())));
}
/**
* Performs the action and shows a notification based on the outcome of the action
*/
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();
});
}
/**
* Navigates to the previous url
* If there's not previous url, it continues to the mydspace page instead
*/
previousPage() {
this.routeService.getPreviousUrl().pipe(take(1))
.subscribe((url) => {
if (isEmpty(url)) {
url = '/mydspace';
}
this.router.navigateByUrl(url);
}
);
}
/**
* Performs the action of this workflow item action page
* @param id The id of the WorkflowItem
*/
abstract sendRequest(id: string): Observable<boolean>;
/**
* Returns the type of page
*/
abstract getType(): string;
}

View File

@@ -0,0 +1,26 @@
import { WorkflowItemDeleteComponent } from './workflow-item-delete.component';
import { ThemedComponent } from '../../shared/theme-support/themed.component';
import { Component } from '@angular/core';
/**
* Themed wrapper for WorkflowItemDeleteComponent
*/
@Component({
selector: 'ds-themed-workflow-item-delete',
styleUrls: [],
templateUrl: './../../shared/theme-support/themed.component.html'
})
export class ThemedWorkflowItemDeleteComponent extends ThemedComponent<WorkflowItemDeleteComponent> {
protected getComponentName(): string {
return 'WorkflowItemDeleteComponent';
}
protected importThemedComponent(themeName: string): Promise<any> {
return import(`../../../themes/${themeName}/app/workflowitems-edit-page/workflow-item-delete/workflow-item-delete.component`);
}
protected importUnthemedComponent(): Promise<any> {
return import(`./workflow-item-delete.component`);
}
}

View File

@@ -0,0 +1,76 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { WorkflowItemDeleteComponent } from './workflow-item-delete.component';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RouteService } from '../../core/services/route.service';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
import { WorkflowItem } from '../../core/submission/models/workflowitem.model';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { VarDirective } from '../../shared/utils/var.directive';
import { of as observableOf } from 'rxjs';
import { RequestService } from '../../core/data/request.service';
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { RouterStub } from '../../shared/testing/router.stub';
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
describe('WorkflowItemDeleteComponent', () => {
let component: WorkflowItemDeleteComponent;
let fixture: ComponentFixture<WorkflowItemDeleteComponent>;
let wfiService;
let wfi;
let itemRD$;
let id;
function init() {
wfiService = jasmine.createSpyObj('workflowItemService', {
delete: observableOf(true)
});
itemRD$ = createSuccessfulRemoteDataObject$(itemRD$);
wfi = new WorkflowItem();
wfi.item = itemRD$;
id = 'de11b5e5-064a-4e98-a7ac-a1a6a65ddf80';
}
beforeEach(waitForAsync(() => {
init();
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock
}
})],
declarations: [WorkflowItemDeleteComponent, VarDirective],
providers: [
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub({}, { wfi: createSuccessfulRemoteDataObject(wfi) }) },
{ provide: Router, useClass: RouterStub },
{ provide: RouteService, useValue: {} },
{ provide: NotificationsService, useClass: NotificationsServiceStub },
{ provide: WorkflowItemDataService, useValue: wfiService },
{ provide: RequestService, useValue: getMockRequestService() },
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WorkflowItemDeleteComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should call delete on the workflow-item service when sendRequest is called', () => {
component.sendRequest(id);
expect(wfiService.delete).toHaveBeenCalledWith(id);
});
});

View File

@@ -0,0 +1,51 @@
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { WorkflowItemActionPageComponent } from '../workflow-item-action-page.component';
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';
import { RequestService } from '../../core/data/request.service';
import { map } from 'rxjs/operators';
import { RemoteData } from '../../core/data/remote-data';
import { NoContent } from '../../core/shared/NoContent.model';
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
@Component({
selector: 'ds-workflow-item-delete',
templateUrl: '../workflow-item-action-page.component.html'
})
/**
* Component representing a page to delete a workflow item
*/
export class WorkflowItemDeleteComponent extends WorkflowItemActionPageComponent {
constructor(protected route: ActivatedRoute,
protected workflowItemService: WorkflowItemDataService,
protected router: Router,
protected routeService: RouteService,
protected notificationsService: NotificationsService,
protected translationService: TranslateService,
protected requestService: RequestService) {
super(route, workflowItemService, router, routeService, notificationsService, translationService);
}
/**
* Returns the type of page
*/
getType(): string {
return 'delete';
}
/**
* Performs the action of this workflow item action page
* @param id The id of the WorkflowItem
*/
sendRequest(id: string): Observable<boolean> {
this.requestService.removeByHrefSubstring('/discover');
return this.workflowItemService.delete(id).pipe(
getFirstCompletedRemoteData(),
map((response: RemoteData<NoContent>) => response.hasSucceeded)
);
}
}

View File

@@ -0,0 +1,30 @@
import { first } from 'rxjs/operators';
import { WorkflowItemPageResolver } from './workflow-item-page.resolver';
import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service';
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
describe('WorkflowItemPageResolver', () => {
describe('resolve', () => {
let resolver: WorkflowItemPageResolver;
let wfiService: WorkflowItemDataService;
const uuid = '1234-65487-12354-1235';
beforeEach(() => {
wfiService = {
findById: (id: string) => createSuccessfulRemoteDataObject$({ id })
} as any;
resolver = new WorkflowItemPageResolver(wfiService);
});
it('should resolve a workflow item with the correct id', (done) => {
resolver.resolve({ params: { id: uuid } } as any, undefined)
.pipe(first())
.subscribe(
(resolved) => {
expect(resolved.payload.id).toEqual(uuid);
done();
}
);
});
});
});

View File

@@ -0,0 +1,34 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { followLink } from '../shared/utils/follow-link-config.model';
import { WorkflowItemDataService } from '../core/submission/workflowitem-data.service';
import { WorkflowItem } from '../core/submission/models/workflowitem.model';
import { getFirstCompletedRemoteData } from '../core/shared/operators';
/**
* This class represents a resolver that requests a specific workflow item before the route is activated
*/
@Injectable()
export class WorkflowItemPageResolver implements Resolve<RemoteData<WorkflowItem>> {
constructor(private workflowItemService: WorkflowItemDataService) {
}
/**
* Method for resolving a workflow item based on the parameters in the current route
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns Observable<<RemoteData<Item>> Emits the found workflow item based on the parameters in the current route,
* or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<WorkflowItem>> {
return this.workflowItemService.findById(route.params.id,
true,
false,
followLink('item'),
).pipe(
getFirstCompletedRemoteData(),
);
}
}

View File

@@ -0,0 +1,26 @@
import { ThemedComponent } from '../../shared/theme-support/themed.component';
import { Component } from '@angular/core';
import { WorkflowItemSendBackComponent } from './workflow-item-send-back.component';
/**
* Themed wrapper for WorkflowItemActionPageComponent
*/
@Component({
selector: 'ds-themed-workflow-item-send-back',
styleUrls: [],
templateUrl: './../../shared/theme-support/themed.component.html'
})
export class ThemedWorkflowItemSendBackComponent extends ThemedComponent<WorkflowItemSendBackComponent> {
protected getComponentName(): string {
return 'WorkflowItemSendBackComponent';
}
protected importThemedComponent(themeName: string): Promise<any> {
return import(`../../../themes/${themeName}/app/workflowitems-edit-page/workflow-item-send-back/workflow-item-send-back.component`);
}
protected importUnthemedComponent(): Promise<any> {
return import(`./workflow-item-send-back.component`);
}
}

View File

@@ -0,0 +1,76 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RouteService } from '../../core/services/route.service';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { WorkflowItemDataService } from '../../core/submission/workflowitem-data.service';
import { WorkflowItem } from '../../core/submission/models/workflowitem.model';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { VarDirective } from '../../shared/utils/var.directive';
import { of as observableOf } from 'rxjs';
import { WorkflowItemSendBackComponent } from './workflow-item-send-back.component';
import { RequestService } from '../../core/data/request.service';
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import { RouterStub } from '../../shared/testing/router.stub';
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
describe('WorkflowItemSendBackComponent', () => {
let component: WorkflowItemSendBackComponent;
let fixture: ComponentFixture<WorkflowItemSendBackComponent>;
let wfiService;
let wfi;
let itemRD$;
let id;
function init() {
wfiService = jasmine.createSpyObj('workflowItemService', {
sendBack: observableOf(true)
});
itemRD$ = createSuccessfulRemoteDataObject$(itemRD$);
wfi = new WorkflowItem();
wfi.item = itemRD$;
id = 'de11b5e5-064a-4e98-a7ac-a1a6a65ddf80';
}
beforeEach(waitForAsync(() => {
init();
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock
}
})],
declarations: [WorkflowItemSendBackComponent, VarDirective],
providers: [
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub({}, { wfi: createSuccessfulRemoteDataObject(wfi) }) },
{ provide: Router, useClass: RouterStub },
{ provide: RouteService, useValue: {} },
{ provide: NotificationsService, useClass: NotificationsServiceStub },
{ provide: WorkflowItemDataService, useValue: wfiService },
{ provide: RequestService, useValue: getMockRequestService() },
],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WorkflowItemSendBackComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should call sendBack on the workflow-item service when sendRequest is called', () => {
component.sendRequest(id);
expect(wfiService.sendBack).toHaveBeenCalledWith(id);
});
});

View File

@@ -0,0 +1,44 @@
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';
import { RequestService } from '../../core/data/request.service';
@Component({
selector: 'ds-workflow-item-send-back',
templateUrl: '../workflow-item-action-page.component.html'
})
/**
* Component representing a page to send back a workflow item to the submitter
*/
export class WorkflowItemSendBackComponent extends WorkflowItemActionPageComponent {
constructor(protected route: ActivatedRoute,
protected workflowItemService: WorkflowItemDataService,
protected router: Router,
protected routeService: RouteService,
protected notificationsService: NotificationsService,
protected translationService: TranslateService,
protected requestService: RequestService) {
super(route, workflowItemService, router, routeService, notificationsService, translationService);
}
/**
* Returns the type of page
*/
getType(): string {
return 'send-back';
}
/**
* Performs the action of this workflow item action page
* @param id The id of the WorkflowItem
*/
sendRequest(id: string): Observable<boolean> {
this.requestService.removeByHrefSubstring('/discover');
return this.workflowItemService.sendBack(id);
}
}

View File

@@ -0,0 +1,26 @@
import { URLCombiner } from '../core/url-combiner/url-combiner';
import { getWorkflowItemModuleRoute } from '../app-routing-paths';
export function getWorkflowItemPageRoute(wfiId: string) {
return new URLCombiner(getWorkflowItemModuleRoute(), wfiId).toString();
}
export function getWorkflowItemEditRoute(wfiId: string) {
return new URLCombiner(getWorkflowItemModuleRoute(), wfiId, WORKFLOW_ITEM_EDIT_PATH).toString();
}
export function getWorkflowItemViewRoute(wfiId: string) {
return new URLCombiner(getWorkflowItemModuleRoute(), wfiId, WORKFLOW_ITEM_VIEW_PATH).toString();
}
export function getWorkflowItemDeleteRoute(wfiId: string) {
return new URLCombiner(getWorkflowItemModuleRoute(), wfiId, WORKFLOW_ITEM_DELETE_PATH).toString();
}
export function getWorkflowItemSendBackRoute(wfiId: string) {
return new URLCombiner(getWorkflowItemModuleRoute(), wfiId, WORKFLOW_ITEM_SEND_BACK_PATH).toString();
}
export const WORKFLOW_ITEM_EDIT_PATH = 'edit';
export const WORKFLOW_ITEM_DELETE_PATH = 'delete';
export const WORKFLOW_ITEM_VIEW_PATH = 'view';
export const WORKFLOW_ITEM_SEND_BACK_PATH = 'sendback';

View File

@@ -0,0 +1,73 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AuthenticatedGuard } from '../core/auth/authenticated.guard';
import { WorkflowItemPageResolver } from './workflow-item-page.resolver';
import {
WORKFLOW_ITEM_DELETE_PATH,
WORKFLOW_ITEM_EDIT_PATH,
WORKFLOW_ITEM_SEND_BACK_PATH,
WORKFLOW_ITEM_VIEW_PATH
} from './workflowitems-edit-page-routing-paths';
import { ThemedSubmissionEditComponent } from '../submission/edit/themed-submission-edit.component';
import { ThemedWorkflowItemDeleteComponent } from './workflow-item-delete/themed-workflow-item-delete.component';
import { ThemedWorkflowItemSendBackComponent } from './workflow-item-send-back/themed-workflow-item-send-back.component';
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
import { ItemFromWorkflowResolver } from './item-from-workflow.resolver';
import { ThemedFullItemPageComponent } from '../item-page/full/themed-full-item-page.component';
@NgModule({
imports: [
RouterModule.forChild([
{
path: ':id',
resolve: { wfi: WorkflowItemPageResolver },
children: [
{
canActivate: [AuthenticatedGuard],
path: WORKFLOW_ITEM_EDIT_PATH,
component: ThemedSubmissionEditComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
},
data: { title: 'workflow-item.edit.title', breadcrumbKey: 'workflow-item.edit' }
},
{
canActivate: [AuthenticatedGuard],
path: WORKFLOW_ITEM_VIEW_PATH,
component: ThemedFullItemPageComponent,
resolve: {
dso: ItemFromWorkflowResolver,
breadcrumb: I18nBreadcrumbResolver
},
data: { title: 'workflow-item.view.title', breadcrumbKey: 'workflow-item.view' }
},
{
canActivate: [AuthenticatedGuard],
path: WORKFLOW_ITEM_DELETE_PATH,
component: ThemedWorkflowItemDeleteComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
},
data: { title: 'workflow-item.delete.title', breadcrumbKey: 'workflow-item.edit' }
},
{
canActivate: [AuthenticatedGuard],
path: WORKFLOW_ITEM_SEND_BACK_PATH,
component: ThemedWorkflowItemSendBackComponent,
resolve: {
breadcrumb: I18nBreadcrumbResolver
},
data: { title: 'workflow-item.send-back.title', breadcrumbKey: 'workflow-item.edit' }
}
]
}]
)
],
providers: [WorkflowItemPageResolver, ItemFromWorkflowResolver]
})
/**
* This module defines the default component to load when navigating to the workflowitems edit page path.
*/
export class WorkflowItemsEditPageRoutingModule {
}

View File

@@ -0,0 +1,34 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
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';
import { ThemedWorkflowItemDeleteComponent } from './workflow-item-delete/themed-workflow-item-delete.component';
import { ThemedWorkflowItemSendBackComponent } from './workflow-item-send-back/themed-workflow-item-send-back.component';
import { StatisticsModule } from '../statistics/statistics.module';
import { ItemPageModule } from '../item-page/item-page.module';
@NgModule({
imports: [
WorkflowItemsEditPageRoutingModule,
CommonModule,
SharedModule,
SubmissionModule,
StatisticsModule,
ItemPageModule
],
declarations: [
WorkflowItemDeleteComponent,
ThemedWorkflowItemDeleteComponent,
WorkflowItemSendBackComponent,
ThemedWorkflowItemSendBackComponent
]
})
/**
* This module handles all modules that need to access the workflowitems edit page.
*/
export class WorkflowItemsEditPageModule {
}