import { Component, Injector, ViewChild, ViewEncapsulation } from '@angular/core'; import { CreateAddressTypeModalComponent } from './create-address-type-modal.component'; import { UpdateAddressTypeModalComponent } from './edit-address-type-modal.component'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { AddressTypeListDto, AddressTypeServiceProxy } from '@shared/service-proxies/service-proxies'; import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent'; import { Paginator } from 'primeng/components/paginator/paginator'; import { Table } from 'primeng/components/table/table'; import { PrimengTableHelper } from 'shared/helpers/PrimengTableHelper'; @Component({ templateUrl: './address-types.component.html', // styleUrls: ['./.udcomponent.less'], encapsulation: ViewEncapsulation.None, animations: [appModuleAnimation()] }) export class AddressTypeComponent extends AppComponentBase { @ViewChild('createAddressTypeModal', {static: false}) createAddressTypeModal: CreateAddressTypeModalComponent; @ViewChild('updateAddressTypeModal', {static: false}) updateAddressTypeModal: UpdateAddressTypeModalComponent; @ViewChild('dataTable', {static: true}) dataTable: Table; @ViewChild('paginator', {static: true}) paginator: Paginator; //Filters filters :{ id: number; name: string; currentPage:number; } = {}; constructor( injector: Injector, private _addressTypeService: AddressTypeServiceProxy ) { super(injector); } getAddressTypes(event?: LazyLoadEvent) { if (this.primengTableHelper.shouldResetPaging(event)) { this.paginator.changePage(0); return; } this.spinnerService.show(); this._addressTypeService.getAddressType( this.filters.id, this.filters.name, this.primengTableHelper.getSorting(this.dataTable), this.primengTableHelper.getMaxResultCount(this.paginator, event), this.primengTableHelper.getSkipCount(this.paginator, event) ).subscribe((result) => { this.primengTableHelper.totalRecordsCount = result.totalCount; this.primengTableHelper.records = result.items; this.spinnerService.hide(); }); } createAddressType(): void { this.createAddressTypeModal.show(); } reloadPage(): void { this.paginator.changePage(this.paginator.getPage()); } deleteAddressType(addressType: AddressTypeListDto): void { this.message.confirm( this.l('DeleteAddressTypeWarningMessage'), isConfirmed => { if (isConfirmed) { this._addressTypeService.deleteAddressType(addressType.id).subscribe(() => { this.reloadPage(); this.notify.info(this.l('SuccessfullyDeleted')); }); } } ); } }