diff --git a/apps/gauzy/src/app/pages/inventory/icon-row/icon-row.component.ts b/apps/gauzy/src/app/pages/inventory/icon-row/icon-row.component.ts deleted file mode 100644 index c1e6eb9a30..0000000000 --- a/apps/gauzy/src/app/pages/inventory/icon-row/icon-row.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { ViewCell } from 'ng2-smart-table'; -import { ProductTypeTranslated } from '@gauzy/models'; - -@Component({ - template: ` -
- -
- `, - styles: [ - ` - .icon-container { - width: 35px; - height: 35px; - display: flex; - justify-content: center; - align-items: center; - background: #3366ff; - padding: 5px 0; - border-radius: 50%; - } - - nb-icon { - color: #fff; - width: 25px; - } - ` - ] -}) -export class IconRowComponent implements ViewCell { - @Input() - value: string | number; - rowData: ProductTypeTranslated; -} diff --git a/apps/gauzy/src/app/pages/inventory/img-row/image-row.component.ts b/apps/gauzy/src/app/pages/inventory/img-row/image-row.component.ts deleted file mode 100644 index 9e3a475b8a..0000000000 --- a/apps/gauzy/src/app/pages/inventory/img-row/image-row.component.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { ViewCell } from 'ng2-smart-table'; -import { ProductCategoryTranslated } from '@gauzy/models'; - -@Component({ - template: ` -
- feature img -
- `, - styles: [ - ` - .img-container { - width: 100%; - display: flex; - justify-content: center; - } - img { - width: 50px; - margin-right: 15px; - border-radius: 5px; - } - ` - ] -}) -export class ImageRowComponent implements ViewCell { - @Input() - value: string | number; - rowData: ProductCategoryTranslated; -} diff --git a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.html b/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.html deleted file mode 100644 index 5aa3c41dc8..0000000000 --- a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.html +++ /dev/null @@ -1,64 +0,0 @@ - - -
-

{{ 'INVENTORY_PAGE.HEADER' | translate }}

-
- - -
-
-
- - -
- - - -
- - - -
-
diff --git a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.scss b/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.scss deleted file mode 100644 index dd511c2014..0000000000 --- a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.scss +++ /dev/null @@ -1,9 +0,0 @@ -.main-header { - display: flex; - align-items: center; - justify-content: space-between; - - button:first-child { - margin-right: 10px; - } -} diff --git a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.ts b/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.ts deleted file mode 100644 index 75794d5585..0000000000 --- a/apps/gauzy/src/app/pages/inventory/inventory-table/inventory.component.ts +++ /dev/null @@ -1,181 +0,0 @@ -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 { TranslationBaseComponent } from '../../../@shared/language-base/translation-base.component'; -import { ProductMutationComponent } from '../../../@shared/product-mutation/product-mutation.component'; -import { first, take } from 'rxjs/operators'; -import { ProductService } from '../../../@core/services/product.service'; -import { - Product, - ProductTypeTranslated, - ProductCategoryTranslated -} from '@gauzy/models'; -import { DeleteConfirmationComponent } from '../../../@shared/user/forms/delete-confirmation/delete-confirmation.component'; -import { Router } from '@angular/router'; -import { PictureNameTagsComponent } from '../../../@shared/table-components/picture-name-tags/picture-name-tags.component'; - -export interface SelectedProduct { - data: Product; - isSelected: false; -} - -@Component({ - selector: 'ngx-inventory', - templateUrl: './inventory.component.html', - styleUrls: ['./inventory.component.scss'] -}) -export class InventoryComponent extends TranslationBaseComponent - implements OnInit { - settingsSmartTable: object; - loading = true; - selectedItem: Product; - smartTableSource = new LocalDataSource(); - form: FormGroup; - disableButton = true; - selectedLanguage: string; - - @ViewChild('inventoryTable') inventoryTable; - - ngOnInit(): void { - this.selectedLanguage = this.translateService.currentLang; - this.translateService.onLangChange - .pipe(take(1)) - .subscribe((languageEvent) => { - this.selectedLanguage = languageEvent.lang; - }); - - this.loadSmartTable(); - this._applyTranslationOnSmartTable(); - this.loadSettings(); - } - - constructor( - readonly translateService: TranslateService, - private dialogService: NbDialogService, - private toastrService: NbToastrService, - private productService: ProductService, - private router: Router - ) { - super(translateService); - } - - async loadSmartTable() { - this.settingsSmartTable = { - actions: false, - columns: { - name: { - title: this.getTranslation('INVENTORY_PAGE.NAME'), - type: 'custom', - renderComponent: PictureNameTagsComponent - }, - code: { - title: this.getTranslation('INVENTORY_PAGE.CODE'), - type: 'string' - }, - type: { - title: this.getTranslation('INVENTORY_PAGE.PRODUCT_TYPE'), - type: 'string', - valuePrepareFunction: (type: ProductTypeTranslated) => - type ? type.name : '' - }, - category: { - title: this.getTranslation( - 'INVENTORY_PAGE.PRODUCT_CATEGORY' - ), - type: 'string', - valuePrepareFunction: ( - category: ProductCategoryTranslated - ) => (category ? category.name : '') - }, - description: { - title: this.getTranslation('INVENTORY_PAGE.DESCRIPTION'), - type: 'string', - filter: false, - valuePrepareFunction: (description: string) => { - return description.slice(0, 15) + '...'; - } - } - } - }; - } - - manageProductTypes() { - this.router.navigate(['/pages/organization/inventory/product-types']); - } - - manageProductCategories() { - this.router.navigate([ - '/pages/organization/inventory/product-categories' - ]); - } - - async save() { - const dialog = this.dialogService.open(ProductMutationComponent, { - context: { product: this.selectedItem } - }); - - await dialog.onClose.pipe(first()).toPromise(); - - this.loadSettings(); - } - - async delete() { - const result = await this.dialogService - .open(DeleteConfirmationComponent) - .onClose.pipe(first()) - .toPromise(); - - if (!result) return; - - try { - const res = await this.productService.delete(this.selectedItem.id); - - if (res.affected > 0) { - this.loadSettings(); - this.toastrService.primary( - this.getTranslation( - 'INVENTORY_PAGE.INVENTORY_ITEM_DELETED' - ), - this.getTranslation('TOASTR.TITLE.SUCCESS') - ); - } - } catch { - this.toastrService.success( - this.getTranslation('TOASTR.MESSAGE.SOMETHING_BAD_HAPPENED'), - this.getTranslation('TOASTR.TITLE.ERROR') - ); - } finally { - this.disableButton = true; - } - } - - async loadSettings() { - this.selectedItem = null; - const { items } = await this.productService.getAll( - null, - null, - this.selectedLanguage - ); - - this.loading = false; - this.smartTableSource.load(items); - } - - async selectItem($event: SelectedProduct) { - 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(); - }); - } -} diff --git a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.html b/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.html deleted file mode 100644 index 355d752b37..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.html +++ /dev/null @@ -1,58 +0,0 @@ - - -
- -
-

{{ 'INVENTORY_PAGE.PRODUCT_CATEGORIES' | translate }}

-
-
-
- - -
- - - -
- - - -
-
diff --git a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.scss b/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.scss deleted file mode 100644 index 1255e6a987..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.top-nav { - display: flex; - align-items: center; -} diff --git a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.ts b/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.ts deleted file mode 100644 index 442b851d05..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-category/product-categories.component.ts +++ /dev/null @@ -1,179 +0,0 @@ -import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core'; -import { Organization, ProductCategoryTranslated } from '@gauzy/models'; -import { LocalDataSource } from 'ng2-smart-table'; -import { TranslateService } from '@ngx-translate/core'; -import { TranslationBaseComponent } from '../../../@shared/language-base/translation-base.component'; -import { NbDialogService, NbToastrService } from '@nebular/theme'; -import { first, takeUntil } from 'rxjs/operators'; -import { DeleteConfirmationComponent } from '../../../@shared/user/forms/delete-confirmation/delete-confirmation.component'; -import { Location } from '@angular/common'; -import { ProductCategoryService } from '../../../@core/services/product-category.service'; -import { ProductCategoryMutationComponent } from '../../../@shared/product-mutation/product-category-mutation/product-category-mutation.component'; -import { ImageRowComponent } from '../img-row/image-row.component'; -import { Store } from '../../../@core/services/store.service'; -import { Subject } from 'rxjs'; - -export interface SelectedProductCategory { - data: ProductCategoryTranslated; - isSelected: boolean; -} - -@Component({ - selector: 'ngx-product-categories', - templateUrl: './product-categories.component.html', - styleUrls: ['./product-categories.component.scss'] -}) -export class ProductCategoriesComponent extends TranslationBaseComponent - implements OnInit, OnDestroy { - settingsSmartTable: object; - loading = true; - selectedItem: ProductCategoryTranslated; - selectedOrganization: Organization; - smartTableSource = new LocalDataSource(); - disableButton = true; - - private _ngDestroy$ = new Subject(); - - @ViewChild('productCategoriesTable', { static: true }) - productCategoriesTable; - - constructor( - readonly translateService: TranslateService, - private dialogService: NbDialogService, - private productCategoryService: ProductCategoryService, - private toastrService: NbToastrService, - private location: Location, - private store: Store - ) { - super(translateService); - } - - ngOnInit(): void { - this.store.selectedOrganization$ - .pipe(takeUntil(this._ngDestroy$)) - .subscribe((org) => { - this.selectedOrganization = org; - this.loadSettings(); - }); - - this.store.preferredLanguage$ - .pipe(takeUntil(this._ngDestroy$)) - .subscribe(() => { - this.loadSettings(); - }); - - this.loadSmartTable(); - this._applyTranslationOnSmartTable(); - } - - ngOnDestroy(): void { - this._ngDestroy$.next(); - this._ngDestroy$.complete(); - } - - async loadSmartTable() { - this.settingsSmartTable = { - actions: false, - columns: { - imageUrl: { - title: this.getTranslation('INVENTORY_PAGE.IMAGE'), - width: '10%', - filter: false, - type: 'custom', - renderComponent: ImageRowComponent - }, - name: { - title: this.getTranslation('INVENTORY_PAGE.NAME'), - type: 'string', - width: '40%' - }, - description: { - title: this.getTranslation('INVENTORY_PAGE.DESCRIPTION'), - type: 'string', - filter: false - } - } - }; - } - - async loadSettings() { - this.selectedItem = null; - const searchCriteria = this.selectedOrganization - ? { organization: { id: this.selectedOrganization.id } } - : null; - - const { items } = await this.productCategoryService.getAll( - this.store.preferredLanguage, - ['organization'], - searchCriteria - ); - - this.loading = false; - this.smartTableSource.load(items); - } - - _applyTranslationOnSmartTable() { - this.translateService.onLangChange.subscribe(() => { - this.loadSmartTable(); - }); - } - - async save() { - const editProductCategory = this.selectedItem - ? await this.productCategoryService.getById(this.selectedItem.id) - : null; - - const dialog = this.dialogService.open( - ProductCategoryMutationComponent, - { - context: { - productCategory: editProductCategory - } - } - ); - - const productCategory = await dialog.onClose.pipe(first()).toPromise(); - this.selectedItem = null; - this.disableButton = true; - - if (productCategory) { - this.toastrService.primary( - this.getTranslation('INVENTORY_PAGE.PRODUCT_CATEGORY_SAVED'), - this.getTranslation('TOASTR.TITLE.SUCCESS') - ); - } - - this.loadSettings(); - } - - async delete() { - const result = await this.dialogService - .open(DeleteConfirmationComponent) - .onClose.pipe(first()) - .toPromise(); - - if (result) { - await this.productCategoryService.delete(this.selectedItem.id); - this.loadSettings(); - this.toastrService.primary( - this.getTranslation('INVENTORY_PAGE.PRODUCT_CATEGORY_DELETED'), - this.getTranslation('TOASTR.TITLE.SUCCESS') - ); - } - this.disableButton = true; - } - - selectProductCategory($event: SelectedProductCategory) { - if ($event.isSelected) { - this.selectedItem = $event.data; - this.disableButton = false; - this.productCategoriesTable.grid.dataSet.willSelect = false; - } else { - this.disableButton = true; - } - } - - goBack() { - this.location.back(); - } -} diff --git a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.html b/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.html deleted file mode 100644 index 2c7a6712ac..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.html +++ /dev/null @@ -1,58 +0,0 @@ - - -
- -
-

{{ 'INVENTORY_PAGE.PRODUCT_TYPES' | translate }}

-
-
-
- - -
- - - -
- - - -
-
diff --git a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.scss b/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.scss deleted file mode 100644 index ecf7b578c0..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.scss +++ /dev/null @@ -1,4 +0,0 @@ -.top-nav { - display: flex; - align-items: center; -} diff --git a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.spec.ts b/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.spec.ts deleted file mode 100644 index 7b0235c031..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ProductTypesComponent } from './product-types.component'; - -describe('ProductTypeComponent', () => { - let component: ProductTypesComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ProductTypesComponent] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ProductTypesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.ts b/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.ts deleted file mode 100644 index 4c4b3d152b..0000000000 --- a/apps/gauzy/src/app/pages/inventory/product-type/product-types.component.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core'; -import { Organization, ProductTypeTranslated } from '@gauzy/models'; -import { LocalDataSource } from 'ng2-smart-table'; -import { TranslateService } from '@ngx-translate/core'; -import { TranslationBaseComponent } from '../../../@shared/language-base/translation-base.component'; -import { ProductTypeService } from '../../../@core/services/product-type.service'; -import { NbDialogService, NbToastrService } from '@nebular/theme'; -import { first, takeUntil } from 'rxjs/operators'; -import { ProductTypeMutationComponent } from '../../../@shared/product-mutation/product-type-mutation/product-type-mutation.component'; -import { DeleteConfirmationComponent } from '../../../@shared/user/forms/delete-confirmation/delete-confirmation.component'; -import { Location } from '@angular/common'; -import { IconRowComponent } from '../icon-row/icon-row.component'; -import { Store } from '../../../@core/services/store.service'; -import { Subject } from 'rxjs'; - -export interface SelectedProductType { - data: ProductTypeTranslated; - isSelected: boolean; -} - -@Component({ - selector: 'ngx-product-type', - templateUrl: './product-types.component.html', - styleUrls: ['./product-types.component.scss'] -}) -export class ProductTypesComponent extends TranslationBaseComponent - implements OnInit, OnDestroy { - settingsSmartTable: object; - loading = true; - selectedItem: ProductTypeTranslated; - selectedOrganization: Organization; - smartTableSource = new LocalDataSource(); - disableButton = true; - private _ngDestroy$ = new Subject(); - - @ViewChild('productTypesTable', { static: true }) productTypesTable; - - constructor( - readonly translateService: TranslateService, - private dialogService: NbDialogService, - private productTypeService: ProductTypeService, - private toastrService: NbToastrService, - private location: Location, - private store: Store - ) { - super(translateService); - } - - ngOnInit(): void { - this.store.selectedOrganization$ - .pipe(takeUntil(this._ngDestroy$)) - .subscribe((org) => { - this.selectedOrganization = org; - this.loadSettings(); - }); - - this.store.preferredLanguage$ - .pipe(takeUntil(this._ngDestroy$)) - .subscribe(() => { - this.loadSettings(); - }); - - this.loadSmartTable(); - this._applyTranslationOnSmartTable(); - } - - ngOnDestroy() { - this._ngDestroy$.next(); - this._ngDestroy$.complete(); - } - - async loadSmartTable() { - this.settingsSmartTable = { - actions: false, - columns: { - icon: { - title: this.getTranslation('INVENTORY_PAGE.ICON'), - width: '5%', - filter: false, - type: 'custom', - renderComponent: IconRowComponent - }, - name: { - title: this.getTranslation('INVENTORY_PAGE.NAME'), - type: 'string', - width: '40%' - }, - description: { - title: this.getTranslation('INVENTORY_PAGE.DESCRIPTION'), - type: 'string', - filter: false - } - } - }; - } - - async loadSettings() { - this.selectedItem = null; - const searchCriteria = this.selectedOrganization - ? { organization: { id: this.selectedOrganization.id } } - : null; - - const { items } = await this.productTypeService.getAllTranslated( - this.store.preferredLanguage, - ['organization'], - searchCriteria - ); - - this.loading = false; - this.smartTableSource.load(items); - } - - _applyTranslationOnSmartTable() { - this.translateService.onLangChange.subscribe(() => { - this.loadSmartTable(); - }); - } - - async save() { - const editProductType = this.selectedItem - ? await this.productTypeService.getById(this.selectedItem.id) - : null; - - const dialog = this.dialogService.open(ProductTypeMutationComponent, { - context: { - productType: editProductType - } - }); - - const productType = await dialog.onClose.pipe(first()).toPromise(); - this.selectedItem = null; - this.disableButton = true; - - if (productType) { - this.toastrService.primary( - this.getTranslation('INVENTORY_PAGE.PRODUCT_TYPE_SAVED'), - this.getTranslation('TOASTR.TITLE.SUCCESS') - ); - } - - this.loadSettings(); - } - - async delete() { - const result = await this.dialogService - .open(DeleteConfirmationComponent) - .onClose.pipe(first()) - .toPromise(); - - if (result) { - await this.productTypeService.delete(this.selectedItem.id); - this.loadSettings(); - this.toastrService.primary( - this.getTranslation('INVENTORY_PAGE.PRODUCT_TYPE_DELETED'), - this.getTranslation('TOASTR.TITLE.SUCCESS') - ); - } - this.disableButton = true; - } - - selectProductType($event: SelectedProductType) { - if ($event.isSelected) { - this.selectedItem = $event.data; - this.disableButton = false; - this.productTypesTable.grid.dataSet.willSelect = false; - } else { - this.disableButton = true; - } - } - - goBack() { - this.location.back(); - } -}