mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
Modal outputs as EventEmitters instead of Subjects
This commit is contained in:
@@ -46,27 +46,27 @@ describe('ConfirmationModalComponent', () => {
|
|||||||
|
|
||||||
describe('confirmPressed', () => {
|
describe('confirmPressed', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
component.confirmPressed();
|
component.confirmPressed();
|
||||||
});
|
});
|
||||||
it('should call the close method on the active modal', () => {
|
it('should call the close method on the active modal', () => {
|
||||||
expect(modalStub.close).toHaveBeenCalled();
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('behaviour subject should have true as next', () => {
|
it('behaviour subject should emit true', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('cancelPressed', () => {
|
describe('cancelPressed', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
component.cancelPressed();
|
component.cancelPressed();
|
||||||
});
|
});
|
||||||
it('should call the close method on the active modal', () => {
|
it('should call the close method on the active modal', () => {
|
||||||
expect(modalStub.close).toHaveBeenCalled();
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('behaviour subject should have false as next', () => {
|
it('behaviour subject should emit false', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(false);
|
expect(component.response.emit).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ describe('ConfirmationModalComponent', () => {
|
|||||||
describe('when the click method emits on cancel button', () => {
|
describe('when the click method emits on cancel button', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
spyOn(component, 'close');
|
spyOn(component, 'close');
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
debugElement.query(By.css('button.cancel')).triggerEventHandler('click', {
|
debugElement.query(By.css('button.cancel')).triggerEventHandler('click', {
|
||||||
preventDefault: () => {/**/
|
preventDefault: () => {/**/
|
||||||
}
|
}
|
||||||
@@ -99,15 +99,15 @@ describe('ConfirmationModalComponent', () => {
|
|||||||
it('should call the close method on the component', () => {
|
it('should call the close method on the component', () => {
|
||||||
expect(component.close).toHaveBeenCalled();
|
expect(component.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('behaviour subject should have false as next', () => {
|
it('behaviour subject should emit false', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(false);
|
expect(component.response.emit).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when the click method emits on confirm button', () => {
|
describe('when the click method emits on confirm button', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
spyOn(component, 'close');
|
spyOn(component, 'close');
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
debugElement.query(By.css('button.confirm')).triggerEventHandler('click', {
|
debugElement.query(By.css('button.confirm')).triggerEventHandler('click', {
|
||||||
preventDefault: () => {/**/
|
preventDefault: () => {/**/
|
||||||
}
|
}
|
||||||
@@ -118,8 +118,8 @@ describe('ConfirmationModalComponent', () => {
|
|||||||
it('should call the close method on the component', () => {
|
it('should call the close method on the component', () => {
|
||||||
expect(component.close).toHaveBeenCalled();
|
expect(component.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('behaviour subject should have true as next', () => {
|
it('behaviour subject should emit false', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { Component, 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 { Subject } from 'rxjs';
|
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -24,7 +23,7 @@ export class ConfirmationModalComponent {
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
@Output()
|
@Output()
|
||||||
response: Subject<boolean> = new Subject();
|
response = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor(protected activeModal: NgbActiveModal) {
|
constructor(protected activeModal: NgbActiveModal) {
|
||||||
}
|
}
|
||||||
@@ -33,7 +32,7 @@ export class ConfirmationModalComponent {
|
|||||||
* Confirm the action that led to the modal
|
* Confirm the action that led to the modal
|
||||||
*/
|
*/
|
||||||
confirmPressed() {
|
confirmPressed() {
|
||||||
this.response.next(true);
|
this.response.emit(true);
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ export class ConfirmationModalComponent {
|
|||||||
* Cancel the action that led to the modal and close modal
|
* Cancel the action that led to the modal and close modal
|
||||||
*/
|
*/
|
||||||
cancelPressed() {
|
cancelPressed() {
|
||||||
this.response.next(false);
|
this.response.emit(false);
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ describe('IdleModalComponent', () => {
|
|||||||
|
|
||||||
describe('extendSessionPressed', () => {
|
describe('extendSessionPressed', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
component.extendSessionPressed();
|
component.extendSessionPressed();
|
||||||
}));
|
}));
|
||||||
it('should set idle to false', () => {
|
it('should set idle to false', () => {
|
||||||
@@ -55,8 +55,8 @@ describe('IdleModalComponent', () => {
|
|||||||
it('should close the modal', () => {
|
it('should close the modal', () => {
|
||||||
expect(modalStub.close).toHaveBeenCalled();
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('response \'closed\' should have true as next', () => {
|
it('response \'closed\' should emit true', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ describe('IdleModalComponent', () => {
|
|||||||
|
|
||||||
describe('closePressed', () => {
|
describe('closePressed', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
spyOn(component.response, 'next');
|
spyOn(component.response, 'emit');
|
||||||
component.closePressed();
|
component.closePressed();
|
||||||
}));
|
}));
|
||||||
it('should set idle to false', () => {
|
it('should set idle to false', () => {
|
||||||
@@ -83,8 +83,8 @@ describe('IdleModalComponent', () => {
|
|||||||
it('should close the modal', () => {
|
it('should close the modal', () => {
|
||||||
expect(modalStub.close).toHaveBeenCalled();
|
expect(modalStub.close).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
it('response \'closed\' should have true as next', () => {
|
it('response \'closed\' should emit true', () => {
|
||||||
expect(component.response.next).toHaveBeenCalledWith(true);
|
expect(component.response.emit).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
import { Component, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { Subject } from 'rxjs';
|
|
||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '../../app.reducer';
|
import { AppState } from '../../app.reducer';
|
||||||
@@ -29,7 +28,7 @@ export class IdleModalComponent implements OnInit {
|
|||||||
* An event fired when the modal is closed
|
* An event fired when the modal is closed
|
||||||
*/
|
*/
|
||||||
@Output()
|
@Output()
|
||||||
response: Subject<boolean> = new Subject();
|
response = new EventEmitter<boolean>();
|
||||||
|
|
||||||
constructor(private activeModal: NgbActiveModal,
|
constructor(private activeModal: NgbActiveModal,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
@@ -84,6 +83,6 @@ export class IdleModalComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
closeModal() {
|
closeModal() {
|
||||||
this.activeModal.close();
|
this.activeModal.close();
|
||||||
this.response.next(true);
|
this.response.emit(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { Component, Output } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { Subject } from 'rxjs';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-versions-delete-modal',
|
selector: 'ds-item-versions-delete-modal',
|
||||||
@@ -12,7 +11,7 @@ export class ItemVersionsDeleteModalComponent {
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
@Output()
|
@Output()
|
||||||
response: Subject<boolean> = new Subject();
|
response = new EventEmitter<boolean>();
|
||||||
|
|
||||||
versionNumber: number;
|
versionNumber: number;
|
||||||
|
|
||||||
@@ -21,12 +20,12 @@ export class ItemVersionsDeleteModalComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onModalClose() {
|
onModalClose() {
|
||||||
this.response.next(false);
|
this.response.emit(false);
|
||||||
this.activeModal.dismiss();
|
this.activeModal.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalSubmit() {
|
onModalSubmit() {
|
||||||
this.response.next(true);
|
this.response.emit(true);
|
||||||
this.activeModal.close();
|
this.activeModal.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user