| .. | .. |
|---|
| 1 | 1 | import { Router } from '@angular/router'; |
|---|
| 2 | | -import { MdDialog } from '@angular/material'; |
|---|
| 2 | +import { MdDialog, MdDialogConfig } from '@angular/material'; |
|---|
| 3 | 3 | import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core'; |
|---|
| 4 | 4 | import { IPageChangeEvent } from '@covalent/core'; |
|---|
| 5 | 5 | import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 6 | 6 | import { TdMediaService } from '@covalent/core'; |
|---|
| 7 | 7 | import { PacksService } from './resources/packs'; |
|---|
| 8 | 8 | import { PackFormComponent } from './forms/pack.form.component'; |
|---|
| 9 | +import { LocaleService } from './common/i18n'; |
|---|
| 10 | + |
|---|
| 9 | 11 | |
|---|
| 10 | 12 | var pack_example = { |
|---|
| 11 | 13 | id: 7, |
|---|
| .. | .. |
|---|
| 36 | 38 | renew_valid_period: 0, |
|---|
| 37 | 39 | } |
|---|
| 38 | 40 | |
|---|
| 41 | +const DIALOG_OPTIONS : MdDialogConfig = { |
|---|
| 42 | + height: '80%', // can be px or % |
|---|
| 43 | + width: '45%', // can be px or % |
|---|
| 44 | +} |
|---|
| 45 | + |
|---|
| 39 | 46 | @Component({ |
|---|
| 40 | 47 | selector: 'pack-list', |
|---|
| 41 | 48 | templateUrl: 'src/app/pack.list.component.html' |
|---|
| .. | .. |
|---|
| 58 | 65 | fromRow: number = 1; |
|---|
| 59 | 66 | currentPage: number = 1; |
|---|
| 60 | 67 | pageSize: number = 10; |
|---|
| 61 | | - sortBy: string = 'application_name'; |
|---|
| 68 | + sortBy: string = 'code'; |
|---|
| 62 | 69 | sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending; |
|---|
| 63 | 70 | filteredItems = this.data.length; |
|---|
| 64 | 71 | pack_menu_options : any[] = [{ |
|---|
| .. | .. |
|---|
| 81 | 88 | private media: TdMediaService, |
|---|
| 82 | 89 | private router: Router, |
|---|
| 83 | 90 | private dialog: MdDialog, |
|---|
| 91 | + private $L: LocaleService, |
|---|
| 84 | 92 | private packForm: PackFormComponent, |
|---|
| 85 | 93 | private packs: PacksService) { |
|---|
| 86 | 94 | this.packs.get().subscribe( |
|---|
| .. | .. |
|---|
| 97 | 105 | } |
|---|
| 98 | 106 | |
|---|
| 99 | 107 | createPack() : void { |
|---|
| 100 | | - var ref = this.dialog.open(PackFormComponent, { |
|---|
| 101 | | - height: '50%', // can be px or % |
|---|
| 102 | | - width: '40%', // can be px or % |
|---|
| 103 | | - }); |
|---|
| 108 | + var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS); |
|---|
| 104 | 109 | ref.componentInstance.isNew = true; |
|---|
| 105 | 110 | ref.afterClosed().subscribe(result => { |
|---|
| 106 | 111 | console.log(result); |
|---|
| .. | .. |
|---|
| 113 | 118 | } |
|---|
| 114 | 119 | |
|---|
| 115 | 120 | editPack(pack: any) : void { |
|---|
| 116 | | - var ref = this.dialog.open(PackFormComponent, { |
|---|
| 117 | | - height: '70%', // can be px or % |
|---|
| 118 | | - width: '40%', // can be px or % |
|---|
| 119 | | - }); |
|---|
| 121 | + var ref = this.dialog.open(PackFormComponent, DIALOG_OPTIONS); |
|---|
| 120 | 122 | ref.componentInstance.isNew = false; |
|---|
| 121 | 123 | ref.componentInstance.data = pack; |
|---|
| 122 | 124 | ref.afterClosed().subscribe(result => { |
|---|
| .. | .. |
|---|
| 127 | 129 | |
|---|
| 128 | 130 | |
|---|
| 129 | 131 | sort(sortEvent: ITdDataTableSortChangeEvent): void { |
|---|
| 130 | | - this.sortBy = sortEvent.name; |
|---|
| 132 | + this.sortBy = sortEvent.name === 'used_licenses' ? 'num_available' : sortEvent.name; |
|---|
| 131 | 133 | this.sortOrder = sortEvent.order; |
|---|
| 132 | 134 | this.filter(); |
|---|
| 133 | 135 | } |
|---|