rsanchez
2017-03-10 ac8d1f0e8ab4bab6eb546daa8062a6dad3ab8e23
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
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 = data,
          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 = data,
          err => console.error('Error loading orgs')
        );
  }
  ngOnInit(): void {
    this.loadCombos();
    this.data = {};
    this.form_title = this.$L.get('Pack data');
  }
  ngAfterViewInit(): void {
  }
}