mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
Add Item Status Edit Actions
Add the Item Withdraw and Reistate action Add the make Item Private and Public action Add the Permanently Delete action
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {RestResponse} from '../../../core/cache/response-cache.models';
|
||||
import {AbstractSimpleItemActionComponent} from '../simple-item-action/abstract-simple-item-action.component';
|
||||
import {getItemEditPath} from '../../item-page-routing.module';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-delete',
|
||||
templateUrl: '../simple-item-action/abstract-simple-item-action.component.html'
|
||||
})
|
||||
/**
|
||||
* Component responsible for rendering the item delete page
|
||||
*/
|
||||
export class ItemDeleteComponent extends AbstractSimpleItemActionComponent {
|
||||
|
||||
protected messageKey = 'delete';
|
||||
|
||||
/**
|
||||
* Perform the delete action to the item
|
||||
*/
|
||||
performAction() {
|
||||
this.itemDataService.delete(this.item.id).pipe(first()).subscribe(
|
||||
(response: RestResponse) => {
|
||||
this.processRestResponse(response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the RestResponse retrieved from the server.
|
||||
* When the item is successfully delete, navigate to the homepage, otherwise navigate back to the item edit page
|
||||
* @param response
|
||||
*/
|
||||
processRestResponse(response: RestResponse) {
|
||||
if (response.isSuccessful) {
|
||||
this.notificationsService.success(this.translateService.get('item.edit.' + this.messageKey + '.success'));
|
||||
this.router.navigate(['']);
|
||||
} else {
|
||||
this.notificationsService.error(this.translateService.get('item.edit.' + this.messageKey + '.error'));
|
||||
this.router.navigate([getItemEditPath(this.item.id)]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user