all files / component/popup/model/ popup-response.model.ts

35.71% Statements 5/14
0% Branches 0/4
25% Functions 1/4
36.36% Lines 4/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                       
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
import { DejaPopupAction } from './popup-action.model';
import { DejaPopupBase } from './popup-base.class';
 
export class DejaPopupReponse {
 
    public acceptedActionNames = ['check', 'ok', 'yes', 'confirm', 'save'];
    public lastAction: DejaPopupAction;
 
    constructor(
        public resp: any,
        public componentInstance: DejaPopupBase,
    ) {
        if (componentInstance && componentInstance.actionSelected) {
            this.lastAction = this.componentInstance.actionSelected;
        } else {
            this.lastAction = new DejaPopupAction('cancel');
        }
    }
 
    public get accepted(): boolean {
        return this.acceptedActionNames.some((nameOk: string) => nameOk === this.lastAction.name);
    }
}