import { Injectable } from '@angular/core';
import { I<%= entityAngularName %> } from 'app/shared/model/<%= entityModelFileName %>.model';
import { PopupService } from 'app/layouts';
import { <%= entityAngularName %>SelectDialogComponent } from './<%= entityFileName %>-select-dialog.component';

@Injectable()
export class <%= entityAngularName %>SelectDialogService {

    constructor(private popupService: PopupService) {
    }

    open(callback: Function, selected: Array<I<%= entityAngularName %>> = [], multiSelect = false) {
        this.popupService.load(<%= entityAngularName %>SelectDialogComponent, {
            selected: multiSelect ? [...selected] : (selected && selected.length === 1) ? selected[0] : null,
            multiSelect,
            callback,
            close: () => {
                this.close();
            }
        });
    }

    close() {
        this.popupService.eject();
    }
}
