Skip to content

Commit

Permalink
RocketChat#752 Закрытие формы создания рездала и пункта после сохранения
Browse files Browse the repository at this point in the history
  • Loading branch information
shedoev committed Nov 10, 2020
1 parent 6977b45 commit 8e792b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/models/server/models/Protocols.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Protocols extends Base {
if (data.sections) {
data.sections = data.sections.map((section) => {
if (section._id === sectionData._id) {
return { ...sectionData, items: section.items };
return { ...sectionData, inum: section.inum, items: section.items };
}
return section;
});
Expand Down Expand Up @@ -137,7 +137,7 @@ class Protocols extends Base {
if (section._id === sectionId) {
section.items = section.items.map((item) => {
if (item._id === itemData._id) {
return { ...itemData };
return { ...itemData, inum: item.inum };
}
return item;
})
Expand Down
4 changes: 2 additions & 2 deletions app/protocols/client/views/AddItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function AddItem({ goToNew, close, onChange, ...props }) {
expireAt
);
dispatchToastMessage({ type: 'success', message: t('Item_Added_Successfully') });
goToNew(sectionId, result)();
close();
onChange();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
}, [dispatchToastMessage, goToNew, number, name, responsible, expireAt, onChange, saveAction, t]);
}, [dispatchToastMessage, close, number, name, responsible, expireAt, onChange, saveAction, t]);

return <VerticalBar.ScrollableContent {...props}>
<Field>
Expand Down
4 changes: 2 additions & 2 deletions app/protocols/client/views/AddSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export function AddSection({ goToNew, close, onChange, ...props }) {
name
);
dispatchToastMessage({ type: 'success', message: t('Section_Added_Successfully') });
goToNew(result)();
close()
onChange();
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
}, [dispatchToastMessage, goToNew, number, name, onChange, saveAction, t]);
}, [dispatchToastMessage, close, number, name, onChange, saveAction, t]);

return <VerticalBar.ScrollableContent {...props}>
<Field>
Expand Down
3 changes: 2 additions & 1 deletion app/protocols/client/views/EditItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ function EditItemWithData({ close, onChange, protocol, sectionId, itemId, ...pro

const handleSave = useCallback(async () => {
saveAction(number, name, responsible, expireAt);
close();
onChange();
}, [saveAction, onChange]);
}, [saveAction, close, onChange]);

return <VerticalBar.ScrollableContent {...props}>
<Field>
Expand Down
3 changes: 2 additions & 1 deletion app/protocols/client/views/EditSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ function EditSectionWithData({ close, onChange, protocol, sectionId, ...props })

const handleSave = useCallback(async () => {
saveAction(number, name);
close();
onChange();
}, [saveAction, onChange]);
}, [saveAction, close, onChange]);

return <VerticalBar.ScrollableContent {...props}>
<Field>
Expand Down

0 comments on commit 8e792b5

Please sign in to comment.