-
Notifications
You must be signed in to change notification settings - Fork 487
/
inventory.component.ts
107 lines (97 loc) · 2.62 KB
/
inventory.component.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { Component, OnInit, ViewChild } from '@angular/core';
import { LocalDataSource } from 'ng2-smart-table';
import { FormGroup } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { NbDialogService, NbToastrService } from '@nebular/theme';
import { Router } from '@angular/router';
import { TranslationBaseComponent } from '../../../@shared/language-base/translation-base.component';
import { InventoryItem, Inventory } from '@gauzy/models';
@Component({
selector: 'ngx-inventory',
templateUrl: './inventory.component.html',
styleUrls: ['./inventory.component.scss']
})
export class InventoryComponent extends TranslationBaseComponent
implements OnInit {
settingsSmartTable: object;
loading = true;
selectedItem: InventoryItem;
inventory: Inventory;
smartTableSource = new LocalDataSource();
form: FormGroup;
disableButton = true;
@ViewChild('inventoryTable', { static: false }) inventoryTable;
ngOnInit(): void {
this.loadSmartTable();
this._applyTranslationOnSmartTable();
this.loadSettings();
}
constructor(
readonly translateService: TranslateService,
private dialogService: NbDialogService,
private toastrService: NbToastrService,
private router: Router
) {
super(translateService);
}
async loadSmartTable() {
this.settingsSmartTable = {
actions: false,
columns: {
name: {
title: this.getTranslation('INVENTORY_PAGE.NAME'),
type: 'string'
},
productType: {
title: this.getTranslation('INVENTORY_PAGE.PRODUCT_TYPE'),
type: 'string'
},
productCategory: {
title: this.getTranslation(
'INVENTORY_PAGE.PRODUCT_CATEGORY'
),
type: 'string'
},
description: {
title: this.getTranslation('INVENTORY_PAGE.DESCRIPTION'),
type: 'string',
filter: false
},
unitCost: {
title: this.getTranslation('INVENTORY_PAGE.UNIT_COST'),
type: 'number',
filter: false
},
quantity: {
title: this.getTranslation('INVENTORY_PAGE.QUANTITY'),
type: 'number',
filter: false
}
}
};
}
async save() {}
async delete() {}
async loadSettings() {
this.selectedItem = null;
// const { items } = await this.inventoryService.getAll();
const items = [];
this.loading = false;
this.smartTableSource.load(items);
}
//todo
async selectItem($event: any) {
if ($event.isSelected) {
this.selectedItem = $event.data;
this.disableButton = false;
this.inventoryTable.grid.dataSet.willSelect = false;
} else {
this.disableButton = true;
}
}
_applyTranslationOnSmartTable() {
this.translateService.onLangChange.subscribe(() => {
this.loadSmartTable();
});
}
}