@Component({
template: `
<ng-template #fillTpl>
- The description of the confirmation modal is mandatory.
+ Template based description.
</ng-template>
`
})
titleText: 'Title is a must have',
buttonText: 'Action label',
bodyTpl: this.fillTpl,
+ description: 'String based description.',
onSubmit: () => {
this.returnValue = 'The submit action has to hide manually.';
this.modalRef.hide();
it('has no description defined', () => {
expectError(
{
- bodyTpl: undefined
+ bodyTpl: undefined,
+ description: undefined
},
'No description defined'
);
it('should show the description', () => {
expect(fh.getText('.modal-body')).toBe(
- 'The description of the confirmation modal is mandatory.'
+ 'Template based description. String based description.'
);
});
});
})
export class ConfirmationModalComponent implements OnInit, OnDestroy {
// Needed
- bodyTpl: TemplateRef<any>;
buttonText: string;
titleText: string;
onSubmit: Function;
+ // One of them is needed
+ bodyTpl?: TemplateRef<any>;
+ description?: TemplateRef<any>;
+
// Optional
bodyData?: object;
onCancel?: Function;
throw new Error('No action name defined');
} else if (!this.titleText) {
throw new Error('No title defined');
- } else if (!this.bodyTpl) {
+ } else if (!this.bodyTpl && !this.description) {
throw new Error('No description defined');
}
}