Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #841/add page for displaying inventory stock
- Loading branch information
1 parent
dda0cc0
commit ea4fa9d
Showing
11 changed files
with
308 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
apps/gauzy/src/app/pages/inventory/inventory-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { InventoryComponent } from './inventory-table/inventory.component'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: InventoryComponent | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class InventoryRoutingModule {} |
44 changes: 44 additions & 0 deletions
44
apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<nb-card [nbSpinner]="loading" nbSpinnerStatus="primary" nbSpinnerSize="large"> | ||
<nb-card-header> | ||
<h4>{{ 'INVENTORY_PAGE.HEADER' | translate }}</h4> | ||
</nb-card-header> | ||
|
||
<nb-card-body> | ||
<div class="mb-3"> | ||
<button (click)="save()" nbButton status="success" class="mr-2"> | ||
<nb-icon class="mr-1" icon="plus-outline"></nb-icon | ||
>{{ 'BUTTONS.ADD' | translate }} | ||
</button> | ||
<button | ||
(click)="save()" | ||
nbButton | ||
status="info" | ||
class="mr-2" | ||
[disabled]="disableButton" | ||
> | ||
<nb-icon class="mr-1" icon="edit-outline"></nb-icon> | ||
{{ 'BUTTONS.EDIT' | translate }} | ||
</button> | ||
<button | ||
(click)="delete()" | ||
nbButton | ||
status="danger" | ||
class="mr-2" | ||
[disabled]="disableButton" | ||
> | ||
<nb-icon class="mr-1" icon="archive-outline"> </nb-icon> | ||
{{ 'BUTTONS.DELETE' | translate }} | ||
</button> | ||
</div> | ||
|
||
<ng2-smart-table | ||
class="tags-table" | ||
[settings]="settingsSmartTable" | ||
(userRowSelect)="selectItem($event)" | ||
[source]="smartTableSource" | ||
style="cursor: pointer;" | ||
#inventoryTable | ||
> | ||
</ng2-smart-table> | ||
</nb-card-body> | ||
</nb-card> |
Empty file.
107 changes: 107 additions & 0 deletions
107
apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { InventoryRoutingModule } from './inventory-routing.module'; | ||
import { InventoryComponent } from './inventory-table/inventory.component'; | ||
import { | ||
NbCardModule, | ||
NbButtonModule, | ||
NbIconModule, | ||
NbSpinnerModule | ||
} from '@nebular/theme'; | ||
import { Ng2SmartTableModule } from 'ng2-smart-table'; | ||
import { TableComponentsModule } from '../../@shared/table-components/table-components.module'; | ||
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; | ||
import { TranslateHttpLoader } from '@ngx-translate/http-loader'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
export function HttpLoaderFactory(http: HttpClient) { | ||
return new TranslateHttpLoader(http, './assets/i18n/', '.json'); | ||
} | ||
|
||
@NgModule({ | ||
declarations: [InventoryComponent], | ||
imports: [ | ||
InventoryRoutingModule, | ||
CommonModule, | ||
NbCardModule, | ||
NbButtonModule, | ||
NbIconModule, | ||
Ng2SmartTableModule, | ||
TableComponentsModule, | ||
TranslateModule.forChild({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useFactory: HttpLoaderFactory, | ||
deps: [HttpClient] | ||
} | ||
}), | ||
NbSpinnerModule | ||
] | ||
}) | ||
export class InventoryModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Product as IProduct } from './product.model'; | ||
import { BaseEntityModel as IBaseEntityModel } from '..'; | ||
|
||
export interface Inventory extends IBaseEntityModel { | ||
stock: InventoryStock[]; | ||
trackInventory: boolean; | ||
} | ||
|
||
export interface InventoryItem extends IBaseEntityModel, IProduct {} | ||
|
||
export interface InventoryStock { | ||
item: InventoryItem; | ||
currentStock: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { BaseEntityModel as IBaseEntityModel } from './base-entity.model'; | ||
|
||
export interface Product { | ||
name: string; | ||
enabled: boolean; | ||
productTypeId: string; | ||
productCategoryId: string; | ||
isSubscription: boolean; | ||
isPurchaseAutomatically: boolean; | ||
canBeSold: boolean; | ||
canBePurchased: boolean; | ||
canBeCharged: boolean; | ||
canBeRented: boolean; | ||
isEquipment: boolean; | ||
internalReference: string; | ||
code: string; | ||
notes: string; | ||
description: string; | ||
unitCost: number; | ||
unitCostCurrency: string; | ||
retailPrice: number; | ||
retailPriceCurrency: string; | ||
quantity: number; | ||
taxes: number; | ||
billingInvoicingPolicy: string; | ||
productType?: ProductType; | ||
productCategory?: ProductCategory; | ||
} | ||
|
||
export interface ProductType extends IBaseEntityModel { | ||
name: string; | ||
} | ||
|
||
export interface ProductCategory extends IBaseEntityModel { | ||
name: string; | ||
} |