Merge pull request #2338 from alexandrevryghem/improve-confirmation-modal_contribute-main

Made ConfirmationModalComponent more generic
This commit is contained in:
Tim Donohue
2024-01-19 16:32:27 -06:00
committed by GitHub
9 changed files with 16 additions and 15 deletions

View File

@@ -201,7 +201,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
deleteEPerson(ePerson: EPerson) { deleteEPerson(ePerson: EPerson) {
if (hasValue(ePerson.id)) { if (hasValue(ePerson.id)) {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = ePerson; modalRef.componentInstance.name = this.dsoNameService.getName(ePerson);
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header'; modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info'; modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel'; modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel';

View File

@@ -478,7 +478,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
take(1), take(1),
switchMap((eperson: EPerson) => { switchMap((eperson: EPerson) => {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = eperson; modalRef.componentInstance.name = this.dsoNameService.getName(eperson);
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header'; modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-eperson.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info'; modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-eperson.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel'; modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-eperson.cancel';

View File

@@ -420,7 +420,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
delete() { delete() {
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((group: Group) => { this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((group: Group) => {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = group; modalRef.componentInstance.name = this.dsoNameService.getName(group);
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-group.modal.header'; modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-group.modal.header';
modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-group.modal.info'; modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-group.modal.info';
modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-group.modal.cancel'; modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-group.modal.cancel';

View File

@@ -124,7 +124,7 @@ export class WorkspaceItemAdminWorkflowActionsComponent implements OnInit {
*/ */
deleteSupervisionOrder(supervisionOrderEntry: SupervisionOrderListEntry) { deleteSupervisionOrder(supervisionOrderEntry: SupervisionOrderListEntry) {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = supervisionOrderEntry.group; modalRef.componentInstance.name = this.dsoNameService.getName(supervisionOrderEntry.group);
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-supervision.modal.header'; modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-supervision.modal.header';
modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-supervision.modal.info'; modalRef.componentInstance.infoLabel = this.messagePrefix + '.delete-supervision.modal.info';
modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-supervision.modal.cancel'; modalRef.componentInstance.cancelLabel = this.messagePrefix + '.delete-supervision.modal.cancel';

View File

@@ -1,18 +1,18 @@
<div> <div>
<div class="modal-header">{{ headerLabel | translate:{ dsoName: dsoNameService.getName(dso) } }} <div class="modal-header">{{ headerLabel | translate:{ dsoName: name } }}
<button type="button" class="close" (click)="close()" aria-label="Close"> <button type="button" class="close" (click)="close()" aria-label="Close">
<span aria-hidden="true">×</span> <span aria-hidden="true">×</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>{{ infoLabel | translate:{ dsoName: dsoNameService.getName(dso) } }}</p> <p>{{ infoLabel | translate:{ dsoName: name } }}</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="cancel btn btn-outline-secondary" (click)="cancelPressed()" aria-label="Cancel"> <button type="button" class="cancel btn btn-outline-secondary" (click)="cancelPressed()" aria-label="Cancel">
<i class="fas fa-times"></i> {{ cancelLabel | translate:{ dsoName: dsoNameService.getName(dso) } }} <i class="fas fa-times"></i> {{ cancelLabel | translate:{ dsoName: name } }}
</button> </button>
<button type="button" class="confirm btn btn-{{brandColor}}" (click)="confirmPressed()" aria-label="Confirm" ngbAutofocus> <button type="button" class="confirm btn btn-{{brandColor}}" (click)="confirmPressed()" aria-label="Confirm" ngbAutofocus>
<i *ngIf="confirmIcon" class="{{confirmIcon}}"></i> {{ confirmLabel | translate:{ dsoName: dsoNameService.getName(dso) } }} <i *ngIf="confirmIcon" class="{{confirmIcon}}"></i> {{ confirmLabel | translate:{ dsoName: name } }}
</button> </button>
</div> </div>
</div> </div>

View File

@@ -1,7 +1,5 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
@Component({ @Component({
selector: 'ds-confirmation-modal', selector: 'ds-confirmation-modal',
@@ -18,7 +16,7 @@ export class ConfirmationModalComponent {
*/ */
@Input() brandColor = 'primary'; @Input() brandColor = 'primary';
@Input() dso: DSpaceObject; @Input() name: string;
/** /**
* An event fired when the cancel or confirm button is clicked, with respectively false or true * An event fired when the cancel or confirm button is clicked, with respectively false or true
@@ -28,7 +26,6 @@ export class ConfirmationModalComponent {
constructor( constructor(
protected activeModal: NgbActiveModal, protected activeModal: NgbActiveModal,
public dsoNameService: DSONameService,
) { ) {
} }

View File

@@ -20,6 +20,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths'; import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths';
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id'; import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
/** /**
* Component to wrap a list of existing dso's inside a modal * Component to wrap a list of existing dso's inside a modal
@@ -38,6 +39,7 @@ export class ExportBatchSelectorComponent extends DSOSelectorModalWrapperCompone
protected notificationsService: NotificationsService, protected translationService: TranslateService, protected notificationsService: NotificationsService, protected translationService: TranslateService,
protected scriptDataService: ScriptDataService, protected scriptDataService: ScriptDataService,
protected authorizationDataService: AuthorizationDataService, protected authorizationDataService: AuthorizationDataService,
protected dsoNameService: DSONameService,
private modalService: NgbModal) { private modalService: NgbModal) {
super(activeModal, route); super(activeModal, route);
} }
@@ -49,7 +51,7 @@ export class ExportBatchSelectorComponent extends DSOSelectorModalWrapperCompone
navigate(dso: DSpaceObject): Observable<boolean> { navigate(dso: DSpaceObject): Observable<boolean> {
if (dso instanceof Collection) { if (dso instanceof Collection) {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = dso; modalRef.componentInstance.name = this.dsoNameService.getName(dso);
modalRef.componentInstance.headerLabel = 'confirmation-modal.export-batch.header'; modalRef.componentInstance.headerLabel = 'confirmation-modal.export-batch.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.export-batch.info'; modalRef.componentInstance.infoLabel = 'confirmation-modal.export-batch.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-batch.cancel'; modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-batch.cancel';

View File

@@ -21,6 +21,7 @@ import { RemoteData } from '../../../../core/data/remote-data';
import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths'; import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths';
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service'; import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id'; import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
/** /**
* Component to wrap a list of existing dso's inside a modal * Component to wrap a list of existing dso's inside a modal
@@ -39,6 +40,7 @@ export class ExportMetadataSelectorComponent extends DSOSelectorModalWrapperComp
protected notificationsService: NotificationsService, protected translationService: TranslateService, protected notificationsService: NotificationsService, protected translationService: TranslateService,
protected scriptDataService: ScriptDataService, protected scriptDataService: ScriptDataService,
protected authorizationDataService: AuthorizationDataService, protected authorizationDataService: AuthorizationDataService,
protected dsoNameService: DSONameService,
private modalService: NgbModal) { private modalService: NgbModal) {
super(activeModal, route); super(activeModal, route);
} }
@@ -50,7 +52,7 @@ export class ExportMetadataSelectorComponent extends DSOSelectorModalWrapperComp
navigate(dso: DSpaceObject): Observable<boolean> { navigate(dso: DSpaceObject): Observable<boolean> {
if (dso instanceof Collection || dso instanceof Community) { if (dso instanceof Collection || dso instanceof Community) {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = dso; modalRef.componentInstance.name = this.dsoNameService.getName(dso);
modalRef.componentInstance.headerLabel = 'confirmation-modal.export-metadata.header'; modalRef.componentInstance.headerLabel = 'confirmation-modal.export-metadata.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.export-metadata.info'; modalRef.componentInstance.infoLabel = 'confirmation-modal.export-metadata.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-metadata.cancel'; modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-metadata.cancel';

View File

@@ -82,7 +82,7 @@ export class SubscriptionViewComponent {
deleteSubscriptionPopup(subscription: Subscription) { deleteSubscriptionPopup(subscription: Subscription) {
if (hasValue(subscription.id)) { if (hasValue(subscription.id)) {
const modalRef = this.modalService.open(ConfirmationModalComponent); const modalRef = this.modalService.open(ConfirmationModalComponent);
modalRef.componentInstance.dso = this.dso; modalRef.componentInstance.name = this.dsoNameService.getName(this.dso);
modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-subscription.header'; modalRef.componentInstance.headerLabel = 'confirmation-modal.delete-subscription.header';
modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-subscription.info'; modalRef.componentInstance.infoLabel = 'confirmation-modal.delete-subscription.info';
modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-subscription.cancel'; modalRef.componentInstance.cancelLabel = 'confirmation-modal.delete-subscription.cancel';