feat(core-tabs): Move Core-Process to Core-Tabs

This commit is contained in:
Nino
2025-06-16 15:05:30 +02:00
parent 083f75a395
commit e41dbc2870
33 changed files with 77 additions and 45 deletions

View File

@@ -18,7 +18,11 @@ import { CanActivateAssortmentGuard } from './guards/can-activate-assortment.gua
import { CanActivatePackageInspectionGuard } from './guards/can-activate-package-inspection.guard';
import { MainComponent } from './main.component';
import { PreviewComponent } from './preview';
import { BranchSectionResolver, CustomerSectionResolver, ProcessIdResolver } from './resolvers';
import {
BranchSectionResolver,
CustomerSectionResolver,
ProcessIdResolver,
} from './resolvers';
import { TokenLoginComponent, TokenLoginModule } from './token-login';
import { ProcessIdGuard } from './guards/process-id.guard';
import {
@@ -26,7 +30,7 @@ import {
ActivateProcessIdWithConfigKeyGuard,
} from './guards/activate-process-id.guard';
import { MatomoRouteData } from 'ngx-matomo-client';
import { processResolverFn } from '@isa/core/process';
import { processResolverFn } from '@isa/core/tabs';
import { provideScrollPositionRestoration } from '@isa/utils/scroll-position';
const routes: Routes = [
@@ -48,7 +52,8 @@ const routes: Routes = [
children: [
{
path: 'dashboard',
loadChildren: () => import('@page/dashboard').then((m) => m.DashboardModule),
loadChildren: () =>
import('@page/dashboard').then((m) => m.DashboardModule),
data: {
matomo: {
title: 'Dashboard',
@@ -57,57 +62,67 @@ const routes: Routes = [
},
{
path: 'product',
loadChildren: () => import('@page/catalog').then((m) => m.PageCatalogModule),
loadChildren: () =>
import('@page/catalog').then((m) => m.PageCatalogModule),
canActivate: [CanActivateProductGuard],
},
{
path: ':processId/product',
loadChildren: () => import('@page/catalog').then((m) => m.PageCatalogModule),
loadChildren: () =>
import('@page/catalog').then((m) => m.PageCatalogModule),
canActivate: [CanActivateProductWithProcessIdGuard],
resolve: { processId: ProcessIdResolver },
},
{
path: 'order',
loadChildren: () => import('@page/customer-order').then((m) => m.CustomerOrderModule),
loadChildren: () =>
import('@page/customer-order').then((m) => m.CustomerOrderModule),
canActivate: [CanActivateCustomerOrdersGuard],
},
{
path: ':processId/order',
loadChildren: () => import('@page/customer-order').then((m) => m.CustomerOrderModule),
loadChildren: () =>
import('@page/customer-order').then((m) => m.CustomerOrderModule),
canActivate: [CanActivateCustomerOrdersWithProcessIdGuard],
resolve: { processId: ProcessIdResolver },
},
{
path: 'customer',
loadChildren: () => import('@page/customer').then((m) => m.CustomerModule),
loadChildren: () =>
import('@page/customer').then((m) => m.CustomerModule),
canActivate: [CanActivateCustomerGuard],
},
{
path: ':processId/customer',
loadChildren: () => import('@page/customer').then((m) => m.CustomerModule),
loadChildren: () =>
import('@page/customer').then((m) => m.CustomerModule),
canActivate: [CanActivateCustomerWithProcessIdGuard],
resolve: { processId: ProcessIdResolver },
},
{
path: 'cart',
loadChildren: () => import('@page/checkout').then((m) => m.PageCheckoutModule),
loadChildren: () =>
import('@page/checkout').then((m) => m.PageCheckoutModule),
canActivate: [CanActivateCartGuard],
},
{
path: ':processId/cart',
loadChildren: () => import('@page/checkout').then((m) => m.PageCheckoutModule),
loadChildren: () =>
import('@page/checkout').then((m) => m.PageCheckoutModule),
canActivate: [CanActivateCartWithProcessIdGuard],
},
{
path: 'pickup-shelf',
canActivate: [ProcessIdGuard],
// NOTE: This is a workaround for the canActivate guard not being called
loadChildren: () => import('@page/pickup-shelf').then((m) => m.PickupShelfOutModule),
loadChildren: () =>
import('@page/pickup-shelf').then((m) => m.PickupShelfOutModule),
},
{
path: ':processId/pickup-shelf',
canActivate: [ActivateProcessIdGuard],
loadChildren: () => import('@page/pickup-shelf').then((m) => m.PickupShelfOutModule),
loadChildren: () =>
import('@page/pickup-shelf').then((m) => m.PickupShelfOutModule),
},
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
],
@@ -119,34 +134,43 @@ const routes: Routes = [
children: [
{
path: 'task-calendar',
loadChildren: () => import('@page/task-calendar').then((m) => m.PageTaskCalendarModule),
loadChildren: () =>
import('@page/task-calendar').then(
(m) => m.PageTaskCalendarModule,
),
canActivate: [CanActivateTaskCalendarGuard],
},
{
path: 'pickup-shelf',
canActivate: [ActivateProcessIdWithConfigKeyGuard('pickupShelf')],
// NOTE: This is a workaround for the canActivate guard not being called
loadChildren: () => import('@page/pickup-shelf').then((m) => m.PickupShelfInModule),
loadChildren: () =>
import('@page/pickup-shelf').then((m) => m.PickupShelfInModule),
},
{
path: 'goods/in',
loadChildren: () => import('@page/goods-in').then((m) => m.GoodsInModule),
loadChildren: () =>
import('@page/goods-in').then((m) => m.GoodsInModule),
canActivate: [CanActivateGoodsInGuard],
},
{
path: 'remission',
loadChildren: () => import('@page/remission').then((m) => m.PageRemissionModule),
loadChildren: () =>
import('@page/remission').then((m) => m.PageRemissionModule),
canActivate: [CanActivateRemissionGuard],
},
{
path: 'package-inspection',
loadChildren: () =>
import('@page/package-inspection').then((m) => m.PackageInspectionModule),
import('@page/package-inspection').then(
(m) => m.PackageInspectionModule,
),
canActivate: [CanActivatePackageInspectionGuard],
},
{
path: 'assortment',
loadChildren: () => import('@page/assortment').then((m) => m.AssortmentModule),
loadChildren: () =>
import('@page/assortment').then((m) => m.AssortmentModule),
canActivate: [CanActivateAssortmentGuard],
},
{ path: '**', redirectTo: 'task-calendar', pathMatch: 'full' },
@@ -163,7 +187,8 @@ const routes: Routes = [
children: [
{
path: 'return',
loadChildren: () => import('@isa/oms/feature/return-search').then((m) => m.routes),
loadChildren: () =>
import('@isa/oms/feature/return-search').then((m) => m.routes),
},
],
},

View File

@@ -4,7 +4,7 @@ import {
Inject,
ChangeDetectorRef,
inject,
DOCUMENT
DOCUMENT,
} from '@angular/core';
import { AuthModule, AuthService } from '@core/auth';
import { StockService } from '@generated/swagger/wws-api';
@@ -29,7 +29,7 @@ import {
ProductCatalogNavigationService,
} from '@shared/services/navigation';
import { ProcessService } from '@isa/core/process';
import { ProcessService } from '@isa/core/tabs';
import { NgIconComponent, provideIcons } from '@ng-icons/core';
import { isaNavigationReturn } from '@isa/icons';

View File

@@ -1,7 +1,7 @@
# core-process
# core-tabs
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test core-process` to execute the unit tests.
Run `nx test core-tabs` to execute the unit tests.

View File

@@ -1,5 +1,5 @@
import nx from '@nx/eslint-plugin';
import baseConfig from '../../../eslint.config.mjs';
import baseConfig from '../../../eslint.config.js';
export default [
...baseConfig,

View File

@@ -1,8 +1,8 @@
export default {
displayName: 'core-process',
displayName: 'core-tabs',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../../coverage/libs/core/process',
coverageDirectory: '../../../coverage/libs/core/tabs',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',

View File

@@ -1,7 +1,7 @@
{
"name": "core-process",
"name": "core-tabs",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/core/process/src",
"sourceRoot": "libs/core/tabs/src",
"prefix": "lib",
"projectType": "library",
"tags": [],
@@ -10,7 +10,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/core/process/jest.config.ts"
"jestConfig": "libs/core/tabs/jest.config.ts"
}
},
"lint": {

View File

@@ -20,10 +20,14 @@ import { computed, effect } from '@angular/core';
export const ProcessService = signalStore(
{ providedIn: 'root' },
withState<{ activatedProcessId: number | null }>({ activatedProcessId: null }),
withState<{ activatedProcessId: number | null }>({
activatedProcessId: null,
}),
withEntities<Process>(),
withComputed((store) => ({
nextId: computed(() => Math.max(0, ...store.entities().map((e) => e.id)) + 1),
nextId: computed(
() => Math.max(0, ...store.entities().map((e) => e.id)) + 1,
),
activatedProcess: computed<Process | null>(() => {
const activeProcessId = store.activatedProcessId();
if (activeProcessId === null) {
@@ -51,7 +55,10 @@ export const ProcessService = signalStore(
});
},
patchProcess(id: number, changes: z.infer<typeof PatchProcessSchema>) {
patchState(store, updateEntity({ id, changes: PatchProcessSchema.parse(changes) }));
patchState(
store,
updateEntity({ id, changes: PatchProcessSchema.parse(changes) }),
);
},
removeProcess(id: number) {
patchState(store, removeEntity(id));

View File

@@ -1,7 +1,7 @@
import { createServiceFactory } from '@ngneat/spectator/jest';
import { ReturnProcessStore } from './return-process.store';
import { IDBStorageProvider } from '@isa/core/storage';
import { ProcessService } from '@isa/core/process';
import { ProcessService } from '@isa/core/tabs';
import { patchState } from '@ngrx/signals';
import { setAllEntities, setEntity } from '@ngrx/signals/entities';
import { unprotected } from '@ngrx/signals/testing';

View File

@@ -13,7 +13,7 @@ import {
} from '@ngrx/signals/entities';
import { IDBStorageProvider, withStorage } from '@isa/core/storage';
import { computed, effect, inject } from '@angular/core';
import { ProcessService } from '@isa/core/process';
import { ProcessService } from '@isa/core/tabs';
import { Receipt, ReceiptItem, ReturnProcess } from '../models';
import {
CreateReturnProcessError,

View File

@@ -26,7 +26,7 @@ import {
import { ReceiptListItem } from '../models';
import { Query } from '@isa/shared/filter';
import { SessionStorageProvider, withStorage } from '@isa/core/storage';
import { ProcessService } from '@isa/core/process';
import { ProcessService } from '@isa/core/tabs';
/**
* Enum representing the status of a return search process.

View File

@@ -13,7 +13,7 @@ import { z } from 'zod';
import { NgIconComponent, provideIcons } from '@ng-icons/core';
import { isaActionChevronLeft } from '@isa/icons';
import { ButtonComponent } from '@isa/ui/buttons';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { Location } from '@angular/common';
import { ExpandableDirectives } from '@isa/ui/expandable';
import { ProgressBarComponent } from '@isa/ui/progress-bar';

View File

@@ -18,7 +18,7 @@ import {
ReturnProcessService,
ReturnProcessStore,
} from '@isa/oms/data-access';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { ReturnProcessItemComponent } from './return-process-item/return-process-item.component';
import { Location } from '@angular/common';
import { RouterLink } from '@angular/router';

View File

@@ -1,7 +1,7 @@
import { computed, inject, Injectable } from '@angular/core';
import { CanDeactivate } from '@angular/router';
import { firstValueFrom } from 'rxjs';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { ReturnTaskListStore } from '@isa/oms/data-access';
import { ReturnReviewComponent } from '../return-review.component';
import { ConfirmationDialogComponent, injectDialog } from '@isa/ui/dialog';

View File

@@ -1,6 +1,6 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { PrintReceiptsService, ReturnProcessStore } from '@isa/oms/data-access';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { ReturnTaskListComponent } from '@isa/oms/shared/task-list';
import { ReturnReviewHeaderComponent } from './return-review-header/return-review-header.component';

View File

@@ -6,7 +6,7 @@ import {
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { CallbackResult, ListResponseArgs } from '@isa/common/data-access';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import {
ReceiptListItem,
ReturnSearchStatus,

View File

@@ -6,7 +6,7 @@ import {
inject,
linkedSignal,
} from '@angular/core';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import {

View File

@@ -6,7 +6,7 @@ import {
signal,
} from '@angular/core';
import { ReturnSummaryItemComponent } from './return-summary-item/return-summary-item.component';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import {
ReturnProcess,
ReturnProcessService,

View File

@@ -20,7 +20,7 @@ import {
} from '@isa/oms/data-access';
import { IconButtonComponent } from '@isa/ui/buttons';
import { firstValueFrom } from 'rxjs';
import { injectActivatedProcessId } from '@isa/core/process';
import { injectActivatedProcessId } from '@isa/core/tabs';
import { logger, provideLoggerContext } from '@isa/core/logging';
// TODO: Komponente und logik benötigt review

View File

@@ -45,8 +45,8 @@
"@isa/core/config": ["libs/core/config/src/index.ts"],
"@isa/core/logging": ["libs/core/logging/src/index.ts"],
"@isa/core/notifications": ["libs/core/notifications/src/index.ts"],
"@isa/core/process": ["libs/core/process/src/index.ts"],
"@isa/core/storage": ["libs/core/storage/src/index.ts"],
"@isa/core/tabs": ["libs/core/tabs/src/index.ts"],
"@isa/icons": ["libs/icons/src/index.ts"],
"@isa/oms/data-access": ["libs/oms/data-access/src/index.ts"],
"@isa/oms/feature/return-details": [