From bfe4f8bd5e0243976e4a6ec00a513dcbafc3893d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 05:11:18 +0000 Subject: [PATCH 1/8] Initial plan From b7e5ac84776a0ecafc8bd2ce3253b8207edcc83b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 05:17:32 +0000 Subject: [PATCH 2/8] Remove Akita dependencies and update to use BehaviorSubject-based state management Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com> --- .../store/customers-state.service.ts | 118 +++++++++++------- .../components/store/customers.query.ts | 60 ++++----- .../components/store/customers.store.ts | 104 +++++++-------- .../customers-pn/components/store/index.ts | 4 +- .../customers-pn/customers-pn.module.ts | 9 +- .../layouts/customer-pn-layout.component.ts | 31 +++-- 6 files changed, 186 insertions(+), 140 deletions(-) diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts index 2ad069d2..f8e73a69 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts @@ -1,38 +1,66 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; +import { BehaviorSubject, Observable } from 'rxjs'; import { OperationDataResult, PaginationModel, SortModel, + FiltrationStateModel, + CommonPaginationState, } from 'src/app/common/models'; import { updateTableSort, getOffset } from 'src/app/common/helpers'; import { map } from 'rxjs/operators'; -import { CustomersQuery, CustomersStore } from './'; import { CustomersPnService } from '../../services'; import { CustomersPnModel } from '../../models'; -@Injectable() +export interface CustomersState { + pagination: CommonPaginationState; + filters: FiltrationStateModel; + total: number; +} + +function createInitialState(): CustomersState { + return { + pagination: { + pageSize: 10, + sort: 'Id', + isSortDsc: false, + offset: 0, + }, + filters: { + nameFilter: '', + }, + total: 0, + }; +} + +@Injectable({ providedIn: 'root' }) export class CustomersStateService { + private state$ = new BehaviorSubject(createInitialState()); + constructor( - private store: CustomersStore, - private service: CustomersPnService, - private query: CustomersQuery + private service: CustomersPnService ) {} + private get state(): CustomersState { + return this.state$.value; + } + + private updateState(update: Partial) { + this.state$.next({ ...this.state, ...update }); + } + getAllCustomers(): Observable> { return this.service .getAllCustomers({ - ...this.query.pageSetting.pagination, - ...this.query.pageSetting.filters, - sortColumnName: this.query.pageSetting.pagination.sort, - name: this.query.pageSetting.filters.nameFilter, + ...this.state.pagination, + ...this.state.filters, + sortColumnName: this.state.pagination.sort, + name: this.state.filters.nameFilter, }) .pipe( map((response) => { if (response && response.success && response.model) { - this.store.update(() => ({ - total: response.model.total, - })); + this.updateState({ total: response.model.total }); } return response; }) @@ -40,88 +68,94 @@ export class CustomersStateService { } updateNameFilter(nameFilter: string) { - this.store.update((state) => ({ + this.updateState({ filters: { - ...state.filters, + ...this.state.filters, nameFilter: nameFilter, }, pagination: { - ...state.pagination, + ...this.state.pagination, offset: 0, }, - })); + }); } updatePageSize(pageSize: number) { - this.store.update((state) => ({ + this.updateState({ pagination: { - ...state.pagination, + ...this.state.pagination, pageSize: pageSize, }, - })); + }); this.checkOffset(); } getPageSize(): Observable { - return this.query.selectPageSize$; + return this.state$.pipe(map(state => state.pagination.pageSize)); } getSort(): Observable { - return this.query.selectSort$; + return this.state$.pipe( + map(state => new SortModel(state.pagination.sort, state.pagination.isSortDsc)) + ); } getNameFilter(): Observable { - return this.query.selectNameFilter$; + return this.state$.pipe(map(state => state.filters.nameFilter)); } changePage(offset: number) { - this.store.update((state) => ({ + this.updateState({ pagination: { - ...state.pagination, + ...this.state.pagination, offset: offset, }, - })); + }); } onDelete() { - this.store.update((state) => ({ - total: state.total - 1, - })); + this.updateState({ total: this.state.total - 1 }); this.checkOffset(); } onSortTable(sort: string) { const localPageSettings = updateTableSort( sort, - this.query.pageSetting.pagination.sort, - this.query.pageSetting.pagination.isSortDsc + this.state.pagination.sort, + this.state.pagination.isSortDsc ); - this.store.update((state) => ({ + this.updateState({ pagination: { - ...state.pagination, + ...this.state.pagination, isSortDsc: localPageSettings.isSortDsc, sort: localPageSettings.sort, }, - })); + }); } checkOffset() { const newOffset = getOffset( - this.query.pageSetting.pagination.pageSize, - this.query.pageSetting.pagination.offset, - this.query.pageSetting.total + this.state.pagination.pageSize, + this.state.pagination.offset, + this.state.total ); - if (newOffset !== this.query.pageSetting.pagination.offset) { - this.store.update((state) => ({ + if (newOffset !== this.state.pagination.offset) { + this.updateState({ pagination: { - ...state.pagination, + ...this.state.pagination, offset: newOffset, }, - })); + }); } } getPagination(): Observable { - return this.query.selectPagination$; + return this.state$.pipe( + map(state => new PaginationModel( + state.total, + state.pagination.pageSize, + state.pagination.offset + )) + ); } } diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.query.ts b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.query.ts index ea0ba413..dbcedf81 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.query.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.query.ts @@ -1,30 +1,30 @@ -import { Injectable } from '@angular/core'; -import { Query } from '@datorama/akita'; -import { CustomersState, CustomersStore } from './'; -import { PaginationModel, SortModel } from 'src/app/common/models'; - -@Injectable({ providedIn: 'root' }) -export class CustomersQuery extends Query { - constructor(protected store: CustomersStore) { - super(store); - } - - get pageSetting() { - return this.getValue(); - } - - selectNameFilter$ = this.select((state) => state.filters.nameFilter); - selectPageSize$ = this.select((state) => state.pagination.pageSize); - selectPagination$ = this.select( - (state) => - new PaginationModel( - state.total, - state.pagination.pageSize, - state.pagination.offset - ) - ); - - selectSort$ = this.select( - (state) => new SortModel(state.pagination.sort, state.pagination.isSortDsc) - ); -} +// import { Injectable } from '@angular/core'; +// import { Query } from '@datorama/akita'; +// import { CustomersState, CustomersStore } from './'; +// import { PaginationModel, SortModel } from 'src/app/common/models'; +// +// @Injectable({ providedIn: 'root' }) +// export class CustomersQuery extends Query { +// constructor(protected store: CustomersStore) { +// super(store); +// } +// +// get pageSetting() { +// return this.getValue(); +// } +// +// selectNameFilter$ = this.select((state) => state.filters.nameFilter); +// selectPageSize$ = this.select((state) => state.pagination.pageSize); +// selectPagination$ = this.select( +// (state) => +// new PaginationModel( +// state.total, +// state.pagination.pageSize, +// state.pagination.offset +// ) +// ); +// +// selectSort$ = this.select( +// (state) => new SortModel(state.pagination.sort, state.pagination.isSortDsc) +// ); +// } diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.store.ts b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.store.ts index b93c37eb..8edcb8d0 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.store.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers.store.ts @@ -1,52 +1,52 @@ -import { Injectable } from '@angular/core'; -import { persistState, Store, StoreConfig } from '@datorama/akita'; -import { - FiltrationStateModel, - CommonPaginationState, -} from 'src/app/common/models'; - -export interface CustomersState { - pagination: CommonPaginationState; - filters: FiltrationStateModel; - total: number; -} - -export function createInitialState(): CustomersState { - return { - pagination: { - pageSize: 10, - sort: 'Id', - isSortDsc: false, - offset: 0, - }, - filters: { - nameFilter: '', - }, - total: 0, - }; -} - -const customersPersistStorage = persistState({ - include: ['customers'], - key: 'customersPn', - preStorageUpdate(storeName, state) { - return { - pagination: state.pagination, - filters: state.filters, - }; - }, -}); - -@Injectable({ providedIn: 'root' }) -@StoreConfig({ name: 'customers', resettable: true }) -export class CustomersStore extends Store { - constructor() { - super(createInitialState()); - } -} - -export const customersPersistProvider = { - provide: 'persistStorage', - useValue: customersPersistStorage, - multi: true, -}; +// import { Injectable } from '@angular/core'; +// import { persistState, Store, StoreConfig } from '@datorama/akita'; +// import { +// FiltrationStateModel, +// CommonPaginationState, +// } from 'src/app/common/models'; +// +// export interface CustomersState { +// pagination: CommonPaginationState; +// filters: FiltrationStateModel; +// total: number; +// } +// +// export function createInitialState(): CustomersState { +// return { +// pagination: { +// pageSize: 10, +// sort: 'Id', +// isSortDsc: false, +// offset: 0, +// }, +// filters: { +// nameFilter: '', +// }, +// total: 0, +// }; +// } +// +// const customersPersistStorage = persistState({ +// include: ['customers'], +// key: 'customersPn', +// preStorageUpdate(storeName, state) { +// return { +// pagination: state.pagination, +// filters: state.filters, +// }; +// }, +// }); +// +// @Injectable({ providedIn: 'root' }) +// @StoreConfig({ name: 'customers', resettable: true }) +// export class CustomersStore extends Store { +// constructor() { +// super(createInitialState()); +// } +// } +// +// export const customersPersistProvider = { +// provide: 'persistStorage', +// useValue: customersPersistStorage, +// multi: true, +// }; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/store/index.ts b/eform-client/src/app/plugins/modules/customers-pn/components/store/index.ts index 1f2bd656..9e7b2009 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/store/index.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/store/index.ts @@ -1,3 +1,3 @@ -export * from './customers.query'; -export * from './customers.store'; +// export * from './customers.query'; +// export * from './customers.store'; export * from './customers-state.service'; diff --git a/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts b/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts index ce7337b0..9ad9d463 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { NgSelectModule } from '@ng-select/ng-select'; import { TranslateModule } from '@ngx-translate/core'; -import { MDBRootModule } from 'angular-bootstrap-md'; +import { RouterModule } from '@angular/router'; import { CustomerPnLayoutComponent } from './layouts'; import { CustomersPnFieldsService, @@ -20,9 +20,8 @@ import { CustomersPnFieldsComponent, CustomersPnPageComponent, } from './components'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { EformSharedModule } from 'src/app/common/modules/eform-shared/eform-shared.module'; -import { customersPersistProvider, CustomersStateService} from './components/store'; +import { CustomersStateService } from './components/store'; @NgModule({ imports: [ @@ -32,10 +31,9 @@ import { customersPersistProvider, CustomersStateService} from './components/sto SharedPnModule, CustomersPnRouting, TranslateModule, - MDBRootModule, NgSelectModule, - FontAwesomeModule, EformSharedModule, + RouterModule, ], declarations: [ CustomerPnLayoutComponent, @@ -51,7 +49,6 @@ import { customersPersistProvider, CustomersStateService} from './components/sto CustomersPnFieldsService, CustomersPnSettingsService, CustomersStateService, - customersPersistProvider, ], }) export class CustomersPnModule {} diff --git a/eform-client/src/app/plugins/modules/customers-pn/layouts/customer-pn-layout.component.ts b/eform-client/src/app/plugins/modules/customers-pn/layouts/customer-pn-layout.component.ts index 01093b08..fed3c482 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/layouts/customer-pn-layout.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/layouts/customer-pn-layout.component.ts @@ -1,23 +1,38 @@ import { AfterContentInit, Component, OnInit } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import { AuthStateService } from 'src/app/common/store'; +import { Store } from '@ngrx/store'; +import { addPluginToVisited, selectPluginsVisitedPlugins } from 'src/app/state'; +import { take } from 'rxjs'; import { translates } from './../i18n/translates'; @Component({ selector: 'app-customers-pn-layout', template: ``, + standalone: false }) export class CustomerPnLayoutComponent implements AfterContentInit, OnInit { + private pluginName = 'customers-pn'; + constructor( private translateService: TranslateService, - private authStateService: AuthStateService - ) {} + store: Store + ) { + store.select(selectPluginsVisitedPlugins) + .pipe(take(1)) + .subscribe(x => { + // check current plugin in activated plugin + if (x.findIndex(y => y === this.pluginName) === -1) { + // add all plugin translates one time + Object.keys(translates).forEach(locale => { + this.translateService.setTranslation(locale, translates[locale], true); + }); + // add plugin to visited plugins + store.dispatch(addPluginToVisited(this.pluginName)); + } + }); + } ngOnInit() {} - ngAfterContentInit() { - const lang = this.authStateService.currentUserLocale; - const i18n = translates[lang]; - this.translateService.setTranslation(lang, i18n, true); - } + ngAfterContentInit() {} } From 147ceaba749d3461c775580359f3970fcfc93745 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 05:33:40 +0000 Subject: [PATCH 3/8] Migrate to ngrx state structure with actions, reducers, and selectors Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com> --- .../store/customers-state.service.ts | 159 +++++++----------- .../customers-pn/customers-pn.module.ts | 5 + .../customers-pn/state/customers-pn.state.ts | 7 + .../state/customers/customers.actions.ts | 18 ++ .../state/customers/customers.reducer.ts | 60 +++++++ .../state/customers/customers.selector.ts | 23 +++ .../customers-pn/state/customers/index.ts | 3 + .../modules/customers-pn/state/index.ts | 2 + 8 files changed, 178 insertions(+), 99 deletions(-) create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/customers-pn.state.ts create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.actions.ts create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.reducer.ts create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.selector.ts create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/customers/index.ts create mode 100644 eform-client/src/app/plugins/modules/customers-pn/state/index.ts diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts index f8e73a69..49b02e30 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/store/customers-state.service.ts @@ -1,160 +1,121 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject, Observable } from 'rxjs'; +import {Injectable} from '@angular/core'; +import {Observable, tap} from 'rxjs'; import { + CommonPaginationState, OperationDataResult, PaginationModel, SortModel, - FiltrationStateModel, - CommonPaginationState, } from 'src/app/common/models'; -import { updateTableSort, getOffset } from 'src/app/common/helpers'; -import { map } from 'rxjs/operators'; -import { CustomersPnService } from '../../services'; -import { CustomersPnModel } from '../../models'; - -export interface CustomersState { - pagination: CommonPaginationState; - filters: FiltrationStateModel; - total: number; -} - -function createInitialState(): CustomersState { - return { - pagination: { - pageSize: 10, - sort: 'Id', - isSortDsc: false, - offset: 0, - }, - filters: { - nameFilter: '', - }, - total: 0, - }; -} - -@Injectable({ providedIn: 'root' }) +import {updateTableSort, getOffset} from 'src/app/common/helpers'; +import {CustomersPnService} from '../../services'; +import {Store} from '@ngrx/store'; +import { + selectCustomersFilters, + selectCustomersPagination, + customersUpdateTotalCustomers, + customersUpdateFilters, + customersUpdatePagination, + CustomersFiltrationModel, + selectCustomersPaginationPageSize, + selectCustomersNameFilters, + selectCustomersTotal, +} from '../../state'; +import {CustomersPnModel} from '../../models'; +import {map} from 'rxjs/operators'; + +@Injectable({providedIn: 'root'}) export class CustomersStateService { - private state$ = new BehaviorSubject(createInitialState()); + private selectCustomersFilters$ = this.store.select(selectCustomersFilters); + private selectCustomersPagination$ = this.store.select(selectCustomersPagination); + currentPagination: CommonPaginationState; + currentFilters: CustomersFiltrationModel; constructor( - private service: CustomersPnService - ) {} - - private get state(): CustomersState { - return this.state$.value; - } - - private updateState(update: Partial) { - this.state$.next({ ...this.state, ...update }); + private store: Store, + private service: CustomersPnService, + ) { + this.selectCustomersPagination$.subscribe(x => this.currentPagination = x); + this.selectCustomersFilters$.subscribe(x => this.currentFilters = x); } getAllCustomers(): Observable> { return this.service .getAllCustomers({ - ...this.state.pagination, - ...this.state.filters, - sortColumnName: this.state.pagination.sort, - name: this.state.filters.nameFilter, + ...this.currentFilters, + ...this.currentPagination, + sortColumnName: this.currentPagination.sort, + name: this.currentFilters.nameFilter, }) .pipe( - map((response) => { + tap((response) => { if (response && response.success && response.model) { - this.updateState({ total: response.model.total }); + this.store.dispatch(customersUpdateTotalCustomers(response.model.total)); } - return response; }) ); } updateNameFilter(nameFilter: string) { - this.updateState({ - filters: { - ...this.state.filters, - nameFilter: nameFilter, - }, - pagination: { - ...this.state.pagination, - offset: 0, - }, - }); + this.store.dispatch(customersUpdateFilters({nameFilter: nameFilter})); + this.store.dispatch(customersUpdatePagination({...this.currentPagination, offset: 0})); } updatePageSize(pageSize: number) { - this.updateState({ - pagination: { - ...this.state.pagination, - pageSize: pageSize, - }, - }); + this.store.dispatch(customersUpdatePagination({...this.currentPagination, pageSize: pageSize})); this.checkOffset(); } getPageSize(): Observable { - return this.state$.pipe(map(state => state.pagination.pageSize)); + return this.store.select(selectCustomersPaginationPageSize); } getSort(): Observable { - return this.state$.pipe( - map(state => new SortModel(state.pagination.sort, state.pagination.isSortDsc)) + return this.selectCustomersPagination$.pipe( + map(pagination => new SortModel(pagination.sort, pagination.isSortDsc)) ); } getNameFilter(): Observable { - return this.state$.pipe(map(state => state.filters.nameFilter)); + return this.store.select(selectCustomersNameFilters); } changePage(offset: number) { - this.updateState({ - pagination: { - ...this.state.pagination, - offset: offset, - }, - }); + this.store.dispatch(customersUpdatePagination({...this.currentPagination, offset: offset})); } onDelete() { - this.updateState({ total: this.state.total - 1 }); + const currentTotal = this.currentPagination.total || 0; + this.store.dispatch(customersUpdateTotalCustomers(currentTotal - 1)); this.checkOffset(); } onSortTable(sort: string) { const localPageSettings = updateTableSort( sort, - this.state.pagination.sort, - this.state.pagination.isSortDsc + this.currentPagination.sort, + this.currentPagination.isSortDsc ); - this.updateState({ - pagination: { - ...this.state.pagination, - isSortDsc: localPageSettings.isSortDsc, - sort: localPageSettings.sort, - }, - }); + this.store.dispatch(customersUpdatePagination({...this.currentPagination, ...localPageSettings})); } checkOffset() { + const currentTotal = this.currentPagination.total || 0; const newOffset = getOffset( - this.state.pagination.pageSize, - this.state.pagination.offset, - this.state.total + this.currentPagination.pageSize, + this.currentPagination.offset, + currentTotal ); - if (newOffset !== this.state.pagination.offset) { - this.updateState({ - pagination: { - ...this.state.pagination, - offset: newOffset, - }, - }); + if (newOffset !== this.currentPagination.offset) { + this.store.dispatch(customersUpdatePagination({...this.currentPagination, offset: newOffset})); } } getPagination(): Observable { - return this.state$.pipe( - map(state => new PaginationModel( - state.total, - state.pagination.pageSize, - state.pagination.offset + return this.store.select(selectCustomersTotal).pipe( + map(total => new PaginationModel( + total, + this.currentPagination.pageSize, + this.currentPagination.offset )) ); } diff --git a/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts b/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts index 9ad9d463..6483585b 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/customers-pn.module.ts @@ -4,6 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { NgSelectModule } from '@ng-select/ng-select'; import { TranslateModule } from '@ngx-translate/core'; import { RouterModule } from '@angular/router'; +import { StoreModule } from '@ngrx/store'; import { CustomerPnLayoutComponent } from './layouts'; import { CustomersPnFieldsService, @@ -22,6 +23,7 @@ import { } from './components'; import { EformSharedModule } from 'src/app/common/modules/eform-shared/eform-shared.module'; import { CustomersStateService } from './components/store'; +import { customersReducer } from './state'; @NgModule({ imports: [ @@ -34,6 +36,9 @@ import { CustomersStateService } from './components/store'; NgSelectModule, EformSharedModule, RouterModule, + StoreModule.forFeature('customersPn', { + customersState: customersReducer, + }), ], declarations: [ CustomerPnLayoutComponent, diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/customers-pn.state.ts b/eform-client/src/app/plugins/modules/customers-pn/state/customers-pn.state.ts new file mode 100644 index 00000000..20484402 --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/customers-pn.state.ts @@ -0,0 +1,7 @@ +import { + CustomersState, +} from './'; + +export interface CustomersPnState { + customersState: CustomersState; +} diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.actions.ts b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.actions.ts new file mode 100644 index 00000000..15dde6ba --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.actions.ts @@ -0,0 +1,18 @@ +import {createAction} from '@ngrx/store'; +import {CommonPaginationState} from 'src/app/common/models'; +import {CustomersFiltrationModel} from './'; + +export const customersUpdateFilters = createAction( + '[Customers] Update Filters', + (payload: CustomersFiltrationModel) => ({payload}) +); + +export const customersUpdatePagination = createAction( + '[Customers] Update Pagination', + (payload: CommonPaginationState) => ({payload}) +); + +export const customersUpdateTotalCustomers = createAction( + '[Customers] Update Total Customers', + (payload: number) => ({payload}) +); diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.reducer.ts b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.reducer.ts new file mode 100644 index 00000000..065e1deb --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.reducer.ts @@ -0,0 +1,60 @@ +import {CommonPaginationState} from 'src/app/common/models'; +import {Action, createReducer, on} from '@ngrx/store'; +import { + customersUpdateFilters, + customersUpdatePagination, + customersUpdateTotalCustomers +} from './customers.actions'; + +export interface CustomersFiltrationModel { + nameFilter: string; +} + +export interface CustomersState { + pagination: CommonPaginationState; + filters: CustomersFiltrationModel; + total: number; +} + +export const customersInitialState: CustomersState = { + pagination: { + pageSize: 10, + sort: 'Id', + isSortDsc: false, + offset: 0, + pageIndex: 0, + total: 0, + }, + filters: { + nameFilter: '', + }, + total: 0, +}; + +export const _customersReducer = createReducer( + customersInitialState, + on(customersUpdateFilters, (state, {payload}) => ({ + ...state, + filters: { + ...state.filters, + ...payload, + }, + })), + on(customersUpdatePagination, (state, {payload}) => ({ + ...state, + pagination: { ...state, ...payload, }, + })), + on(customersUpdateTotalCustomers, (state, {payload}) => ({ + ...state, + pagination: { + ...state.pagination, + total: payload, + }, + total: payload, + } + )), +); + +export function customersReducer(state: CustomersState | undefined, action: Action) { + return _customersReducer(state, action); +} diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.selector.ts b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.selector.ts new file mode 100644 index 00000000..16d36945 --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/customers/customers.selector.ts @@ -0,0 +1,23 @@ +import { + CustomersPnState, +} from '../'; +import {createSelector} from '@ngrx/store'; + +const selectCustomersPn = + (state: {customersPn: CustomersPnState}) => state.customersPn; +export const selectCustomers = + createSelector(selectCustomersPn, (state) => state.customersState); +export const selectCustomersFilters = + createSelector(selectCustomers, (state) => state.filters); +export const selectCustomersPagination = + createSelector(selectCustomers, (state) => state.pagination); +export const selectCustomersPaginationSort = + createSelector(selectCustomers, (state) => state.pagination.sort); +export const selectCustomersPaginationIsSortDsc = + createSelector(selectCustomers, (state) => state.pagination.isSortDsc ? 'desc' : 'asc'); +export const selectCustomersNameFilters = + createSelector(selectCustomers, (state) => state.filters.nameFilter); +export const selectCustomersPaginationPageSize = + createSelector(selectCustomers, (state) => state.pagination.pageSize); +export const selectCustomersTotal = + createSelector(selectCustomers, (state) => state.total); diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/customers/index.ts b/eform-client/src/app/plugins/modules/customers-pn/state/customers/index.ts new file mode 100644 index 00000000..f7aa0b2e --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/customers/index.ts @@ -0,0 +1,3 @@ +export * from './customers.actions'; +export * from './customers.reducer'; +export * from './customers.selector'; diff --git a/eform-client/src/app/plugins/modules/customers-pn/state/index.ts b/eform-client/src/app/plugins/modules/customers-pn/state/index.ts new file mode 100644 index 00000000..14c28e7d --- /dev/null +++ b/eform-client/src/app/plugins/modules/customers-pn/state/index.ts @@ -0,0 +1,2 @@ +export * from './customers'; +export * from './customers-pn.state'; From 5dcf06170b32b82a8dfa505a537da3373a0b5a73 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 06:04:39 +0000 Subject: [PATCH 4/8] Add standalone: false to all component decorators Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com> --- .../components/customer-pn-add/customer-pn-add.component.ts | 3 ++- .../customer-pn-delete/customer-pn-delete.component.ts | 3 ++- .../components/customer-pn-edit/customer-pn-edit.component.ts | 3 ++- .../customer-pn-import/customer-pn-import.component.ts | 1 + .../customers-pn-fields/customers-pn-fields.component.ts | 1 + .../customers-pn-page/customers-pn-page.component.ts | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.ts index bbad5404..e724e0c6 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.ts @@ -6,7 +6,8 @@ import {CustomersPnService} from '../../services'; @Component({ selector: 'app-customer-pn-add', templateUrl: './customer-pn-add.component.html', - styleUrls: ['./customer-pn-add.component.scss'] + styleUrls: ['./customer-pn-add.component.scss'], + standalone: false }) export class CustomerPnAddComponent implements OnInit { @ViewChild('frame', {static: false}) frame; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-delete/customer-pn-delete.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-delete/customer-pn-delete.component.ts index 0456f70a..960dcb3f 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-delete/customer-pn-delete.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-delete/customer-pn-delete.component.ts @@ -7,7 +7,8 @@ import {CustomersPnService} from '../../services'; @Component({ selector: 'app-customer-pn-delete', templateUrl: './customer-pn-delete.component.html', - styleUrls: ['./customer-pn-delete.component.scss'] + styleUrls: ['./customer-pn-delete.component.scss'], + standalone: false }) export class CustomerPnDeleteComponent implements OnInit { @ViewChild('frame', {static: false}) frame; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.ts index 8484f6bd..f44024df 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.ts @@ -6,7 +6,8 @@ import {CustomersPnService} from '../../services'; @Component({ selector: 'app-customer-pn-edit', templateUrl: './customer-pn-edit.component.html', - styleUrls: ['./customer-pn-edit.component.scss'] + styleUrls: ['./customer-pn-edit.component.scss'], + standalone: false }) export class CustomerPnEditComponent implements OnInit { @ViewChild('frame', {static: false}) frame; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-import/customer-pn-import.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-import/customer-pn-import.component.ts index 9dea4099..fa2ebe6d 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-import/customer-pn-import.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-import/customer-pn-import.component.ts @@ -12,6 +12,7 @@ const URL = ''; selector: 'app-customer-pn-import', templateUrl: './customer-pn-import.component.html', styleUrls: ['./customer-pn-import.component.scss'], + standalone: false }) export class CustomerPnImportComponent implements OnInit { public data: any = []; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-fields/customers-pn-fields.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-fields/customers-pn-fields.component.ts index 8be56e9b..3e982d5c 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-fields/customers-pn-fields.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-fields/customers-pn-fields.component.ts @@ -16,6 +16,7 @@ import { selector: 'app-customers-pn-fields', templateUrl: './customers-pn-fields.component.html', styleUrls: ['./customers-pn-fields.component.scss'], + standalone: false }) export class CustomersPnFieldsComponent implements OnInit { isChecked = false; diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-page/customers-pn-page.component.ts b/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-page/customers-pn-page.component.ts index 10e9c8b5..27387da0 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-page/customers-pn-page.component.ts +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customers-pn-page/customers-pn-page.component.ts @@ -20,6 +20,7 @@ import { CustomersStateService } from '../store'; selector: 'app-customers-pn-page', templateUrl: './customers-pn-page.component.html', styleUrls: ['./customers-pn-page.component.scss'], + standalone: false }) export class CustomersPnPageComponent implements OnInit { @ViewChild('createCustomerModal', { static: false }) createCustomerModal; From f53064e2f0bca7efde3094d3eba3d5310f920c49 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 3 Oct 2025 06:19:40 +0000 Subject: [PATCH 5/8] Start migration from MDBModal to Angular Material Dialog - convert edit modal Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com> --- .../customer-pn-edit.component.html | 430 ++++++++---------- .../customer-pn-edit.component.ts | 29 +- .../customers-pn/customers-pn.module.ts | 8 + 3 files changed, 227 insertions(+), 240 deletions(-) diff --git a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.html b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.html index c46f9950..74a5ce97 100644 --- a/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.html +++ b/eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-edit/customer-pn-edit.component.html @@ -1,236 +1,206 @@ -