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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user