Skip to content

Commit 7a80307

Browse files
author
Andrea Barbasso
committed
[DSC-2424] fix modal name and body missing dso name
1 parent 442d34b commit 7a80307

4 files changed

Lines changed: 37 additions & 11 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<div>
2-
<div class="modal-header">{{ headerLabel | translate:{ dsoName: dsoNameService.getName(dso) } }}
2+
<div class="modal-header">{{ headerLabel | translate:{ dsoName: name } }}
33
<button type="button" class="close" (click)="close()" aria-label="Close">
44
<span aria-hidden="true">×</span>
55
</button>
66
</div>
77
<div class="modal-body">
8-
<p>{{ infoLabel | translate:{ dsoName: dsoNameService.getName(dso) } }}</p>
8+
<p>{{ infoLabel | translate:{ dsoName: name } }}</p>
99
</div>
1010
<div class="modal-footer">
1111
<button type="button" class="cancel btn btn-outline-secondary" (click)="cancelPressed()" aria-label="Cancel">
12-
<i class="fas fa-times"></i> {{ cancelLabel | translate:{ dsoName: dsoNameService.getName(dso) } }}
12+
<i class="fas fa-times"></i> {{ cancelLabel | translate:{ dsoName: name } }}
1313
</button>
1414
<button type="button" class="confirm btn btn-{{brandColor}}" (click)="confirmPressed()" aria-label="Confirm" ngbAutofocus>
15-
<i *ngIf="confirmIcon" class="{{confirmIcon}}"></i> {{ confirmLabel | translate:{ dsoName: dsoNameService.getName(dso) } }}
15+
<i *ngIf="confirmIcon" class="{{confirmIcon}}"></i> {{ confirmLabel | translate:{ dsoName: name } }}
1616
</button>
1717
</div>
1818
</div>

src/app/shared/confirmation-modal/confirmation-modal.component.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,32 @@ describe('ConfirmationModalComponent', () => {
132132
});
133133
});
134134

135+
describe('displaying the name in the modal', () => {
136+
const testName = 'Test Name';
137+
beforeEach(() => {
138+
component.name = testName;
139+
component.headerLabel = `Header: ${component.name}`;
140+
component.infoLabel = `Info: ${component.name}`;
141+
component.cancelLabel = `Cancel: ${component.name}`;
142+
component.confirmLabel = `Confirm: ${component.name}`;
143+
fixture.detectChanges();
144+
});
145+
it('should display the name in the header', () => {
146+
const header = debugElement.query(By.css('.modal-header')).nativeElement.textContent;
147+
expect(header).toContain(testName);
148+
});
149+
it('should display the name in the body', () => {
150+
const body = debugElement.query(By.css('.modal-body')).nativeElement.textContent;
151+
expect(body).toContain(testName);
152+
});
153+
it('should display the name in the cancel button', () => {
154+
const cancelBtn = debugElement.query(By.css('button.cancel')).nativeElement.textContent;
155+
expect(cancelBtn).toContain(testName);
156+
});
157+
it('should display the name in the confirm button', () => {
158+
const confirmBtn = debugElement.query(By.css('button.confirm')).nativeElement.textContent;
159+
expect(confirmBtn).toContain(testName);
160+
});
161+
});
162+
135163
});

src/app/shared/confirmation-modal/confirmation-modal.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import {
88
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
99
import { TranslateModule } from '@ngx-translate/core';
1010

11-
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
12-
import { DSpaceObject } from '../../core/shared/dspace-object.model';
13-
1411
@Component({
1512
selector: 'ds-confirmation-modal',
1613
templateUrl: 'confirmation-modal.component.html',
@@ -28,7 +25,7 @@ export class ConfirmationModalComponent {
2825
*/
2926
@Input() brandColor = 'primary';
3027

31-
@Input() dso: DSpaceObject;
28+
@Input() name: string;
3229

3330
/**
3431
* An event fired when the cancel or confirm button is clicked, with respectively false or true
@@ -38,7 +35,6 @@ export class ConfirmationModalComponent {
3835

3936
constructor(
4037
protected activeModal: NgbActiveModal,
41-
public dsoNameService: DSONameService,
4238
) {
4339
}
4440

src/app/shared/dso-selector/modal-wrappers/export-metadata-xls-selector/export-metadata-xls-selector.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
switchMap,
2525
} from 'rxjs/operators';
2626

27+
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
2728
import {
2829
COLLECTION_EXPORT_SCRIPT_NAME,
2930
ScriptDataService,
@@ -65,7 +66,8 @@ export class ExportMetadataXlsSelectorComponent extends DSOSelectorModalWrapperC
6566
constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router,
6667
protected notificationsService: NotificationsService, protected translationService: TranslateService,
6768
protected scriptDataService: ScriptDataService,
68-
private modalService: NgbModal) {
69+
private modalService: NgbModal,
70+
private dsoNameService: DSONameService) {
6971
super(activeModal, route);
7072
}
7173

@@ -76,7 +78,7 @@ export class ExportMetadataXlsSelectorComponent extends DSOSelectorModalWrapperC
7678
navigate(dso: DSpaceObject): Observable<boolean> {
7779
if (dso instanceof Collection) {
7880
const modalRef = this.modalService.open(ConfirmationModalComponent);
79-
modalRef.componentInstance.dso = dso;
81+
modalRef.componentInstance.name = this.dsoNameService.getName(dso);
8082
modalRef.componentInstance.headerLabel = 'confirmation-modal.export-metadata-xls.header';
8183
modalRef.componentInstance.infoLabel = 'confirmation-modal.export-metadata-xls.info';
8284
modalRef.componentInstance.cancelLabel = 'confirmation-modal.export-metadata-xls.cancel';

0 commit comments

Comments
 (0)