import {controller, directive} from '../../infrastructure/Dectorators/Components'; import {Mod} from './prm.mod'; import {IPrmService, IPrmDetail, IPrmListRequest} from '../services/prmService'; import * as InformationService from '../services/flightInformationService'; import {IFlightDetail} from '../../core/service/flightService'; export interface PrmListParams extends ng.ui.IStateParamsService { flightId: string; } @controller(Mod, 'prmListController', ['prmService', '$stateParams', '$state', '$rootScope', 'chromaState']) export class Controller { public static NO_PRM = 'This flight has no passengers with reduced movement'; public prms: Array; public message: string; public request: IPrmListRequest; public flightId: string; public model: IFlightDetail; constructor(private prmService: IPrmService, private $stateParams: PrmListParams, private $state: ng.ui.IStateService, private $rootScope: ng.IScope) { this.load(); } private load() : void { this.prmService.getPrmList(this.model.Id, this.model.PhysFlightId) .then((r) => this.onPrmLoad(r)); } private onPrmLoad(request: any): void { this.request = request; this.prms = request; if (!this.prms || this.prms.length === 0) { this.message = Controller.NO_PRM; } } } @directive(Mod, 'chromaPrmList', ['$stateParams']) export class Directive implements ng.IDirective { controller: string = Controller.$componentName; controllerAs: string = 'vm'; templateUrl: string = 'app/flight-detail/prm/prm-list.tpl.html'; restrict: string = 'E'; replace: boolean = false; bindToController: boolean = true; scope: any = { model: '=' }; }