| .. | .. |
|---|
| 1 | +import { Http } from '@angular/http'; |
|---|
| 1 | 2 | import { PacksService } from '../resources/packs'; |
|---|
| 2 | 3 | import { LocaleService } from '../common/i18n'; |
|---|
| 3 | 4 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 4 | 5 | import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 5 | 6 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 6 | 7 | import { TdMediaService } from '@covalent/core'; |
|---|
| 8 | +import { IComboOption } from './base'; |
|---|
| 7 | 9 | |
|---|
| 8 | 10 | @Component({ |
|---|
| 9 | 11 | selector: 'pack-form', |
|---|
| .. | .. |
|---|
| 11 | 13 | }) |
|---|
| 12 | 14 | export class PackFormComponent implements AfterViewInit { |
|---|
| 13 | 15 | |
|---|
| 14 | | - form_title: string = ''; |
|---|
| 16 | + form_title: string = 'Title'; |
|---|
| 15 | 17 | form_subtitle: string = ''; |
|---|
| 18 | + organizations : IComboOption[]; |
|---|
| 19 | + licensetypes : IComboOption[]; |
|---|
| 20 | + data: any = {}; |
|---|
| 21 | + isNew : boolean = true; |
|---|
| 16 | 22 | |
|---|
| 17 | | - constructor(private packs: PacksService, |
|---|
| 23 | + constructor(private http: Http, |
|---|
| 24 | + private packs: PacksService, |
|---|
| 18 | 25 | 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 | + |
|---|
| 21 | 27 | } |
|---|
| 22 | 28 | |
|---|
| 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 | + |
|---|
| 23 | 45 | ngOnInit(): void { |
|---|
| 46 | + this.loadCombos(); |
|---|
| 47 | + this.data = {}; |
|---|
| 48 | + this.form_title = this.$L.get('Pack data'); |
|---|
| 24 | 49 | } |
|---|
| 25 | 50 | |
|---|
| 26 | 51 | |
|---|
| 27 | 52 | ngAfterViewInit(): void { |
|---|
| 28 | | - |
|---|
| 29 | 53 | } |
|---|
| 30 | 54 | } |
|---|
| 31 | 55 | |
|---|