rsanchez
2017-03-10 ac8d1f0e8ab4bab6eb546daa8062a6dad3ab8e23
securis/src/main/webapp/src/app/forms/pack.form.component.ts
....@@ -1,9 +1,11 @@
1
+import { Http } from '@angular/http';
12 import { PacksService } from '../resources/packs';
23 import { LocaleService } from '../common/i18n';
34 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
45 import { IPageChangeEvent } from '@covalent/core';
56 import { Component, AfterViewInit } from '@angular/core';
67 import { TdMediaService } from '@covalent/core';
8
+import { IComboOption } from './base';
79
810 @Component({
911 selector: 'pack-form',
....@@ -11,21 +13,43 @@
1113 })
1214 export class PackFormComponent implements AfterViewInit {
1315
14
- form_title: string = '';
16
+ form_title: string = 'Title';
1517 form_subtitle: string = '';
18
+ organizations : IComboOption[];
19
+ licensetypes : IComboOption[];
20
+ data: any = {};
21
+ isNew : boolean = true;
1622
17
- constructor(private packs: PacksService,
23
+ constructor(private http: Http,
24
+ private packs: PacksService,
1825 private $L: LocaleService) {
19
- this.form_title = $L.get('Pack data');
20
- this.form_subtitle = $L.get('Fullfill the pack data and save the changes');
26
+
2127 }
2228
29
+ private loadCombos(): void {
30
+ this.http.get('organization')
31
+ .map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
32
+ .subscribe(
33
+ data => this.organizations = data,
34
+ err => console.error('Error loading orgs')
35
+ );
36
+ this.http.get('licensetype')
37
+ .map(response => response.json().map((lt : any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`}))
38
+ .subscribe(
39
+ data => this.licensetypes = data,
40
+ err => console.error('Error loading orgs')
41
+ );
42
+ }
43
+
44
+
2345 ngOnInit(): void {
46
+ this.loadCombos();
47
+ this.data = {};
48
+ this.form_title = this.$L.get('Pack data');
2449 }
2550
2651
2752 ngAfterViewInit(): void {
28
-
2953 }
3054 }
3155