mirror of
https://gitlab.silvrtree.co.uk/martind2000/aodb.git
synced 2025-02-09 20:59:16 +00:00
82 lines
2.9 KiB
TypeScript
82 lines
2.9 KiB
TypeScript
import {controller, directive} from '../../infrastructure/Dectorators/Components';
|
|
import {Controller as FlightDetailController} from '../detail/flight-detail';
|
|
import Mod from '../flight-detail.mod';
|
|
import * as InformationService from '../services/flightInformationService';
|
|
|
|
export interface IGroupScope {
|
|
group: string;
|
|
vm: IController;
|
|
}
|
|
|
|
export interface IGroupParams {
|
|
group: InformationService.IFlightInformationGroup;
|
|
}
|
|
export interface IController extends IGroupScope {
|
|
model: InformationService.IFlightInformationModel;
|
|
}
|
|
|
|
@controller(Mod, 'flightGroupController', ['$ionicPopup', '$rootScope', '$stateParams'])
|
|
export class Controller {
|
|
public group: InformationService.IFlightInformationGroup;
|
|
public model: InformationService.IFlightInformationModel;
|
|
public fieldFilter: (field: InformationService.IFlightInformation) => Boolean;
|
|
|
|
constructor(private $ionicPopup: ionic.popup.IonicPopupService,
|
|
private $rootScope: ng.IRootScopeService, private $stateParams: IGroupParams) {
|
|
this.group = $stateParams.group;
|
|
|
|
this.fieldFilter = (field: InformationService.IFlightInformation) => {
|
|
if (this.$stateParams && this.$stateParams.group) {
|
|
if (!field.Restrict || field.Restrict === '') {
|
|
return field.Group.toLowerCase() === this.$stateParams.group.Name.toLowerCase();
|
|
} else {
|
|
return field.Group === this.group.Name
|
|
&& this.model.Flight.Type === field.Restrict;
|
|
}
|
|
}
|
|
};
|
|
|
|
$rootScope.$emit('flightGroupChanged', this.group);
|
|
}
|
|
|
|
public editorFor(field: InformationService.IFlightInformation) {
|
|
if (field.Editor.toLowerCase() === 'readonly') { return; }
|
|
let editor = field.Editor.toLowerCase();
|
|
let modalScope: any = this.$rootScope.$new();
|
|
let editorDefinition: InformationService.IFlightEditor;
|
|
|
|
this.model.Editors.forEach(e => {
|
|
if (e.Name.toLowerCase() === editor) {
|
|
editorDefinition = e;
|
|
}
|
|
});
|
|
|
|
modalScope.model = this.model;
|
|
modalScope.field = field;
|
|
modalScope.editor = editorDefinition;
|
|
|
|
modalScope.instance = this.$ionicPopup.show({
|
|
templateUrl: `app/flight-detail/editors/${editor}/${editor}-holder.tpl.html`,
|
|
cssClass: `editor editor-${editor}`,
|
|
title: `Update ${field.Name}`,
|
|
scope: modalScope
|
|
});
|
|
}
|
|
public update(): void {
|
|
this.$rootScope.$emit('chroma:flight-updated');
|
|
}
|
|
}
|
|
|
|
@directive(Mod, 'chromaFlightDetailGroup')
|
|
export class Directive implements ng.IDirective {
|
|
controller: string = Controller.$componentName;
|
|
controllerAs: string = 'vm';
|
|
templateUrl: string = 'app/flight-detail/group/flight-group.tpl.html';
|
|
restrict: string = 'E';
|
|
replace: boolean = false;
|
|
bindToController: boolean = true;
|
|
scope: any = {
|
|
model: '='
|
|
};
|
|
}
|