mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
feat(core-tabs): Changes due to Renaming from Process to Tab and Unit Test Fixes
This commit is contained in:
@@ -30,7 +30,7 @@ import {
|
||||
ActivateProcessIdWithConfigKeyGuard,
|
||||
} from './guards/activate-process-id.guard';
|
||||
import { MatomoRouteData } from 'ngx-matomo-client';
|
||||
import { processResolverFn } from '@isa/core/tabs';
|
||||
import { tabResolverFn } from '@isa/core/tabs';
|
||||
import { provideScrollPositionRestoration } from '@isa/utils/scroll-position';
|
||||
|
||||
const routes: Routes = [
|
||||
@@ -180,9 +180,9 @@ const routes: Routes = [
|
||||
],
|
||||
},
|
||||
{
|
||||
path: ':processId',
|
||||
path: ':tabId',
|
||||
component: MainComponent,
|
||||
resolve: { process: processResolverFn },
|
||||
resolve: { process: tabResolverFn, tab: tabResolverFn },
|
||||
canActivate: [IsAuthenticatedGuard],
|
||||
children: [
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/product"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<div class="side-menu-group-item-icon">
|
||||
<shared-icon icon="import-contacts"></shared-icon>
|
||||
</div>
|
||||
@@ -25,7 +25,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/customer"
|
||||
(isActiveChange)="customerActive($event); focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="person"></shared-icon>
|
||||
</span>
|
||||
@@ -33,10 +33,12 @@
|
||||
<button
|
||||
class="side-menu-group-arrow"
|
||||
[class.side-menu-item-rotate]="customerExpanded"
|
||||
(click)="
|
||||
$event.stopPropagation(); $event.preventDefault(); customerExpanded = !customerExpanded
|
||||
"
|
||||
>
|
||||
(click)="
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
customerExpanded = !customerExpanded
|
||||
"
|
||||
>
|
||||
<shared-icon icon="keyboard-arrow-down"></shared-icon>
|
||||
</button>
|
||||
</a>
|
||||
@@ -52,7 +54,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/customer\/(\(search|search)"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Suchen</span>
|
||||
</a>
|
||||
@@ -65,7 +67,7 @@
|
||||
[queryParams]="customerCreateRoute.queryParams"
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/customer\/(\(create|create)"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Erfassen</span>
|
||||
</a>
|
||||
@@ -81,7 +83,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/pickup-shelf"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="unarchive"></shared-icon>
|
||||
</span>
|
||||
@@ -93,11 +95,11 @@
|
||||
(click)="closeSideMenu(); focusSearchBox()"
|
||||
[routerLink]="[
|
||||
'/',
|
||||
processService.activatedProcess()?.id || processService.nextId(),
|
||||
processService.activatedTab()?.id || processService.nextId(),
|
||||
'return',
|
||||
]"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon w-[2.375rem] h-12">
|
||||
<ng-icon name="isaNavigationReturn"></ng-icon>
|
||||
</span>
|
||||
@@ -112,7 +114,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/kunde\/\d*\/order"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="deployed-code"></shared-icon>
|
||||
</span>
|
||||
@@ -132,7 +134,7 @@
|
||||
[queryParams]="taskCalenderNavigation.queryParams"
|
||||
routerLinkActive="active"
|
||||
(isActiveChange)="focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="event-available"></shared-icon>
|
||||
</span>
|
||||
@@ -146,7 +148,7 @@
|
||||
[routerLink]="assortmentNavigation.path"
|
||||
[queryParams]="assortmentNavigation.queryParams"
|
||||
routerLinkActive="active"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="shape-outline"></shared-icon>
|
||||
</span>
|
||||
@@ -164,7 +166,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
sharedRegexRouterLinkActiveTest="^\/filiale\/(pickup-shelf|goods\/in)"
|
||||
(isActiveChange)="shelfActive($event); focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="isa-abholfach"></shared-icon>
|
||||
</span>
|
||||
@@ -172,10 +174,12 @@
|
||||
<button
|
||||
class="side-menu-group-arrow"
|
||||
[class.side-menu-item-rotate]="shelfExpanded"
|
||||
(click)="
|
||||
$event.stopPropagation(); $event.preventDefault(); shelfExpanded = !shelfExpanded
|
||||
"
|
||||
>
|
||||
(click)="
|
||||
$event.stopPropagation();
|
||||
$event.preventDefault();
|
||||
shelfExpanded = !shelfExpanded
|
||||
"
|
||||
>
|
||||
<shared-icon icon="keyboard-arrow-down"></shared-icon>
|
||||
</button>
|
||||
</a>
|
||||
@@ -192,7 +196,7 @@
|
||||
sharedRegexRouterLinkActive="active"
|
||||
[sharedRegexRouterLinkActiveTest]="'^\/filiale\/pickup-shelf'"
|
||||
(isActiveChange)="shelfActive($event); focusSearchBox()"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Einbuchen</span>
|
||||
</a>
|
||||
@@ -205,7 +209,7 @@
|
||||
[class.active-child]="(currentShelfView$ | async) === 'reservation'"
|
||||
routerLinkActive="active"
|
||||
(isActiveChange)="shelfActive($event)"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Reservierung</span>
|
||||
</a>
|
||||
@@ -217,7 +221,7 @@
|
||||
[class.active-child]="(currentShelfView$ | async) === 'cleanup'"
|
||||
routerLinkActive="active"
|
||||
(isActiveChange)="shelfActive($event)"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Ausräumen</span>
|
||||
</a>
|
||||
@@ -229,7 +233,7 @@
|
||||
[class.active-child]="(currentShelfView$ | async) === 'remission'"
|
||||
routerLinkActive="active"
|
||||
(isActiveChange)="shelfActive($event)"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Remi-Vorschau</span>
|
||||
</a>
|
||||
@@ -238,10 +242,12 @@
|
||||
(click)="closeSideMenu()"
|
||||
[routerLink]="['/filiale', 'goods', 'in', 'list']"
|
||||
[queryParams]="{ view: 'wareneingangsliste' }"
|
||||
[class.active-child]="(currentShelfView$ | async) === 'wareneingangsliste'"
|
||||
[class.active-child]="
|
||||
(currentShelfView$ | async) === 'wareneingangsliste'
|
||||
"
|
||||
routerLinkActive="active"
|
||||
(isActiveChange)="shelfActive($event)"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon"></span>
|
||||
<span class="side-menu-group-item-label">Fehlende</span>
|
||||
</a>
|
||||
@@ -255,7 +261,7 @@
|
||||
[routerLink]="remissionNavigation.path"
|
||||
[queryParams]="remissionNavigation.queryParams"
|
||||
routerLinkActive="active"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="assignment-return"></shared-icon>
|
||||
</span>
|
||||
@@ -270,7 +276,7 @@
|
||||
[routerLink]="packageInspectionNavigation.path"
|
||||
[queryParams]="packageInspectionNavigation.queryParams"
|
||||
routerLinkActive="active"
|
||||
>
|
||||
>
|
||||
<span class="side-menu-group-item-icon">
|
||||
<shared-icon icon="clipboard-check-outline"></shared-icon>
|
||||
</span>
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
ProductCatalogNavigationService,
|
||||
} from '@shared/services/navigation';
|
||||
|
||||
import { ProcessService } from '@isa/core/tabs';
|
||||
import { TabService } from '@isa/core/tabs';
|
||||
import { NgIconComponent, provideIcons } from '@ng-icons/core';
|
||||
import { isaNavigationReturn } from '@isa/icons';
|
||||
|
||||
@@ -49,7 +49,7 @@ import { isaNavigationReturn } from '@isa/icons';
|
||||
providers: [provideIcons({ isaNavigationReturn })],
|
||||
})
|
||||
export class ShellSideMenuComponent {
|
||||
processService = inject(ProcessService);
|
||||
processService = inject(TabService);
|
||||
|
||||
branchKey$ = this._stockService.StockCurrentBranch().pipe(
|
||||
retry(3),
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
const nx = require('@nx/eslint-plugin');
|
||||
|
||||
module.exports = [
|
||||
...nx.configs['flat/base'],
|
||||
...nx.configs['flat/typescript'],
|
||||
...nx.configs['flat/javascript'],
|
||||
{
|
||||
ignores: ['**/dist'],
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
||||
rules: {
|
||||
'@nx/enforce-module-boundaries': [
|
||||
'error',
|
||||
{
|
||||
enforceBuildableLibDependency: true,
|
||||
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
|
||||
depConstraints: [
|
||||
{
|
||||
sourceTag: '*',
|
||||
onlyDependOnLibsWithTags: ['*'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
||||
// Override or add rules here
|
||||
rules: {},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
rules: {
|
||||
'@nx/dependency-checks': [
|
||||
'error',
|
||||
{
|
||||
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parser: require('jsonc-eslint-parser'),
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
rules: {
|
||||
'@nx/dependency-checks': [
|
||||
'error',
|
||||
{
|
||||
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parser: require('jsonc-eslint-parser'),
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
rules: {
|
||||
'@nx/dependency-checks': [
|
||||
'error',
|
||||
{
|
||||
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parser: require('jsonc-eslint-parser'),
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
rules: {
|
||||
'@nx/dependency-checks': [
|
||||
'error',
|
||||
{
|
||||
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parser: require('jsonc-eslint-parser'),
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,6 +1,7 @@
|
||||
import nx from '@nx/eslint-plugin';
|
||||
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||
import prettierPlugin from 'eslint-plugin-prettier';
|
||||
import jsoncEslintParser from 'jsonc-eslint-parser';
|
||||
|
||||
export default [
|
||||
...nx.configs['flat/base'],
|
||||
@@ -46,4 +47,18 @@ export default [
|
||||
'prettier/prettier': 'error',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.json'],
|
||||
rules: {
|
||||
'@nx/dependency-checks': [
|
||||
'error',
|
||||
{
|
||||
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parser: jsoncEslintParser,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from './lib/process';
|
||||
export * from './lib/process.injector';
|
||||
export * from './lib/process.resolver-fn';
|
||||
export * from './lib/process.schemas';
|
||||
export * from './lib/process.service';
|
||||
export * from './lib/tab';
|
||||
export * from './lib/tab.injector';
|
||||
export * from './lib/tab.resolver-fn';
|
||||
export * from './lib/tab.schemas';
|
||||
export * from './lib/tab.service';
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ProcessService } from './process.service';
|
||||
|
||||
export function injectActivatedProcessId() {
|
||||
return inject(ProcessService).activatedProcessId;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { ProcessService } from './process.service';
|
||||
import { Process } from './process';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const processResolverFn: ResolveFn<Process> = (route) => {
|
||||
const id = parseInt(route.params['processId']);
|
||||
const processService = inject(ProcessService);
|
||||
let process = processService.entityMap()[id];
|
||||
|
||||
if (!process) {
|
||||
process = processService.addProcess({
|
||||
name: 'New Process',
|
||||
tags: ['return'],
|
||||
});
|
||||
}
|
||||
|
||||
processService.activateProcess(process.id);
|
||||
return process;
|
||||
};
|
||||
6
libs/core/tabs/src/lib/tab.injector.ts
Normal file
6
libs/core/tabs/src/lib/tab.injector.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { TabService } from './tab.service';
|
||||
|
||||
export function injectActivatedTabId() {
|
||||
return inject(TabService).activatedTabId;
|
||||
}
|
||||
20
libs/core/tabs/src/lib/tab.resolver-fn.ts
Normal file
20
libs/core/tabs/src/lib/tab.resolver-fn.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import { TabService } from './tab.service';
|
||||
import { Tab } from './tab';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const tabResolverFn: ResolveFn<Tab> = (route) => {
|
||||
const id = parseInt(route.params['tabId']);
|
||||
const tabService = inject(TabService);
|
||||
let tab = tabService.entityMap()[id];
|
||||
|
||||
if (!tab) {
|
||||
tab = tabService.addTab({
|
||||
name: 'Neuer Vorgang',
|
||||
tags: [],
|
||||
});
|
||||
}
|
||||
|
||||
tabService.activateTab(tab.id);
|
||||
return tab;
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const AddProcessSchema = z.object({
|
||||
export const AddTabSchema = z.object({
|
||||
name: z.string().nonempty(),
|
||||
tags: z.array(z.string()),
|
||||
});
|
||||
|
||||
export const PatchProcessSchema = z.object({
|
||||
export const PatchTabSchema = z.object({
|
||||
name: z.string().nonempty().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
});
|
||||
@@ -13,60 +13,60 @@ import {
|
||||
updateEntity,
|
||||
withEntities,
|
||||
} from '@ngrx/signals/entities';
|
||||
import { Process } from './process';
|
||||
import { Tab } from './tab';
|
||||
import { z } from 'zod';
|
||||
import { AddProcessSchema, PatchProcessSchema } from './process.schemas';
|
||||
import { AddTabSchema, PatchTabSchema } from './tab.schemas';
|
||||
import { computed, effect } from '@angular/core';
|
||||
|
||||
export const ProcessService = signalStore(
|
||||
export const TabService = signalStore(
|
||||
{ providedIn: 'root' },
|
||||
withState<{ activatedProcessId: number | null }>({
|
||||
activatedProcessId: null,
|
||||
withState<{ activatedTabId: number | null }>({
|
||||
activatedTabId: null,
|
||||
}),
|
||||
withEntities<Process>(),
|
||||
withEntities<Tab>(),
|
||||
withComputed((store) => ({
|
||||
nextId: computed(
|
||||
() => Math.max(0, ...store.entities().map((e) => e.id)) + 1,
|
||||
),
|
||||
activatedProcess: computed<Process | null>(() => {
|
||||
const activeProcessId = store.activatedProcessId();
|
||||
if (activeProcessId === null) {
|
||||
activatedTab: computed<Tab | null>(() => {
|
||||
const activeTabId = store.activatedTabId();
|
||||
if (activeTabId === null) {
|
||||
return null;
|
||||
}
|
||||
return store.entities().find((e) => e.id === activeProcessId) ?? null;
|
||||
return store.entities().find((e) => e.id === activeTabId) ?? null;
|
||||
}),
|
||||
})),
|
||||
withMethods((store) => ({
|
||||
addProcess(add: z.infer<typeof AddProcessSchema>) {
|
||||
const parsed = AddProcessSchema.parse(add);
|
||||
const process: Process = {
|
||||
addTab(add: z.infer<typeof AddTabSchema>) {
|
||||
const parsed = AddTabSchema.parse(add);
|
||||
const tab: Tab = {
|
||||
name: parsed.name,
|
||||
id: store.nextId(),
|
||||
createdAt: Date.now(),
|
||||
tags: parsed.tags,
|
||||
};
|
||||
patchState(store, addEntity(process));
|
||||
return process;
|
||||
patchState(store, addEntity(tab));
|
||||
return tab;
|
||||
},
|
||||
activateProcess(id: number) {
|
||||
activateTab(id: number) {
|
||||
patchState(store, {
|
||||
...updateEntity({ id, changes: { activatedAt: Date.now() } }),
|
||||
activatedProcessId: id,
|
||||
activatedTabId: id,
|
||||
});
|
||||
},
|
||||
patchProcess(id: number, changes: z.infer<typeof PatchProcessSchema>) {
|
||||
patchTab(id: number, changes: z.infer<typeof PatchTabSchema>) {
|
||||
patchState(
|
||||
store,
|
||||
updateEntity({ id, changes: PatchProcessSchema.parse(changes) }),
|
||||
updateEntity({ id, changes: PatchTabSchema.parse(changes) }),
|
||||
);
|
||||
},
|
||||
removeProcess(id: number) {
|
||||
removeTab(id: number) {
|
||||
patchState(store, removeEntity(id));
|
||||
},
|
||||
})),
|
||||
withHooks((store) => ({
|
||||
onInit() {
|
||||
const entitiesStr = localStorage.getItem('ProcessEntities');
|
||||
const entitiesStr = localStorage.getItem('TabEntities');
|
||||
if (entitiesStr) {
|
||||
const entities = JSON.parse(entitiesStr);
|
||||
patchState(store, addEntities(entities));
|
||||
@@ -74,7 +74,7 @@ export const ProcessService = signalStore(
|
||||
|
||||
effect(() => {
|
||||
const state = store.entities();
|
||||
localStorage.setItem('ProcessEntities', JSON.stringify(state));
|
||||
localStorage.setItem('TabEntities', JSON.stringify(state));
|
||||
});
|
||||
},
|
||||
})),
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface Process {
|
||||
export interface Tab {
|
||||
id: number;
|
||||
name: string;
|
||||
tags: string[];
|
||||
@@ -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/tabs';
|
||||
import { TabService } from '@isa/core/tabs';
|
||||
import { patchState } from '@ngrx/signals';
|
||||
import { setAllEntities, setEntity } from '@ngrx/signals/entities';
|
||||
import { unprotected } from '@ngrx/signals/testing';
|
||||
@@ -47,7 +47,7 @@ const TEST_ITEMS: Record<number, ReturnProcess['receiptItem']> = {
|
||||
describe('ReturnProcessStore', () => {
|
||||
const createService = createServiceFactory({
|
||||
service: ReturnProcessStore,
|
||||
mocks: [IDBStorageProvider, ProcessService],
|
||||
mocks: [IDBStorageProvider, TabService],
|
||||
});
|
||||
|
||||
describe('Initialization', () => {
|
||||
|
||||
@@ -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/tabs';
|
||||
import { TabService } from '@isa/core/tabs';
|
||||
import { Receipt, ReceiptItem, ReturnProcess } from '../models';
|
||||
import {
|
||||
CreateReturnProcessError,
|
||||
@@ -194,17 +194,17 @@ export const ReturnProcessStore = signalStore(
|
||||
},
|
||||
})),
|
||||
|
||||
withHooks((store, processService = inject(ProcessService)) => ({
|
||||
withHooks((store, tabService = inject(TabService)) => ({
|
||||
/**
|
||||
* Lifecycle hook that runs when the store is initialized.
|
||||
* Sets up an effect to clean up orphaned entities that are no longer associated with active processes.
|
||||
*/
|
||||
onInit() {
|
||||
effect(() => {
|
||||
const processIds = processService.ids();
|
||||
const tabIds = tabService.ids();
|
||||
const orphanedEntity = store
|
||||
.entities()
|
||||
.find((entity) => !processIds.includes(entity.processId));
|
||||
.find((entity) => !tabIds.includes(entity.processId));
|
||||
if (orphanedEntity) {
|
||||
store.removeAllEntitiesByProcessId(orphanedEntity.processId);
|
||||
}
|
||||
|
||||
@@ -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/tabs';
|
||||
import { TabService } from '@isa/core/tabs';
|
||||
|
||||
/**
|
||||
* Enum representing the status of a return search process.
|
||||
@@ -262,13 +262,13 @@ export const ReturnSearchStore = signalStore(
|
||||
),
|
||||
),
|
||||
})),
|
||||
withHooks((store, processService = inject(ProcessService)) => ({
|
||||
withHooks((store, tabService = inject(TabService)) => ({
|
||||
onInit() {
|
||||
effect(() => {
|
||||
const processIds = processService.ids();
|
||||
const tabIds = tabService.ids();
|
||||
const orphanedEntity = store
|
||||
.entities()
|
||||
.find((entity) => !processIds.includes(entity.processId));
|
||||
.find((entity) => !tabIds.includes(entity.processId));
|
||||
if (orphanedEntity) {
|
||||
store.removeAllEntitiesByProcessId(orphanedEntity.processId);
|
||||
}
|
||||
|
||||
@@ -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/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import { Location } from '@angular/common';
|
||||
import { ExpandableDirectives } from '@isa/ui/expandable';
|
||||
import { ProgressBarComponent } from '@isa/ui/progress-bar';
|
||||
@@ -53,7 +53,7 @@ export class ReturnDetailsComponent {
|
||||
#returnDetailsService = inject(ReturnDetailsService);
|
||||
#returnProcessStore = inject(ReturnProcessStore);
|
||||
|
||||
private processId = injectActivatedProcessId();
|
||||
private processId = injectActivatedTabId();
|
||||
|
||||
private _router = inject(Router);
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import { ReturnProcessItemComponent } from './return-process-item/return-process
|
||||
import { ReturnProcessComponent } from './return-process.component';
|
||||
|
||||
const mockActivatedProcessIdSignal = signal<number | null>(123);
|
||||
jest.mock('@isa/core/process', () => ({
|
||||
injectActivatedProcessId: jest.fn(() => mockActivatedProcessIdSignal),
|
||||
jest.mock('@isa/core/tabs', () => ({
|
||||
injectActivatedTabId: jest.fn(() => mockActivatedProcessIdSignal),
|
||||
}));
|
||||
|
||||
jest.mock('scandit-web-datacapture-core', () => ({}));
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
ReturnProcessService,
|
||||
ReturnProcessStore,
|
||||
} from '@isa/oms/data-access';
|
||||
import { injectActivatedProcessId } from '@isa/core/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import { ReturnProcessItemComponent } from './return-process-item/return-process-item.component';
|
||||
import { Location } from '@angular/common';
|
||||
import { RouterLink } from '@angular/router';
|
||||
@@ -58,7 +58,7 @@ export class ReturnProcessComponent {
|
||||
#logger = logger();
|
||||
|
||||
/** Signal emitting the numeric ID of the currently active return process, derived from the route parameters. Null if no ID is present. */
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
#returnCanReturnService = inject(ReturnCanReturnService);
|
||||
|
||||
|
||||
@@ -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/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import { ReturnTaskListStore } from '@isa/oms/data-access';
|
||||
import { ReturnReviewComponent } from '../return-review.component';
|
||||
import { ConfirmationDialogComponent, injectDialog } from '@isa/ui/dialog';
|
||||
@@ -16,7 +16,7 @@ export class UncompletedTasksGuard
|
||||
'Aufgaben erledigen',
|
||||
);
|
||||
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
uncompletedTaskListItems = computed(() => {
|
||||
const processId = this.processId();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||
import { PrintReceiptsService, ReturnProcessStore } from '@isa/oms/data-access';
|
||||
import { injectActivatedProcessId } from '@isa/core/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import { ReturnTaskListComponent } from '@isa/oms/shared/task-list';
|
||||
import { ReturnReviewHeaderComponent } from './return-review-header/return-review-header.component';
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ReturnReviewHeaderComponent } from './return-review-header/return-revie
|
||||
export class ReturnReviewComponent {
|
||||
#printReceiptsService = inject(PrintReceiptsService);
|
||||
#returnProcessStore = inject(ReturnProcessStore);
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
async printReceipt() {
|
||||
const processId = this.processId();
|
||||
|
||||
@@ -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/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import {
|
||||
ReceiptListItem,
|
||||
ReturnSearchStatus,
|
||||
@@ -38,7 +38,7 @@ export class ReturnSearchMainComponent {
|
||||
#route = inject(ActivatedRoute);
|
||||
#router = inject(Router);
|
||||
|
||||
private _processId = injectActivatedProcessId();
|
||||
private _processId = injectActivatedTabId();
|
||||
private _filterService = inject(FilterService);
|
||||
private _returnSearchStore = inject(ReturnSearchStore);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
inject,
|
||||
linkedSignal,
|
||||
} from '@angular/core';
|
||||
import { injectActivatedProcessId } from '@isa/core/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import {
|
||||
@@ -72,7 +72,7 @@ export class ReturnSearchResultComponent implements AfterViewInit {
|
||||
restoreScrollPosition = injectRestoreScrollPosition();
|
||||
|
||||
/** Current process ID from the activated route */
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
/** Store for managing return search data and operations */
|
||||
returnSearchStore = inject(ReturnSearchStore);
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
import { ReturnSummaryItemComponent } from './return-summary-item/return-summary-item.component';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
jest.mock('@isa/core/process', () => ({
|
||||
injectActivatedProcessId: () => jest.fn(() => 1),
|
||||
jest.mock('@isa/core/tabs', () => ({
|
||||
injectActivatedTabId: () => jest.fn(() => 1),
|
||||
}));
|
||||
|
||||
const MOCK_RETURN_PROCESSES: ReturnProcess[] = [
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { ReturnSummaryItemComponent } from './return-summary-item/return-summary-item.component';
|
||||
import { injectActivatedProcessId } from '@isa/core/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import {
|
||||
ReturnProcess,
|
||||
ReturnProcessService,
|
||||
@@ -55,7 +55,7 @@ export class ReturnSummaryComponent {
|
||||
location = inject(Location);
|
||||
|
||||
/** The active process ID from the current route */
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
/** Filtered list of return processes for the current process ID */
|
||||
returnProcesses = computed<ReturnProcess[]>(() => {
|
||||
|
||||
@@ -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/tabs';
|
||||
import { injectActivatedTabId } from '@isa/core/tabs';
|
||||
import { logger, provideLoggerContext } from '@isa/core/logging';
|
||||
|
||||
// TODO: Komponente und logik benötigt review
|
||||
@@ -45,7 +45,7 @@ export class ReturnTaskListComponent {
|
||||
#returnTaskListStore = inject(ReturnTaskListStore);
|
||||
#logger = logger();
|
||||
|
||||
processId = injectActivatedProcessId();
|
||||
processId = injectActivatedTabId();
|
||||
|
||||
appearanceClass = computed(
|
||||
() => `oms-shared-return-task-list__${this.appearance()}`,
|
||||
|
||||
Reference in New Issue
Block a user