mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-20 23:15:10 +00:00
Bug fixes for Note model (#12835)
* Bug fixes for Note model - Allow note to be created as "primary" - Reset note creation fields in editor * Tweak to ensure that the API spec does not change
This commit is contained in:
1 parent
43be292db2
commit
e8af71ae5a
4 files changed
+38
-4
No files matched your search
@@ -306,7 +306,7 @@ export default function NotesEditor({
|
||||
return notesQuery.data && notesQuery.data.length > 0;
|
||||
}, [notesQuery.data]);
|
||||
|
||||
const noteFields = useNoteFields({
|
||||
const { fields: noteFields, resetFields: resetNoteFields } = useNoteFields({
|
||||
modelType: modelType!,
|
||||
modelId: modelId!
|
||||
});
|
||||
@@ -711,7 +711,10 @@ export default function NotesEditor({
|
||||
<Button
|
||||
color='green'
|
||||
leftSection={<IconCirclePlus />}
|
||||
onClick={createNote.open}
|
||||
onClick={() => {
|
||||
resetNoteFields();
|
||||
createNote.open();
|
||||
}}
|
||||
disabled={isEditing}
|
||||
>
|
||||
{t`Add Note`}
|
||||
|
||||
@@ -330,13 +330,19 @@ export function useNoteFields({
|
||||
}: {
|
||||
modelType: ModelType;
|
||||
modelId: number;
|
||||
}): ApiFormFieldSet {
|
||||
}): { fields: ApiFormFieldSet; resetFields: () => void } {
|
||||
const api = useApi();
|
||||
|
||||
const [title, setTitle] = useState<string>('');
|
||||
const [description, setDescription] = useState<string>('');
|
||||
const [content, setContent] = useState<string>('');
|
||||
|
||||
const resetFields = useCallback(() => {
|
||||
setTitle('');
|
||||
setDescription('');
|
||||
setContent('');
|
||||
}, []);
|
||||
|
||||
const fetchTemplate = useCallback(
|
||||
(pk: number | null) => {
|
||||
if (!pk) return;
|
||||
@@ -352,7 +358,7 @@ export function useNoteFields({
|
||||
[api]
|
||||
);
|
||||
|
||||
return useMemo(() => {
|
||||
const fields = useMemo<ApiFormFieldSet>(() => {
|
||||
return {
|
||||
model_type: {
|
||||
hidden: true,
|
||||
@@ -392,6 +398,8 @@ export function useNoteFields({
|
||||
}
|
||||
};
|
||||
}, [modelType, modelId, title, description, content, fetchTemplate]);
|
||||
|
||||
return { fields, resetFields };
|
||||
}
|
||||
|
||||
export function selectionListFields(): ApiFormFieldSet {
|
||||
|
||||
Reference in new issue
Block a user