César Calvo
2017-03-15 abb9cc75e166c32cfa97244c497e6a69d14ea114
securis/src/main/webapp/src/app/pack.list.component.ts
....@@ -1,11 +1,13 @@
11 import { Router } from '@angular/router';
2
-import { MdDialog } from '@angular/material';
2
+import { MdDialog, MdDialogConfig } from '@angular/material';
33 import { TdDataTableService, TdDataTableSortingOrder, ITdDataTableSortChangeEvent, ITdDataTableColumn } from '@covalent/core';
44 import { IPageChangeEvent } from '@covalent/core';
55 import { Component, AfterViewInit } from '@angular/core';
66 import { TdMediaService } from '@covalent/core';
77 import { PacksService } from './resources/packs';
88 import { PackFormComponent } from './forms/pack.form.component';
9
+import { LocaleService } from './common/i18n';
10
+
911
1012 var pack_example = {
1113 id: 7,
....@@ -36,6 +38,11 @@
3638 renew_valid_period: 0,
3739 }
3840
41
+const DIALOG_OPTIONS : MdDialogConfig = {
42
+ height: '80%', // can be px or %
43
+ width: '45%', // can be px or %
44
+}
45
+
3946 @Component({
4047 selector: 'pack-list',
4148 templateUrl: 'src/app/pack.list.component.html'
....@@ -58,7 +65,7 @@
5865 fromRow: number = 1;
5966 currentPage: number = 1;
6067 pageSize: number = 10;
61
- sortBy: string = 'application_name';
68
+ sortBy: string = 'code';
6269 sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
6370 filteredItems = this.data.length;
6471 pack_menu_options : any[] = [{
....@@ -81,6 +88,7 @@
8188 private media: TdMediaService,
8289 private router: Router,
8390 private dialog: MdDialog,
91
+ private $L: LocaleService,
8492 private packForm: PackFormComponent,
8593 private packs: PacksService) {
8694 this.packs.get().subscribe(
....@@ -97,10 +105,7 @@
97105 }
98106
99107 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);
104109 ref.componentInstance.isNew = true;
105110 ref.afterClosed().subscribe(result => {
106111 console.log(result);
....@@ -113,10 +118,7 @@
113118 }
114119
115120 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);
120122 ref.componentInstance.isNew = false;
121123 ref.componentInstance.data = pack;
122124 ref.afterClosed().subscribe(result => {
....@@ -127,7 +129,7 @@
127129
128130
129131 sort(sortEvent: ITdDataTableSortChangeEvent): void {
130
- this.sortBy = sortEvent.name;
132
+ this.sortBy = sortEvent.name === 'used_licenses' ? 'num_available' : sortEvent.name;
131133 this.sortOrder = sortEvent.order;
132134 this.filter();
133135 }