mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 20:43:08 +00:00
Added mydspace actions components
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<button type="button"
|
||||
[className]="'btn btn-success ' + wrapperClass"
|
||||
ngbTooltip="{{'submission.workflow.tasks.claimed.approve_help' | translate}}"
|
||||
[disabled]="processingApprove"
|
||||
(click)="click()">
|
||||
<span *ngIf="processingApprove"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!processingApprove"><i class="fa fa-thumbs-up"></i> {{'submission.workflow.tasks.claimed.approve' | translate}}</span>
|
||||
</button>
|
@@ -0,0 +1,19 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-task-actions-approve',
|
||||
styleUrls: ['./claimed-task-actions-approve.component.scss'],
|
||||
templateUrl: './claimed-task-actions-approve.component.html',
|
||||
})
|
||||
|
||||
export class ClaimedTaskActionsApproveComponent {
|
||||
@Input() processingApprove: boolean;
|
||||
@Input() taskId: string;
|
||||
@Input() wrapperClass: string;
|
||||
|
||||
@Output() approve: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
click() {
|
||||
this.approve.emit();
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
|
||||
<a [class.disabled]="!(object.workflowitem | async)?.hasSucceeded"
|
||||
class="btn btn-primary mt-1 mb-3"
|
||||
ngbTooltip="{{'submission.workflow.tasks.claimed.edit_help' | translate}}"
|
||||
[routerLink]="['/workflowitems/' + (object.workflowitem | async)?.payload.id + '/' + object.id + '/edit']"
|
||||
role="button">
|
||||
<i class="fa fa-edit"></i> {{'submission.workflow.tasks.claimed.edit' | translate}}
|
||||
</a>
|
||||
|
||||
<ds-claimed-task-actions-approve [processingApprove]="(processingApprove$ | async)"
|
||||
[taskId]="object.id"
|
||||
[wrapperClass]="'mt-1 mb-3'"
|
||||
(approve)="approve()"></ds-claimed-task-actions-approve>
|
||||
|
||||
<ds-claimed-task-actions-reject [processingReject]="(processingReject$ | async)"
|
||||
[taskId]="object.id"
|
||||
[wrapperClass]="'mt-1 mb-3'"
|
||||
(reject)="reject($event)"></ds-claimed-task-actions-reject>
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-secondary mt-1 mb-3"
|
||||
ngbTooltip="{{'submission.workflow.tasks.claimed.return_help' | translate}}"
|
||||
[disabled]="(processingReturnToPool$ | async)"
|
||||
(click)="returnToPool()">
|
||||
<span *ngIf="(processingReturnToPool$ | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!(processingReturnToPool$ | async)"><i class="fa fa-undo"></i> {{'submission.workflow.tasks.claimed.return' | translate}}</span>
|
||||
</button>
|
||||
|
||||
<ds-message-board
|
||||
[dso]="workflowitem$ | async"
|
||||
[tooltipMessage]="'mydspace.messages.controller-help'"
|
||||
(refresh)="refresh()">
|
||||
</ds-message-board>
|
@@ -0,0 +1,94 @@
|
||||
import { ChangeDetectorRef, Component, Injector, Input, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { ClaimedTask } from '../../../core/tasks/models/claimed-task-object.model';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationOptions } from '../../notifications/models/notification-options.model';
|
||||
import { isNotUndefined } from '../../empty.util';
|
||||
import { Workflowitem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { NormalizedClaimedTask } from '../../../core/tasks/models/normalized-claimed-task-object.model';
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-task-actions',
|
||||
styleUrls: ['./claimed-task-actions.component.scss'],
|
||||
templateUrl: './claimed-task-actions.component.html',
|
||||
})
|
||||
|
||||
export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<ClaimedTask, NormalizedClaimedTask, ClaimedTaskDataService> implements OnInit {
|
||||
@Input() object: ClaimedTask;
|
||||
|
||||
public workflowitem$: Observable<Workflowitem>;
|
||||
|
||||
public processingApprove$ = new BehaviorSubject<boolean>(false);
|
||||
public processingReject$ = new BehaviorSubject<boolean>(false);
|
||||
public processingReturnToPool$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
constructor(protected injector: Injector,
|
||||
protected router: Router,
|
||||
private cd: ChangeDetectorRef,
|
||||
private notificationsService: NotificationsService,
|
||||
private translate: TranslateService) {
|
||||
super(ResourceType.ClaimedTask, injector, router)
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.initObjects(this.object);
|
||||
}
|
||||
|
||||
initObjects(object: ClaimedTask) {
|
||||
this.object = object;
|
||||
this.workflowitem$ = (this.object.workflowitem as Observable<RemoteData<Workflowitem>>).pipe(
|
||||
filter((rd: RemoteData<Workflowitem>) => ((!rd.isRequestPending) && isNotUndefined(rd.payload))),
|
||||
map((rd: RemoteData<Workflowitem>) => rd.payload));
|
||||
}
|
||||
|
||||
approve() {
|
||||
this.processingApprove$.next(true);
|
||||
this.objectDataService.approveTask(this.object.id)
|
||||
.subscribe((res: ProcessTaskResponse) => {
|
||||
this.responseHandle(res);
|
||||
});
|
||||
}
|
||||
|
||||
reject(reason) {
|
||||
this.processingReject$.next(true);
|
||||
this.objectDataService.rejectTask(reason, this.object.id)
|
||||
.subscribe((res: ProcessTaskResponse) => {
|
||||
this.responseHandle(res);
|
||||
});
|
||||
}
|
||||
|
||||
returnToPool() {
|
||||
this.processingReturnToPool$.next(true);
|
||||
this.objectDataService.returnToPoolTask(this.object.id)
|
||||
.subscribe((res: ProcessTaskResponse) => {
|
||||
this.responseHandle(res);
|
||||
});
|
||||
}
|
||||
|
||||
private responseHandle(res: ProcessTaskResponse) {
|
||||
this.processingApprove$.next(false);
|
||||
this.processingReject$.next(false);
|
||||
this.processingReturnToPool$.next(false);
|
||||
if (res.hasSucceeded) {
|
||||
this.reload();
|
||||
this.notificationsService.success(null,
|
||||
this.translate.get('submission.workflow.tasks.generic.success'),
|
||||
new NotificationOptions(5000, false));
|
||||
} else {
|
||||
this.notificationsService.error(null,
|
||||
this.translate.get('submission.workflow.tasks.generic.error'),
|
||||
new NotificationOptions(20000, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
<ng-template #rejectTipContent><p [innerHTML]="'submission.workflow.tasks.claimed.reject_help' | translate"></p></ng-template>
|
||||
<button [className]="'btn btn-danger ' + wrapperClass"
|
||||
[ngbTooltip]="rejectTipContent"
|
||||
[disabled]="processingReject"
|
||||
(click)="openRejectModal(rejectModal)" >
|
||||
<span *ngIf="processingReject"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!processingReject"><i class="fa fa-trash"></i> {{'submission.workflow.tasks.claimed.reject.submit' | translate}}</span>
|
||||
</button>
|
||||
|
||||
<ng-template #rejectModal let-c="close" let-d="dismiss">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{'submission.workflow.tasks.claimed.reject.reason.title' | translate}}</h4>
|
||||
<button type="button"
|
||||
class="close"
|
||||
aria-label="Close"
|
||||
(click)="d('Cross click')">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-info" role="alert">
|
||||
{{'submission.workflow.tasks.claimed.reject.reason.info' | translate}}
|
||||
</div>
|
||||
<form (ngSubmit)="click(rejectModal);" [formGroup]="rejectForm" >
|
||||
<textarea
|
||||
style="width: 100%"
|
||||
formControlName="reason"
|
||||
rows="4"
|
||||
placeholder="{{'submission.workflow.tasks.claimed.reject.reason.placeholder' | translate}}"></textarea>
|
||||
<button
|
||||
id="btn-chat"
|
||||
class="btn btn-danger btn-lg btn-block mt-3"
|
||||
[disabled]="!rejectForm.valid || processingReject"
|
||||
type="submit">
|
||||
<span *ngIf="processingReject"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!processingReject">{{'submission.workflow.tasks.claimed.reject.reason.submit' | translate}}</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</ng-template>
|
@@ -0,0 +1,43 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-task-actions-reject',
|
||||
styleUrls: ['./claimed-task-actions-reject.component.scss'],
|
||||
templateUrl: './claimed-task-actions-reject.component.html',
|
||||
})
|
||||
|
||||
export class ClaimedTaskActionsRejectComponent implements OnInit {
|
||||
@Input() processingReject: boolean;
|
||||
@Input() taskId: string;
|
||||
@Input() wrapperClass: string;
|
||||
|
||||
@Output() reject: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
||||
public rejectForm: FormGroup;
|
||||
public modalRef: NgbModalRef;
|
||||
|
||||
constructor(private formBuilder: FormBuilder, private modalService: NgbModal) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.rejectForm = this.formBuilder.group({
|
||||
reason: ['', Validators.required]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
click() {
|
||||
this.processingReject = true;
|
||||
this.modalRef.close('Send Button');
|
||||
const reason = this.rejectForm.get('reason').value;
|
||||
this.reject.emit(reason);
|
||||
}
|
||||
|
||||
openRejectModal(rejectModal) {
|
||||
this.rejectForm.reset();
|
||||
this.modalRef = this.modalService.open(rejectModal);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
<a class="btn btn-light mt-1 mb-3"
|
||||
role="button"
|
||||
ngbTooltip="{{'submission.workflow.generic.view-help' | translate}}"
|
||||
[href]="itemUrl">
|
||||
<i class="fa fa-info-circle"></i> {{"submission.workflow.generic.view" | translate}}
|
||||
</a>
|
||||
<!--<button class="btn btn-primary mt-1 mb-3"-->
|
||||
<!--ngbTooltip="{{'submission.workflow.generic.view-help' | translate}}"-->
|
||||
<!--[routerLink]="['/items/' + object.id]">-->
|
||||
<!--<i class="fa fa-info-circle"></i> {{"submission.workflow.generic.view" | translate}}-->
|
||||
<!--</button>-->
|
@@ -0,0 +1,40 @@
|
||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
||||
import { NormalizedItem } from '../../../core/cache/models/normalized-item.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { RoleService } from '../../../core/roles/role.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-actions',
|
||||
styleUrls: ['./item-actions.component.scss'],
|
||||
templateUrl: './item-actions.component.html',
|
||||
})
|
||||
|
||||
export class ItemActionsComponent extends MyDSpaceActionsComponent<Item, NormalizedItem, ItemDataService> implements OnInit {
|
||||
@Input() object: Item;
|
||||
|
||||
public isAdmin: Observable<boolean>;
|
||||
public itemUrl: string;
|
||||
|
||||
constructor(protected injector: Injector,
|
||||
protected roleService: RoleService,
|
||||
protected router: Router) {
|
||||
super(ResourceType.Workspaceitem, injector, router);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.isAdmin = this.roleService.isAdmin();
|
||||
this.itemUrl = this.object.firstMetadataValue('dc.identifier.uri');
|
||||
}
|
||||
|
||||
initObjects(object: Item) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
import { DataService } from '../../core/data/data.service';
|
||||
import { ResourceType } from '../../core/shared/resource-type';
|
||||
import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-data.service';
|
||||
import { ClaimedTaskDataService } from '../../core/tasks/claimed-task-data.service';
|
||||
import { PoolTaskDataService } from '../../core/tasks/pool-task-data.service';
|
||||
import { WorkflowitemDataService } from '../../core/submission/workflowitem-data.service';
|
||||
import { NormalizedObject } from '../../core/cache/models/normalized-object.model';
|
||||
import { CacheableObject } from '../../core/cache/object-cache.reducer';
|
||||
|
||||
export class MydspaceActionsServiceFactory<T extends CacheableObject, TNormalized extends NormalizedObject, TService extends DataService<TNormalized, T>> {
|
||||
public getConstructor(type: ResourceType): TService {
|
||||
switch (type) {
|
||||
case ResourceType.Workspaceitem: {
|
||||
return WorkspaceitemDataService as any;
|
||||
}
|
||||
case ResourceType.Workflowitem: {
|
||||
return WorkflowitemDataService as any;
|
||||
}
|
||||
case ResourceType.ClaimedTask: {
|
||||
return ClaimedTaskDataService as any;
|
||||
}
|
||||
case ResourceType.PoolTask: {
|
||||
return PoolTaskDataService as any;
|
||||
}
|
||||
default: {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
src/app/shared/mydspace-actions/mydspace-actions.ts
Normal file
42
src/app/shared/mydspace-actions/mydspace-actions.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Router } from '@angular/router';
|
||||
import { Injector, Input } from '@angular/core';
|
||||
|
||||
import { find } from 'rxjs/operators';
|
||||
|
||||
import { MydspaceActionsServiceFactory } from './mydspace-actions-service.factory';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { NormalizedObject } from '../../core/cache/models/normalized-object.model';
|
||||
import { DataService } from '../../core/data/data.service';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { ResourceType } from '../../core/shared/resource-type';
|
||||
|
||||
export abstract class MyDSpaceActionsComponent<T extends DSpaceObject, TNormalized extends NormalizedObject, TService extends DataService<TNormalized, T>> {
|
||||
@Input() abstract object: T;
|
||||
protected objectDataService: TService;
|
||||
|
||||
constructor(protected objectType: ResourceType, protected injector: Injector, protected router: Router) {
|
||||
const factory = new MydspaceActionsServiceFactory<T, TNormalized, TService>();
|
||||
this.objectDataService = injector.get(factory.getConstructor(objectType));
|
||||
}
|
||||
|
||||
abstract initObjects(object: T): void;
|
||||
|
||||
reload() {
|
||||
// override the route reuse strategy
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => {
|
||||
return false;
|
||||
};
|
||||
this.router.navigated = false;
|
||||
const url = decodeURIComponent(this.router.url);
|
||||
this.router.navigateByUrl(url);
|
||||
}
|
||||
|
||||
refresh() {
|
||||
// override the object with a refreshed one
|
||||
this.objectDataService.findById(this.object.id).pipe(
|
||||
find((rd: RemoteData<T>) => rd.hasSucceeded)
|
||||
).subscribe((rd: RemoteData<T>) => {
|
||||
this.initObjects(rd.payload as T);
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
<ng-content></ng-content>
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-info mt-1 mb-3"
|
||||
ngbTooltip="{{'submission.workflow.tasks.pool.claim_help' | translate}}"
|
||||
[disabled]="(processingClaim$ | async)"
|
||||
(click)="claim()">
|
||||
<span *ngIf="(processingClaim$ | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!(processingClaim$ | async)"><i class="fa fa-hand-paper-o"></i> {{'submission.workflow.tasks.pool.claim' | translate}}</span>
|
||||
</button>
|
||||
|
||||
<ds-message-board
|
||||
[dso]="workflowitem$ | async"
|
||||
[tooltipMessage]="'mydspace.messages.controller-help'"
|
||||
(refresh)="refresh()">
|
||||
</ds-message-board>
|
||||
|
@@ -0,0 +1,73 @@
|
||||
import { Component, Injector, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { Workflowitem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-response';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PoolTask } from '../../../core/tasks/models/pool-task-object.model';
|
||||
import { PoolTaskDataService } from '../../../core/tasks/pool-task-data.service';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationOptions } from '../../notifications/models/notification-options.model';
|
||||
import { isNotUndefined } from '../../empty.util';
|
||||
import { NormalizedPoolTask } from '../../../core/tasks/models/normalized-pool-task-object.model';
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-pool-task-actions',
|
||||
styleUrls: ['./pool-task-actions.component.scss'],
|
||||
templateUrl: './pool-task-actions.component.html',
|
||||
})
|
||||
|
||||
export class PoolTaskActionsComponent extends MyDSpaceActionsComponent<PoolTask, NormalizedPoolTask, PoolTaskDataService> {
|
||||
@Input() object: PoolTask;
|
||||
|
||||
public processingClaim$ = new BehaviorSubject<boolean>(false);
|
||||
public workflowitem$: Observable<Workflowitem>;
|
||||
|
||||
constructor(protected injector: Injector,
|
||||
protected router: Router,
|
||||
private notificationsService: NotificationsService,
|
||||
private translate: TranslateService) {
|
||||
super(ResourceType.PoolTask, injector, router);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.initObjects(this.object);
|
||||
}
|
||||
|
||||
initObjects(object: PoolTask) {
|
||||
this.object = object;
|
||||
this.workflowitem$ = (this.object.workflowitem as Observable<RemoteData<Workflowitem>>).pipe(
|
||||
filter((rd: RemoteData<Workflowitem>) => ((!rd.isRequestPending) && isNotUndefined(rd.payload))),
|
||||
map((rd: RemoteData<Workflowitem>) => rd.payload));
|
||||
}
|
||||
|
||||
claim() {
|
||||
this.processingClaim$.next(true);
|
||||
this.objectDataService.claimTask(this.object.id)
|
||||
.subscribe((res: ProcessTaskResponse) => {
|
||||
this.responseHandle(res);
|
||||
});
|
||||
}
|
||||
|
||||
private responseHandle(res: ProcessTaskResponse) {
|
||||
if (res.hasSucceeded) {
|
||||
this.processingClaim$.next(false);
|
||||
this.reload();
|
||||
this.notificationsService.success(null,
|
||||
this.translate.get('submission.workflow.tasks.generic.success'),
|
||||
new NotificationOptions(5000, false));
|
||||
} else {
|
||||
this.processingClaim$.next(false);
|
||||
this.notificationsService.error(null,
|
||||
this.translate.get('submission.workflow.tasks.generic.error'),
|
||||
new NotificationOptions(20000, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<ds-message-board *ngIf="object && object.item && object.submitter"
|
||||
[dso]="object"
|
||||
[tooltipMessage]="'mydspace.messages.submitter-help'"
|
||||
(refresh)="refresh()">
|
||||
</ds-message-board>
|
@@ -0,0 +1,27 @@
|
||||
import { Component, Injector, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { Workflowitem } from '../../../core/submission/models/workflowitem.model';
|
||||
import { NormalizedWorkflowItem } from '../../../core/submission/models/normalized-workflowitem.model';
|
||||
import { WorkflowitemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-workflowitem-actions',
|
||||
styleUrls: ['./workflowitem-actions.component.scss'],
|
||||
templateUrl: './workflowitem-actions.component.html',
|
||||
})
|
||||
|
||||
export class WorkflowitemActionsComponent extends MyDSpaceActionsComponent<Workflowitem, NormalizedWorkflowItem, WorkflowitemDataService> {
|
||||
@Input() object: Workflowitem;
|
||||
|
||||
constructor(protected injector: Injector,
|
||||
protected router: Router) {
|
||||
super(ResourceType.Workflowitem, injector, router);
|
||||
}
|
||||
|
||||
initObjects(object: Workflowitem) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<a class="btn btn-primary mt-1 mb-3"
|
||||
ngbTooltip="{{'submission.workflow.generic.edit-help' | translate}}"
|
||||
[routerLink]="['/workspaceitems/' + object.id + '/edit']"
|
||||
role="button">
|
||||
<i class="fa fa-edit"></i> {{'submission.workflow.generic.edit' | translate}}
|
||||
</a>
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-danger mt-1 mb-3"
|
||||
ngbTooltip="{{'submission.workflow.generic.delete-help' | translate}}"
|
||||
(click)="$event.preventDefault();confirmDiscard(content)">
|
||||
<span *ngIf="(processingDelete$ | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
|
||||
<span *ngIf="!(processingDelete$ | async)"><i class="fa fa-trash"></i> {{'submission.workflow.generic.delete' | translate}}</span>
|
||||
</button>
|
||||
|
||||
<ds-message-board *ngIf="object && object.item && object.submitter"
|
||||
[dso]="object"
|
||||
[tooltipMessage]="'mydspace.messages.submitter-help'"
|
||||
(refresh)="refresh()">
|
||||
</ds-message-board>
|
||||
|
||||
<ng-template #content let-c="close" let-d="dismiss">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title text-danger">{{'submission.general.discard.confirm.title' | translate}}</h4>
|
||||
<button type="button" class="close" aria-label="Close" (click)="d('cancel')">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{'submission.general.discard.confirm.info' | translate}}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" (click)="c('cancel')">{{'submission.general.discard.confirm.cancel' | translate}}</button>
|
||||
<button type="button" class="btn btn-danger" (click)="c('ok')">{{'submission.general.discard.confirm.submit' | translate}}</button>
|
||||
</div>
|
||||
</ng-template>
|
@@ -0,0 +1,59 @@
|
||||
import { Component, Injector, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { Workspaceitem } from '../../../core/submission/models/workspaceitem.model';
|
||||
import { MyDSpaceActionsComponent } from '../mydspace-actions';
|
||||
import { NormalizedWorkspaceItem } from '../../../core/submission/models/normalized-workspaceitem.model';
|
||||
import { SubmissionRestService } from '../../../submission/submission-rest.service';
|
||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
import { NotificationsService } from '../../notifications/notifications.service';
|
||||
import { NotificationOptions } from '../../notifications/models/notification-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-workspaceitem-actions',
|
||||
styleUrls: ['./workspaceitem-actions.component.scss'],
|
||||
templateUrl: './workspaceitem-actions.component.html',
|
||||
})
|
||||
|
||||
export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent<Workspaceitem, NormalizedWorkspaceItem, WorkspaceitemDataService> {
|
||||
@Input() object: Workspaceitem;
|
||||
|
||||
public processingDelete$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
constructor(protected injector: Injector,
|
||||
protected router: Router,
|
||||
private modalService: NgbModal,
|
||||
private notificationsService: NotificationsService,
|
||||
private restService: SubmissionRestService,
|
||||
private translate: TranslateService) {
|
||||
super(ResourceType.Workspaceitem, injector, router);
|
||||
}
|
||||
|
||||
public confirmDiscard(content) {
|
||||
this.modalService.open(content).result.then(
|
||||
(result) => {
|
||||
if (result === 'ok') {
|
||||
this.processingDelete$.next(true);
|
||||
this.restService.deleteById(this.object.id)
|
||||
.subscribe(() => {
|
||||
this.notificationsService.success(null,
|
||||
this.translate.get('submission.workflow.tasks.generic.success'),
|
||||
new NotificationOptions(5000, false));
|
||||
this.processingDelete$.next(false);
|
||||
this.reload();
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
initObjects(object: Workspaceitem) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user