Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
623d783
Added keep open boolean field to Stock Location modal form
spamik Dec 27, 2025
23daa95
Rewrite keep form open field feature to avoid calling methods in form…
Jan 8, 2026
fdec4b5
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Feb 12, 2026
a4b4566
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Feb 12, 2026
c5cc28f
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Feb 12, 2026
c8af24c
Merge branch 'master' into form-keep-open-feature
matmair Feb 12, 2026
d8adbd8
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 3, 2026
787b8e0
Rewrite keep form open feature as common form property
spamik Mar 8, 2026
045e8c7
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 9, 2026
30cc13b
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 10, 2026
0d7ed88
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 14, 2026
3dc51a3
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 14, 2026
dde261b
Removed unused artefact from previous implementation
spamik Mar 14, 2026
ce614e6
keepOpenOption removed as default option for all create forms. Instea…
spamik Mar 14, 2026
c423bbb
keepOpenOption field speed improvement
spamik Mar 14, 2026
86ec430
Added keep form open feature to changelog
spamik Mar 15, 2026
9eede1c
Updated documentation: keep form open feature added to concepts/user_…
spamik Mar 15, 2026
182ed35
Merge branch 'master' into form-keep-open-feature
SchrodingersGat Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/frontend/src/components/forms/ApiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,16 @@ export function ApiForm({
props.onFormSuccess(response.data, form);
}

if (props.follow && props.modelType && response.data?.pk) {
const keepOpen = form.getValues()?.keep_form_open ?? false;

if (
props.follow &&
props.modelType &&
response.data?.pk &&
!keepOpen
) {
// If we want to automatically follow the returned data
if (!!navigate) {
if (!!navigate && !keepOpen) {
navigate(getDetailUrl(props.modelType, response.data?.pk));
}
} else if (props.table) {
Expand Down
10 changes: 9 additions & 1 deletion src/frontend/src/forms/CommonForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from 'react';
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
import type { ModelType } from '@lib/enums/ModelType';
import { apiUrl } from '@lib/functions/Api';
import type { ApiFormFieldSet } from '@lib/types/Forms';
import type { ApiFormFieldSet, ApiFormFieldType } from '@lib/types/Forms';
import { t } from '@lingui/core/macro';
import type {
StatusCodeInterface,
Expand Down Expand Up @@ -209,3 +209,11 @@ export function useParameterFields({
};
}, [data, modelType, fieldType, choices, modelId]);
}

export const keepFormOpenField = (create = true): ApiFormFieldType => ({
label: 'Keep form open',
field_type: 'boolean',
exclude: true,
hidden: !create,
description: 'Keep form open after submitting'
});
6 changes: 4 additions & 2 deletions src/frontend/src/forms/StockForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
} from '../hooks/UseGenerator';
import { useGlobalSettingsState } from '../states/SettingsStates';
import { StatusFilterOptions } from '../tables/Filter';
import { keepFormOpenField } from './CommonForms';

/**
* Construct a set of fields for creating / editing a StockItem instance
Expand Down Expand Up @@ -1395,7 +1396,7 @@ export function useDeleteStockItem(props: StockOperationProps) {
});
}

export function stockLocationFields(): ApiFormFieldSet {
export function stockLocationFields(create = false): ApiFormFieldSet {
const fields: ApiFormFieldSet = {
parent: {
description: t`Parent stock location`,
Expand All @@ -1408,7 +1409,8 @@ export function stockLocationFields(): ApiFormFieldSet {
custom_icon: {
field_type: 'icon'
},
location_type: {}
location_type: {},
keep_form_open: keepFormOpenField(create)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really like this method here, I would prefer a generic approach here. What do you mean @SchrodingersGat ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem out of step with how are pass other parameters. It could be a simple keep_form_open attribute

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we have this parameter for all forms on InvenTree (if it's not disabled for that form) and then don't mix the form fields with the keep open toggle we render independently at the bottom of keep open is available for that form?

};

return fields;
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/hooks/UseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function useApiFormModal(props: ApiFormModalProps) {
}
],
onFormSuccess: (data, form) => {
if (props.checkClose?.(data, form) ?? true) {
const keepOpen = form.getValues()?.keep_form_open ?? false;

if (!keepOpen && (props.checkClose?.(data, form) ?? true)) {
modalClose.current();
}
props.onFormSuccess?.(data, form);
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/tables/stock/StockLocationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function StockLocationTable({ parentId }: Readonly<{ parentId?: any }>) {
const newLocation = useCreateApiFormModal({
url: ApiEndpoints.stock_location_list,
title: t`Add Stock Location`,
fields: stockLocationFields(),
fields: stockLocationFields(true),
focus: 'name',
initialData: {
parent: parentId
Expand Down