Merged PR 1920: feat(remission-list): add navigation to default list and clear input on reload

feat(remission-list): add navigation to default list and clear input on reload

Add Router injection and injectTabId for navigation functionality.
Implement navigateToDefaultRemissionList method to redirect users
to the default remission list using the current activated tab ID.
Clear query input on reload trigger to prevent stale search results
from persisting across navigation.

Enhance emptySearchResultEffect to handle department list navigation
when no items are found and remission hasn't started yet.

Ref: #5273
This commit is contained in:
Nino Righi
2025-08-14 14:06:20 +00:00
committed by Andreas Schickinger
parent 514715589b
commit dd3705f8bc
2 changed files with 37 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ import {
untracked,
signal,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import {
provideFilter,
withQuerySettingsFactory,
@@ -48,6 +48,7 @@ import { RemissionReturnCardComponent } from './remission-return-card/remission-
import { logger } from '@isa/core/logging';
import { RemissionProcessedHintComponent } from './remission-processed-hint/remission-processed-hint.component';
import { RemissionListDepartmentElementsComponent } from './remission-list-department-elements/remission-list-department-elements.component';
import { injectTabId } from '@isa/core/tabs';
function querySettingsFactory() {
return inject(ActivatedRoute).snapshot.data['querySettings'];
@@ -103,6 +104,17 @@ export class RemissionListComponent {
*/
route = inject(ActivatedRoute);
/**
* Router instance for navigation.
*/
router = inject(Router);
/**
* Injects the current activated tab ID as a signal.
* This is used to determine if the current remission matches the active tab.
*/
activatedTabId = injectTabId();
searchItemToRemitDialog = injectDialog(SearchItemToRemitDialogComponent);
/**
@@ -352,6 +364,12 @@ export class RemissionListComponent {
);
});
/**
* Effect that handles the case when there are no items in the remission list after a search.
* If the search was triggered by the user, it opens a dialog to search for items to remit.
* If remission has already started, it adds the found items to the remission store and remits them.
* If not, it navigates to the default remission list.
*/
emptySearchResultEffect = effect(() => {
const status = this.remissionResource.status();
@@ -384,7 +402,10 @@ export class RemissionListComponent {
}
}
await this.remitItems();
} else if (this.isDepartment()) {
return await this.navigateToDefaultRemissionList();
}
this.reloadListAndReturnData();
this.searchTrigger.set('reload');
}
@@ -456,4 +477,13 @@ export class RemissionListComponent {
this.remissionResource.reload();
this.#store.reloadReturn();
}
/**
* Navigates to the default remission list based on the current activated tab ID.
* This method is used to redirect the user to the remission list after completing or starting a remission.
* @returns {Promise<void>} A promise that resolves when navigation is complete
*/
async navigateToDefaultRemissionList() {
await this.router.navigate(['/', this.activatedTabId(), 'remission']);
}
}

View File

@@ -74,6 +74,12 @@ export const createRemissionListResource = (
const queryToken = { ...params.queryToken };
const exactSearch = isExactSearch(queryToken, params.searchTrigger);
const isReload = params.searchTrigger === 'reload';
// #5273
if (isReload) {
queryToken.input = {};
}
if (exactSearch) {
queryToken.filter = {};