mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
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 { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
|
import { NotificationsService } from '../../notifications/notifications.service';
|
|
|
|
/**
|
|
* This component represents actions related to WorkspaceItem object.
|
|
*/
|
|
@Component({
|
|
selector: 'ds-workspaceitem-actions',
|
|
styleUrls: ['./workspaceitem-actions.component.scss'],
|
|
templateUrl: './workspaceitem-actions.component.html',
|
|
})
|
|
export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent<WorkspaceItem, WorkspaceitemDataService> {
|
|
|
|
/**
|
|
* The workspaceitem object
|
|
*/
|
|
@Input() object: WorkspaceItem;
|
|
|
|
/**
|
|
* A boolean representing if a delete operation is pending
|
|
* @type {BehaviorSubject<boolean>}
|
|
*/
|
|
public processingDelete$ = new BehaviorSubject<boolean>(false);
|
|
|
|
/**
|
|
* Initialize instance variables
|
|
*
|
|
* @param {Injector} injector
|
|
* @param {Router} router
|
|
* @param {NgbModal} modalService
|
|
* @param {NotificationsService} notificationsService
|
|
* @param {TranslateService} translate
|
|
*/
|
|
constructor(protected injector: Injector,
|
|
protected router: Router,
|
|
protected modalService: NgbModal,
|
|
protected notificationsService: NotificationsService,
|
|
protected translate: TranslateService) {
|
|
super(WorkspaceItem.type, injector, router, notificationsService, translate);
|
|
}
|
|
|
|
/**
|
|
* Delete the target workspaceitem object
|
|
*/
|
|
public confirmDiscard(content) {
|
|
this.modalService.open(content).result.then(
|
|
(result) => {
|
|
if (result === 'ok') {
|
|
this.processingDelete$.next(true);
|
|
this.objectDataService.delete(this.object)
|
|
.subscribe((response: boolean) => {
|
|
this.processingDelete$.next(false);
|
|
this.handleActionResponse(response);
|
|
})
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Init the target object
|
|
*
|
|
* @param {WorkspaceItem} object
|
|
*/
|
|
initObjects(object: WorkspaceItem) {
|
|
this.object = object;
|
|
}
|
|
|
|
}
|