rsanchez
2017-03-10 6078e6018ca05bcc0203241dc44071a59cf5e78c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Http } from '@angular/http';
import { PacksService } from '../resources/packs';
import { LocaleService } from '../common/i18n';
import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
import { IPageChangeEvent } from '@covalent/core';
import { Component, AfterViewInit } from '@angular/core';
import { TdMediaService } from '@covalent/core';
import { IComboOption } from './base';
@Component({
  selector: 'pack-form',
  templateUrl: 'src/app/forms/pack.form.html'
})
export class PackFormComponent implements AfterViewInit {
  form_title: string = 'Title';
  form_subtitle: string = '';
  organizations : IComboOption[];
  licensetypes : IComboOption[];
  data: any = {};
  isNew : boolean = true;
  constructor(private http: Http,
              private packs: PacksService,
              private $L: LocaleService) {
      
  }
  private loadCombos(): void {
      this.http.get('organization')
        .map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`}))
        .subscribe(
          data => this.organizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
          err => console.error('Error loading orgs')
        );
      this.http.get('licensetype')
        .map(response => response.json().map((lt : any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`}))
        .subscribe(
          data => this.licensetypes = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label)),
          err => console.error('Error loading license types')
        );
  }
  log(obj: any) {
    console.log(obj)
  }
  
  ngOnInit(): void {
    this.loadCombos();
    this.data = {};
    this.form_title = this.$L.get('Pack data');
    this.form_subtitle = this.$L.get('Create a new licenses pack');
  }
  ngAfterViewInit(): void {
  }
}