Skip to content

Commit

Permalink
Make ConfirmationModalComponent work with both dso & non dso, eg Subs…
Browse files Browse the repository at this point in the history
…criptionViewComponent didn't define name yet, but dso, both should be ok, depending on which is available

DSpace#2338
  • Loading branch information
MarieVerdonck committed Apr 3, 2024
1 parent 822db51 commit 75f6097
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
import { hasValue } from '../empty.util';
import { OnInit } from '@angular/core';

@Component({
selector: 'ds-confirmation-modal',
templateUrl: 'confirmation-modal.component.html',
})
export class ConfirmationModalComponent {
export class ConfirmationModalComponent implements OnInit {
@Input() headerLabel: string;
@Input() infoLabel: string;
@Input() cancelLabel: string;
Expand All @@ -16,6 +20,8 @@ export class ConfirmationModalComponent {
*/
@Input() brandColor = 'primary';

@Input() dso: DSpaceObject;
// To also use ConfirmationModalComponent when not for DSO
@Input() name: string;

/**
Expand All @@ -26,9 +32,16 @@ export class ConfirmationModalComponent {

constructor(
protected activeModal: NgbActiveModal,
protected dsoNameService: DSONameService
) {
}

ngOnInit() {
if (!hasValue(this.name) && hasValue(this.dso)) {
this.name = this.dsoNameService.getName(this.dso);
}
}

/**
* Confirm the action that led to the modal
*/
Expand Down

0 comments on commit 75f6097

Please sign in to comment.