2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-01-30 01:53:42 +00:00

[UI] Delete stock fix (#10868)

* Add helper func getOverviewUrl

* Redirect to parent page when stock item is counted to zero
This commit is contained in:
Oliver
2025-11-20 06:34:25 +11:00
committed by GitHub
parent 18c2a934b8
commit 468efbacfc
2 changed files with 37 additions and 2 deletions

View File

@@ -7,6 +7,28 @@ import { cancelEvent } from './Events';
export const getBaseUrl = (): string =>
(window as any).INVENTREE_SETTINGS?.base_url || 'web';
/**
* Returns the overview URL for a given model type.
* This is the UI URL, not the API URL.
*/
export function getOverviewUrl(model: ModelType, absolute?: boolean): string {
const modelInfo = ModelInformationDict[model];
if (modelInfo?.url_overview) {
const url = modelInfo.url_overview;
const base = getBaseUrl();
if (absolute && base) {
return `/${base}${url}`;
} else {
return url;
}
}
console.error(`No overview URL found for model ${model}`);
return '';
}
/**
* Returns the detail view URL for a given model type.
* This is the UI URL, not the API URL.