@gisce/react-ooui 2.0.0-rc.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConnectionProvider.d.ts +1 -1
- package/dist/ConnectionProvider.d.ts.map +1 -1
- package/dist/actionbar/ActionButton.d.ts +2 -3
- package/dist/actionbar/ActionButton.d.ts.map +1 -1
- package/dist/actionbar/AttachmentsButton.d.ts +2 -3
- package/dist/actionbar/AttachmentsButton.d.ts.map +1 -1
- package/dist/actionbar/AttachmentsButtonWrapper.d.ts +3 -4
- package/dist/actionbar/AttachmentsButtonWrapper.d.ts.map +1 -1
- package/dist/actionbar/ButtonWithBadge.d.ts +3 -4
- package/dist/actionbar/ButtonWithBadge.d.ts.map +1 -1
- package/dist/actionbar/ChangeViewButton.d.ts +3 -4
- package/dist/actionbar/ChangeViewButton.d.ts.map +1 -1
- package/dist/actionbar/DashboardActionBar.d.ts +1 -2
- package/dist/actionbar/DashboardActionBar.d.ts.map +1 -1
- package/dist/actionbar/DropdownButton.d.ts +4 -3
- package/dist/actionbar/DropdownButton.d.ts.map +1 -1
- package/dist/actionbar/FormActionBar.d.ts +1 -2
- package/dist/actionbar/FormActionBar.d.ts.map +1 -1
- package/dist/actionbar/GraphActionBar.d.ts +1 -2
- package/dist/actionbar/GraphActionBar.d.ts.map +1 -1
- package/dist/actionbar/NewButton.d.ts +2 -3
- package/dist/actionbar/NewButton.d.ts.map +1 -1
- package/dist/actionbar/SearchBar.d.ts +2 -3
- package/dist/actionbar/SearchBar.d.ts.map +1 -1
- package/dist/actionbar/TreeActionBar.d.ts +2 -3
- package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/common/ButtonWithTooltip.d.ts +2 -3
- package/dist/common/ButtonWithTooltip.d.ts.map +1 -1
- package/dist/common/DatePicker.d.ts +3 -4
- package/dist/common/DatePicker.d.ts.map +1 -1
- package/dist/common/Field.d.ts +1 -1
- package/dist/common/Field.d.ts.map +1 -1
- package/dist/common/SelectAllRecordsRow.d.ts +9 -0
- package/dist/common/SelectAllRecordsRow.d.ts.map +1 -0
- package/dist/common/TimePicker.d.ts +10 -0
- package/dist/common/TimePicker.d.ts.map +1 -0
- package/dist/context/ActionViewContext.d.ts +4 -4
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/context/ConfigContext.d.ts +9 -1
- package/dist/context/ConfigContext.d.ts.map +1 -1
- package/dist/context/ContentRootContext.d.ts +2 -2
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/context/DashboardActionContext.d.ts +3 -3
- package/dist/context/DashboardActionContext.d.ts.map +1 -1
- package/dist/context/FormContext.d.ts +2 -2
- package/dist/context/FormContext.d.ts.map +1 -1
- package/dist/context/FormModalContext.d.ts +2 -2
- package/dist/context/FormModalContext.d.ts.map +1 -1
- package/dist/context/LocaleContext.d.ts +2 -2
- package/dist/context/LocaleContext.d.ts.map +1 -1
- package/dist/context/One2manyContext.d.ts +2 -2
- package/dist/context/One2manyContext.d.ts.map +1 -1
- package/dist/context/TabManagerContext.d.ts +5 -5
- package/dist/context/TabManagerContext.d.ts.map +1 -1
- package/dist/helpers/containerHelper.d.ts.map +1 -1
- package/dist/helpers/dayjs.d.ts +3 -0
- package/dist/helpers/dayjs.d.ts.map +1 -0
- package/dist/helpers/dynamicColumnsHelper.d.ts.map +1 -1
- package/dist/helpers/errorHelper.d.ts.map +1 -1
- package/dist/helpers/filesHelper.d.ts +1 -1
- package/dist/helpers/filesHelper.d.ts.map +1 -1
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/helpers/iconMapper.d.ts +2 -2
- package/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/helpers/logInfoHelper.d.ts.map +1 -1
- package/dist/helpers/one2manyHelper.d.ts +5 -5
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/helpers/searchHelper.d.ts.map +1 -1
- package/dist/helpers/timeHelper.d.ts.map +1 -1
- package/dist/helpers/treeHelper.d.ts +3 -3
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/helpers/viewHelper.d.ts +3 -3
- package/dist/helpers/viewHelper.d.ts.map +1 -1
- package/dist/hooks/useEffectDebugger.d.ts +3 -0
- package/dist/hooks/useEffectDebugger.d.ts.map +1 -0
- package/dist/hooks/useExport.d.ts.map +1 -1
- package/dist/hooks/useFetchViews.d.ts +1 -0
- package/dist/hooks/useFetchViews.d.ts.map +1 -0
- package/dist/hooks/useSearch.d.ts +3 -3
- package/dist/hooks/useSearch.d.ts.map +1 -1
- package/dist/hooks/useWindowDimensions.d.ts.map +1 -1
- package/dist/index.d.ts +47 -47
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +1 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +1 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +1 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +7247 -8856
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +47 -46
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/ActionErrorDialog.d.ts.map +1 -1
- package/dist/ui/ConfirmDialog.d.ts +1 -1
- package/dist/ui/ConfirmDialog.d.ts.map +1 -1
- package/dist/ui/ErrorAlert.d.ts +1 -2
- package/dist/ui/ErrorAlert.d.ts.map +1 -1
- package/dist/ui/FavouriteButton.d.ts +4 -5
- package/dist/ui/FavouriteButton.d.ts.map +1 -1
- package/dist/ui/FormErrorsDialog.d.ts.map +1 -1
- package/dist/ui/GenericErrorDialog.d.ts.map +1 -1
- package/dist/ui/GoToResourceModal.d.ts +3 -4
- package/dist/ui/GoToResourceModal.d.ts.map +1 -1
- package/dist/ui/InfoDialog.d.ts.map +1 -1
- package/dist/ui/RefreshItemDialog.d.ts.map +1 -1
- package/dist/ui/RemoveItemDialog.d.ts.map +1 -1
- package/dist/ui/TitleHeader.d.ts +2 -3
- package/dist/ui/TitleHeader.d.ts.map +1 -1
- package/dist/ui/UnlinkItemDialog.d.ts.map +1 -1
- package/dist/ui/UnsavedChangesDialog.d.ts.map +1 -1
- package/dist/ui/WarningDialog.d.ts +1 -1
- package/dist/ui/WarningDialog.d.ts.map +1 -1
- package/dist/views/ActionView.d.ts +2 -2
- package/dist/views/ActionView.d.ts.map +1 -1
- package/dist/views/CurrentTabContent.d.ts +1 -2
- package/dist/views/CurrentTabContent.d.ts.map +1 -1
- package/dist/views/RootView.d.ts +2 -2
- package/dist/views/RootView.d.ts.map +1 -1
- package/dist/views/TabContent.d.ts +2 -2
- package/dist/views/TabContent.d.ts.map +1 -1
- package/dist/views/TabSelector.d.ts +1 -2
- package/dist/views/TabSelector.d.ts.map +1 -1
- package/dist/views/Welcome.d.ts.map +1 -1
- package/dist/views/actionViews/DashboardActionView.d.ts +4 -4
- package/dist/views/actionViews/DashboardActionView.d.ts.map +1 -1
- package/dist/views/actionViews/FormActionView.d.ts +3 -4
- package/dist/views/actionViews/FormActionView.d.ts.map +1 -1
- package/dist/views/actionViews/GraphActionView.d.ts +3 -4
- package/dist/views/actionViews/GraphActionView.d.ts.map +1 -1
- package/dist/views/actionViews/TreeActionView.d.ts +3 -4
- package/dist/views/actionViews/TreeActionView.d.ts.map +1 -1
- package/dist/views/tabs/Tab.d.ts +2 -3
- package/dist/views/tabs/Tab.d.ts.map +1 -1
- package/dist/widgets/WidgetFactory.d.ts.map +1 -1
- package/dist/widgets/base/Binary.d.ts +3 -4
- package/dist/widgets/base/Binary.d.ts.map +1 -1
- package/dist/widgets/base/Boolean.d.ts +2 -3
- package/dist/widgets/base/Boolean.d.ts.map +1 -1
- package/dist/widgets/base/Button.d.ts +2 -3
- package/dist/widgets/base/Button.d.ts.map +1 -1
- package/dist/widgets/base/Char.d.ts +3 -4
- package/dist/widgets/base/Char.d.ts.map +1 -1
- package/dist/widgets/base/Date.d.ts +2 -3
- package/dist/widgets/base/Date.d.ts.map +1 -1
- package/dist/widgets/base/DateTime.d.ts +2 -3
- package/dist/widgets/base/DateTime.d.ts.map +1 -1
- package/dist/widgets/base/Email.d.ts +2 -3
- package/dist/widgets/base/Email.d.ts.map +1 -1
- package/dist/widgets/base/Float.d.ts +2 -3
- package/dist/widgets/base/Float.d.ts.map +1 -1
- package/dist/widgets/base/FloatTime.d.ts +2 -2
- package/dist/widgets/base/FloatTime.d.ts.map +1 -1
- package/dist/widgets/base/Image.d.ts +3 -4
- package/dist/widgets/base/Image.d.ts.map +1 -1
- package/dist/widgets/base/Integer.d.ts +3 -4
- package/dist/widgets/base/Integer.d.ts.map +1 -1
- package/dist/widgets/base/Label.d.ts +3 -4
- package/dist/widgets/base/Label.d.ts.map +1 -1
- package/dist/widgets/base/LinkInput.d.ts +1 -2
- package/dist/widgets/base/LinkInput.d.ts.map +1 -1
- package/dist/widgets/base/MultiSelection.d.ts +4 -5
- package/dist/widgets/base/MultiSelection.d.ts.map +1 -1
- package/dist/widgets/base/ProgressBar.d.ts +3 -4
- package/dist/widgets/base/ProgressBar.d.ts.map +1 -1
- package/dist/widgets/base/Reference.d.ts +2 -2
- package/dist/widgets/base/Reference.d.ts.map +1 -1
- package/dist/widgets/base/ReferenceTree.d.ts +1 -1
- package/dist/widgets/base/ReferenceTree.d.ts.map +1 -1
- package/dist/widgets/base/Selection.d.ts +4 -5
- package/dist/widgets/base/Selection.d.ts.map +1 -1
- package/dist/widgets/base/Separator.d.ts +2 -3
- package/dist/widgets/base/Separator.d.ts.map +1 -1
- package/dist/widgets/base/Text.d.ts +2 -3
- package/dist/widgets/base/Text.d.ts.map +1 -1
- package/dist/widgets/base/Time.d.ts +4 -5
- package/dist/widgets/base/Time.d.ts.map +1 -1
- package/dist/widgets/base/Url.d.ts +2 -3
- package/dist/widgets/base/Url.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2one.d.ts +2 -2
- package/dist/widgets/base/many2one/Many2one.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2oneSuffix.d.ts +2 -3
- package/dist/widgets/base/many2one/Many2oneSuffix.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2oneSuffixModal.d.ts +2 -3
- package/dist/widgets/base/many2one/Many2oneSuffixModal.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2oneTree.d.ts +1 -1
- package/dist/widgets/base/many2one/Many2oneTree.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2many.d.ts +2 -3
- package/dist/widgets/base/one2many/One2many.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyInput.d.ts +4 -4
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyTopBar.d.ts +3 -4
- package/dist/widgets/base/one2many/One2manyTopBar.d.ts.map +1 -1
- package/dist/widgets/containers/Container.d.ts +1 -1
- package/dist/widgets/containers/Container.d.ts.map +1 -1
- package/dist/widgets/containers/Group.d.ts +1 -1
- package/dist/widgets/containers/Group.d.ts.map +1 -1
- package/dist/widgets/containers/Notebook.d.ts +1 -1
- package/dist/widgets/containers/Notebook.d.ts.map +1 -1
- package/dist/widgets/custom/Avatar.d.ts +2 -2
- package/dist/widgets/custom/Avatar.d.ts.map +1 -1
- package/dist/widgets/custom/ButtonGroup.d.ts +2 -3
- package/dist/widgets/custom/ButtonGroup.d.ts.map +1 -1
- package/dist/widgets/custom/CodeEditor.d.ts +3 -4
- package/dist/widgets/custom/CodeEditor.d.ts.map +1 -1
- package/dist/widgets/custom/Comments.d.ts +11 -12
- package/dist/widgets/custom/Comments.d.ts.map +1 -1
- package/dist/widgets/custom/FiberGrid.d.ts +3 -4
- package/dist/widgets/custom/FiberGrid.d.ts.map +1 -1
- package/dist/widgets/custom/Indicator.d.ts +3 -4
- package/dist/widgets/custom/Indicator.d.ts.map +1 -1
- package/dist/widgets/custom/Markdown.d.ts +3 -4
- package/dist/widgets/custom/Markdown.d.ts.map +1 -1
- package/dist/widgets/custom/MultiCheckbox.d.ts +4 -5
- package/dist/widgets/custom/MultiCheckbox.d.ts.map +1 -1
- package/dist/widgets/custom/Radio.d.ts +4 -5
- package/dist/widgets/custom/Radio.d.ts.map +1 -1
- package/dist/widgets/custom/Steps.d.ts +4 -5
- package/dist/widgets/custom/Steps.d.ts.map +1 -1
- package/dist/widgets/custom/Switch.d.ts +2 -3
- package/dist/widgets/custom/Switch.d.ts.map +1 -1
- package/dist/widgets/custom/Tag.d.ts +5 -6
- package/dist/widgets/custom/Tag.d.ts.map +1 -1
- package/dist/widgets/custom/Tags.d.ts +5 -6
- package/dist/widgets/custom/Tags.d.ts.map +1 -1
- package/dist/widgets/custom/Timeline.d.ts +5 -6
- package/dist/widgets/custom/Timeline.d.ts.map +1 -1
- package/dist/widgets/modals/ExportModal.d.ts +2 -3
- package/dist/widgets/modals/ExportModal.d.ts.map +1 -1
- package/dist/widgets/modals/FormModal.d.ts +3 -4
- package/dist/widgets/modals/FormModal.d.ts.map +1 -1
- package/dist/widgets/modals/SearchModal.d.ts +2 -3
- package/dist/widgets/modals/SearchModal.d.ts.map +1 -1
- package/dist/widgets/modals/TranslationModal.d.ts +2 -3
- package/dist/widgets/modals/TranslationModal.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/Dashboard.d.ts +1 -1
- package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/DashboardForm.d.ts +1 -2
- package/dist/widgets/views/Dashboard/DashboardForm.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/DashboardTree.d.ts +4 -5
- package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/dashboardHelper.d.ts.map +1 -1
- package/dist/widgets/views/DashboardGrid/DashboardGrid.d.ts +1 -2
- package/dist/widgets/views/DashboardGrid/DashboardGrid.d.ts.map +1 -1
- package/dist/widgets/views/DashboardGrid/DashboardGrid.types.d.ts +2 -2
- package/dist/widgets/views/DashboardGrid/DashboardGrid.types.d.ts.map +1 -1
- package/dist/widgets/views/DashboardGrid/DashboardGridItem.d.ts +1 -2
- package/dist/widgets/views/DashboardGrid/DashboardGridItem.d.ts.map +1 -1
- package/dist/widgets/views/DashboardGrid/DashboardGridItem.types.d.ts +2 -2
- package/dist/widgets/views/DashboardGrid/DashboardGridItem.types.d.ts.map +1 -1
- package/dist/widgets/views/DashboardGrid/index.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts +2 -2
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/dist/widgets/views/Graph/Graph.d.ts +1 -1
- package/dist/widgets/views/Graph/Graph.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphChart.d.ts +2 -3
- package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphDefaults.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphIndicator.d.ts +2 -3
- package/dist/widgets/views/Graph/GraphIndicator.d.ts.map +1 -1
- package/dist/widgets/views/Graph/useGraphData.d.ts +2 -2
- package/dist/widgets/views/Graph/useGraphData.d.ts.map +1 -1
- package/dist/widgets/views/SearchTree.d.ts +5 -5
- package/dist/widgets/views/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/{Tree.d.ts → Tree/Tree.d.ts} +8 -7
- package/dist/widgets/views/Tree/Tree.d.ts.map +1 -0
- package/dist/widgets/views/Tree/index.d.ts +2 -0
- package/dist/widgets/views/Tree/index.d.ts.map +1 -0
- package/dist/widgets/views/Tree/treeComponents.d.ts +131 -0
- package/dist/widgets/views/Tree/treeComponents.d.ts.map +1 -0
- package/dist/widgets/views/searchFilter/DateRangePicker.d.ts +2 -3
- package/dist/widgets/views/searchFilter/DateRangePicker.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/DateTimeRangePicker.d.ts +2 -3
- package/dist/widgets/views/searchFilter/DateTimeRangePicker.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/PairFields.d.ts +1 -1
- package/dist/widgets/views/searchFilter/PairFields.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchBottomBar.d.ts +3 -3
- package/dist/widgets/views/searchFilter/SearchBottomBar.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchField.d.ts +2 -3
- package/dist/widgets/views/searchFilter/SearchField.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts +3 -4
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchParams.d.ts +1 -1
- package/dist/widgets/views/searchFilter/SearchParams.d.ts.map +1 -1
- package/package.json +108 -56
- package/dist/react-ooui.umd.js +0 -38
- package/dist/react-ooui.umd.js.map +0 -1
- package/dist/widgets/views/Tree.d.ts.map +0 -1
- package/src/ConnectionProvider.ts +0 -16
- package/src/__tests__/iconMapper.test.ts +0 -30
- package/src/__tests__/searchFilterHelper.spec.ts +0 -386
- package/src/actionbar/ActionButton.tsx +0 -40
- package/src/actionbar/AttachmentsButton.tsx +0 -130
- package/src/actionbar/AttachmentsButtonWrapper.tsx +0 -157
- package/src/actionbar/ButtonWithBadge.tsx +0 -42
- package/src/actionbar/ChangeViewButton.tsx +0 -137
- package/src/actionbar/DashboardActionBar.tsx +0 -67
- package/src/actionbar/DropdownButton.tsx +0 -61
- package/src/actionbar/FormActionBar.tsx +0 -485
- package/src/actionbar/GraphActionBar.tsx +0 -67
- package/src/actionbar/NewButton.tsx +0 -46
- package/src/actionbar/SearchBar.tsx +0 -73
- package/src/actionbar/TreeActionBar.tsx +0 -376
- package/src/common/ButtonWithTooltip.tsx +0 -18
- package/src/common/DatePicker.tsx +0 -99
- package/src/common/Field.tsx +0 -92
- package/src/context/ActionViewContext.tsx +0 -209
- package/src/context/ConfigContext.tsx +0 -9
- package/src/context/ContentRootContext.tsx +0 -454
- package/src/context/DashboardActionContext.tsx +0 -45
- package/src/context/FormContext.tsx +0 -79
- package/src/context/FormModalContext.tsx +0 -29
- package/src/context/LocaleContext.tsx +0 -50
- package/src/context/One2manyContext.tsx +0 -46
- package/src/context/TabManagerContext.tsx +0 -118
- package/src/helpers/containerHelper.ts +0 -145
- package/src/helpers/dynamicColumnsHelper.ts +0 -73
- package/src/helpers/errorHelper.ts +0 -27
- package/src/helpers/filesHelper.ts +0 -41
- package/src/helpers/formHelper.ts +0 -302
- package/src/helpers/iconMapper.ts +0 -164
- package/src/helpers/logInfoHelper.tsx +0 -28
- package/src/helpers/one2manyHelper.ts +0 -194
- package/src/helpers/searchHelper.ts +0 -193
- package/src/helpers/timeHelper.ts +0 -58
- package/src/helpers/treeHelper.ts +0 -204
- package/src/helpers/viewHelper.ts +0 -23
- package/src/hooks/useEffectDebugger.ts +0 -43
- package/src/hooks/useExport.ts +0 -438
- package/src/hooks/useFetchViews.ts +0 -0
- package/src/hooks/useSearch.ts +0 -434
- package/src/hooks/useWindowDimensions.ts +0 -33
- package/src/index.ts +0 -168
- package/src/locales/ca_ES.tsx +0 -98
- package/src/locales/en_US.tsx +0 -95
- package/src/locales/es_ES.tsx +0 -99
- package/src/stories/Binary.stories.tsx +0 -26
- package/src/stories/Boolean.stories.tsx +0 -25
- package/src/stories/Button.stories.tsx +0 -136
- package/src/stories/Char.stories.tsx +0 -52
- package/src/stories/FiberGrid.stories.tsx +0 -112
- package/src/stories/Float.stories.tsx +0 -25
- package/src/stories/FloatTime.stories.tsx +0 -35
- package/src/stories/Image.stories.tsx +0 -28
- package/src/stories/Integer.stories.tsx +0 -25
- package/src/stories/Label.stories.tsx +0 -103
- package/src/stories/Many2one.stories.tsx +0 -34
- package/src/stories/One2many.stories.tsx +0 -295
- package/src/stories/ProgressBar.stories.tsx +0 -25
- package/src/stories/Reference.stories.tsx +0 -46
- package/src/stories/Selection.stories.tsx +0 -37
- package/src/stories/Separator.stories.tsx +0 -57
- package/src/stories/Text.stories.tsx +0 -38
- package/src/stories/Time.stories.tsx +0 -32
- package/src/stories/Utils.stories.tsx +0 -16
- package/src/stories/containers/Group.stories.tsx +0 -90
- package/src/stories/containers/NewLine.stories.tsx +0 -56
- package/src/stories/containers/Notebook.stories.tsx +0 -199
- package/src/stories/custom/Avatar.stories.tsx +0 -27
- package/src/stories/custom/ButtonGroup.stories.tsx +0 -61
- package/src/stories/custom/CodeEditor.stories.tsx +0 -28
- package/src/stories/custom/Comments.stories.tsx +0 -190
- package/src/stories/custom/Indicator.stories.tsx +0 -44
- package/src/stories/custom/Markdown.stories.tsx +0 -42
- package/src/stories/custom/MultiCheckbox.stories.tsx +0 -55
- package/src/stories/custom/Radio.stories.tsx +0 -71
- package/src/stories/custom/Steps.stories.tsx +0 -41
- package/src/stories/custom/Switch.stories.tsx +0 -26
- package/src/stories/custom/Tag.stories.tsx +0 -60
- package/src/stories/custom/Tags.stories.tsx +0 -70
- package/src/stories/dashboard/Dashboard.stories.tsx +0 -23
- package/src/stories/dashboard/DashboardGrid.stories.tsx +0 -43
- package/src/stories/forms/ActivacioContracteForm.stories.tsx +0 -25
- package/src/stories/forms/Attachment.stories.tsx +0 -24
- package/src/stories/forms/CUPSForm.stories.tsx +0 -25
- package/src/stories/forms/Company.stories.tsx +0 -25
- package/src/stories/forms/CrmCaseForm.stories.tsx +0 -25
- package/src/stories/forms/Documents.stories.tsx +0 -25
- package/src/stories/forms/FormWithGridFiber.stories.tsx +0 -25
- package/src/stories/forms/FormWithLinks.stories.tsx +0 -31
- package/src/stories/forms/Lead.stories.tsx +0 -25
- package/src/stories/forms/ModContractForm.stories.tsx +0 -25
- package/src/stories/forms/PartnersForm.stories.tsx +0 -25
- package/src/stories/forms/PolissaForm.stories.tsx +0 -25
- package/src/stories/forms/PreferencesForm.stories.tsx +0 -696
- package/src/stories/forms/Signatures.stories.tsx +0 -25
- package/src/stories/forms/Switching.stories.tsx +0 -25
- package/src/stories/graphs/GraphIndicator.stories.tsx +0 -20
- package/src/stories/graphs/PieGraph.stories.tsx +0 -78
- package/src/stories/mocks/index.ts +0 -46
- package/src/stories/mocks/mockProvider.ts +0 -186
- package/src/stories/mocks/models/activacioContracte.ts +0 -112
- package/src/stories/mocks/models/attachment.ts +0 -1327
- package/src/stories/mocks/models/butlleti.ts +0 -344
- package/src/stories/mocks/models/company.ts +0 -137
- package/src/stories/mocks/models/crm_case.ts +0 -595
- package/src/stories/mocks/models/cups.ts +0 -920
- package/src/stories/mocks/models/document.ts +0 -225
- package/src/stories/mocks/models/factura.ts +0 -2727
- package/src/stories/mocks/models/form_with_gridfiber.ts +0 -143
- package/src/stories/mocks/models/hist_autoconsum.ts +0 -148
- package/src/stories/mocks/models/lead.ts +0 -2109
- package/src/stories/mocks/models/modcontractual.ts +0 -806
- package/src/stories/mocks/models/partner.ts +0 -1360
- package/src/stories/mocks/models/polissa.ts +0 -3133
- package/src/stories/mocks/models/res_partner_category.ts +0 -15
- package/src/stories/mocks/models/signatura.ts +0 -618
- package/src/stories/mocks/models/switching.ts +0 -769
- package/src/stories/modals/FormModal.stories.tsx +0 -36
- package/src/stories/modals/SearchModal.stories.tsx +0 -37
- package/src/stories/trees/FacturesTree.stories.tsx +0 -16
- package/src/stories/ui/ActionBar.stories.tsx +0 -24
- package/src/stories/ui/FavouriteButton.stories.tsx +0 -19
- package/src/stories/ui/GoToResourceModal.stories.tsx +0 -27
- package/src/stories/views/ActionView.stories.tsx +0 -28
- package/src/stories/views/SearchTree.stories.tsx +0 -1110
- package/src/stories/views/Tab.stories.tsx +0 -96
- package/src/stories/views/TabsAndContent.stories.tsx +0 -91
- package/src/stories/views/Tree.stories.jsx +0 -184
- package/src/stories/views/searchFilter/DateRangePicker.stories.tsx +0 -25
- package/src/stories/views/searchFilter/DateTimeRangePicker.stories.tsx +0 -26
- package/src/stories/views/searchFilter/PairFields.stories.tsx +0 -26
- package/src/stories/views/searchFilter/SearchFilter.stories.tsx +0 -169
- package/src/stories/views/searchFilter/examples/PartnersSearchFilter.stories.tsx +0 -428
- package/src/tailwind.css +0 -8
- package/src/tailwind.generated.css +0 -168533
- package/src/types/index.ts +0 -391
- package/src/ui/ActionErrorDialog.tsx +0 -24
- package/src/ui/ConfirmDialog.tsx +0 -28
- package/src/ui/ErrorAlert.tsx +0 -37
- package/src/ui/FavouriteButton.tsx +0 -272
- package/src/ui/FormErrorsDialog.tsx +0 -17
- package/src/ui/GenericErrorDialog.tsx +0 -16
- package/src/ui/GoToResourceModal.tsx +0 -75
- package/src/ui/InfoDialog.tsx +0 -13
- package/src/ui/RefreshItemDialog.tsx +0 -29
- package/src/ui/RemoveItemDialog.tsx +0 -20
- package/src/ui/TitleHeader.tsx +0 -110
- package/src/ui/UnlinkItemDialog.tsx +0 -20
- package/src/ui/UnsavedChangesDialog.tsx +0 -29
- package/src/ui/WarningDialog.tsx +0 -17
- package/src/views/ActionView.tsx +0 -514
- package/src/views/CurrentTabContent.tsx +0 -21
- package/src/views/RootView.tsx +0 -510
- package/src/views/TabContent.tsx +0 -31
- package/src/views/TabSelector.tsx +0 -31
- package/src/views/Welcome.tsx +0 -18
- package/src/views/actionViews/DashboardActionView.tsx +0 -47
- package/src/views/actionViews/FormActionView.tsx +0 -70
- package/src/views/actionViews/GraphActionView.tsx +0 -152
- package/src/views/actionViews/TreeActionView.tsx +0 -87
- package/src/views/tabs/Tab.tsx +0 -82
- package/src/widgets/WidgetFactory.tsx +0 -142
- package/src/widgets/base/Binary.tsx +0 -145
- package/src/widgets/base/Boolean.tsx +0 -45
- package/src/widgets/base/Button.tsx +0 -77
- package/src/widgets/base/Char.tsx +0 -157
- package/src/widgets/base/Date.tsx +0 -12
- package/src/widgets/base/DateTime.tsx +0 -12
- package/src/widgets/base/Email.tsx +0 -27
- package/src/widgets/base/Float.tsx +0 -39
- package/src/widgets/base/FloatTime.tsx +0 -73
- package/src/widgets/base/Image.tsx +0 -120
- package/src/widgets/base/Integer.tsx +0 -56
- package/src/widgets/base/Label.tsx +0 -56
- package/src/widgets/base/LinkInput.tsx +0 -101
- package/src/widgets/base/MultiSelection.tsx +0 -91
- package/src/widgets/base/ProgressBar.tsx +0 -38
- package/src/widgets/base/Reference.tsx +0 -115
- package/src/widgets/base/ReferenceTree.tsx +0 -62
- package/src/widgets/base/Selection.tsx +0 -65
- package/src/widgets/base/Separator.tsx +0 -26
- package/src/widgets/base/Text.tsx +0 -162
- package/src/widgets/base/Time.tsx +0 -41
- package/src/widgets/base/Url.tsx +0 -26
- package/src/widgets/base/many2one/Many2one.tsx +0 -323
- package/src/widgets/base/many2one/Many2oneSuffix.tsx +0 -221
- package/src/widgets/base/many2one/Many2oneSuffixModal.tsx +0 -42
- package/src/widgets/base/many2one/Many2oneTree.tsx +0 -18
- package/src/widgets/base/one2many/One2many.tsx +0 -100
- package/src/widgets/base/one2many/One2manyInput.tsx +0 -724
- package/src/widgets/base/one2many/One2manyTopBar.tsx +0 -158
- package/src/widgets/containers/Container.tsx +0 -99
- package/src/widgets/containers/Group.tsx +0 -37
- package/src/widgets/containers/Notebook.tsx +0 -45
- package/src/widgets/custom/Avatar.tsx +0 -32
- package/src/widgets/custom/ButtonGroup.tsx +0 -166
- package/src/widgets/custom/CodeEditor.tsx +0 -28
- package/src/widgets/custom/Comments.tsx +0 -144
- package/src/widgets/custom/FiberGrid.tsx +0 -48
- package/src/widgets/custom/Indicator.tsx +0 -67
- package/src/widgets/custom/Markdown.tsx +0 -22
- package/src/widgets/custom/MultiCheckbox.tsx +0 -165
- package/src/widgets/custom/Radio.tsx +0 -49
- package/src/widgets/custom/Steps.tsx +0 -55
- package/src/widgets/custom/Switch.tsx +0 -30
- package/src/widgets/custom/Tag.tsx +0 -49
- package/src/widgets/custom/Tags.tsx +0 -164
- package/src/widgets/custom/Timeline.tsx +0 -196
- package/src/widgets/modals/ExportModal.tsx +0 -75
- package/src/widgets/modals/FormModal.tsx +0 -122
- package/src/widgets/modals/SearchModal.tsx +0 -130
- package/src/widgets/modals/TranslationModal.tsx +0 -202
- package/src/widgets/views/Dashboard/Dashboard.tsx +0 -381
- package/src/widgets/views/Dashboard/DashboardForm.tsx +0 -30
- package/src/widgets/views/Dashboard/DashboardTree.tsx +0 -236
- package/src/widgets/views/Dashboard/dashboardHelper.ts +0 -79
- package/src/widgets/views/DashboardGrid/DashboardGrid.tsx +0 -53
- package/src/widgets/views/DashboardGrid/DashboardGrid.types.ts +0 -4
- package/src/widgets/views/DashboardGrid/DashboardGridItem.tsx +0 -62
- package/src/widgets/views/DashboardGrid/DashboardGridItem.types.ts +0 -10
- package/src/widgets/views/DashboardGrid/index.ts +0 -4
- package/src/widgets/views/Form.tsx +0 -1153
- package/src/widgets/views/Graph/Graph.tsx +0 -145
- package/src/widgets/views/Graph/GraphChart.tsx +0 -113
- package/src/widgets/views/Graph/GraphDefaults.ts +0 -170
- package/src/widgets/views/Graph/GraphIndicator.tsx +0 -421
- package/src/widgets/views/Graph/useGraphData.tsx +0 -176
- package/src/widgets/views/SearchTree.tsx +0 -357
- package/src/widgets/views/Tree.tsx +0 -400
- package/src/widgets/views/searchFilter/DateRangePicker.tsx +0 -16
- package/src/widgets/views/searchFilter/DateTimeRangePicker.tsx +0 -63
- package/src/widgets/views/searchFilter/PairFields.tsx +0 -56
- package/src/widgets/views/searchFilter/SearchBottomBar.tsx +0 -58
- package/src/widgets/views/searchFilter/SearchField.tsx +0 -59
- package/src/widgets/views/searchFilter/SearchFilter.tsx +0 -159
- package/src/widgets/views/searchFilter/SearchParams.tsx +0 -32
|
@@ -1,1153 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useState,
|
|
3
|
-
forwardRef,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useEffect,
|
|
6
|
-
useRef,
|
|
7
|
-
useContext,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { Form as FormOoui, parseContext } from "@gisce/ooui";
|
|
10
|
-
import {
|
|
11
|
-
Form as AntForm,
|
|
12
|
-
Button,
|
|
13
|
-
Divider,
|
|
14
|
-
Space,
|
|
15
|
-
Row,
|
|
16
|
-
Alert,
|
|
17
|
-
Spin,
|
|
18
|
-
message,
|
|
19
|
-
} from "antd";
|
|
20
|
-
import Measure from "react-measure";
|
|
21
|
-
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
22
|
-
import debounce from "lodash/debounce";
|
|
23
|
-
|
|
24
|
-
import Container from "@/widgets/containers/Container";
|
|
25
|
-
import {
|
|
26
|
-
processValues,
|
|
27
|
-
getTouchedValues,
|
|
28
|
-
checkFieldsType,
|
|
29
|
-
mergeFieldsDomain,
|
|
30
|
-
getValuesForDomain,
|
|
31
|
-
getOnChangePayload,
|
|
32
|
-
} from "@/helpers/formHelper";
|
|
33
|
-
import ConnectionProvider from "@/ConnectionProvider";
|
|
34
|
-
import showUnsavedChangesDialog from "@/ui/UnsavedChangesDialog";
|
|
35
|
-
import formErrorsDialog from "@/ui/FormErrorsDialog";
|
|
36
|
-
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
37
|
-
import showWarningDialog from "@/ui/WarningDialog";
|
|
38
|
-
import FormProvider, {
|
|
39
|
-
FormContext,
|
|
40
|
-
FormContextType,
|
|
41
|
-
} from "@/context/FormContext";
|
|
42
|
-
import { FormView, One2manyItem } from "@/index";
|
|
43
|
-
import {
|
|
44
|
-
FormModalContext,
|
|
45
|
-
FormModalContextType,
|
|
46
|
-
} from "@/context/FormModalContext";
|
|
47
|
-
|
|
48
|
-
import {
|
|
49
|
-
ActionViewContext,
|
|
50
|
-
ActionViewContextType,
|
|
51
|
-
} from "@/context/ActionViewContext";
|
|
52
|
-
|
|
53
|
-
import {
|
|
54
|
-
ContentRootContext,
|
|
55
|
-
ContentRootContextType,
|
|
56
|
-
} from "@/context/ContentRootContext";
|
|
57
|
-
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
|
-
import { convertToPlain2ManyValues } from "@/helpers/one2manyHelper";
|
|
59
|
-
import { ErrorAlert } from "@/ui/ErrorAlert";
|
|
60
|
-
|
|
61
|
-
export type FormProps = {
|
|
62
|
-
model: string;
|
|
63
|
-
readOnly?: boolean;
|
|
64
|
-
id?: number;
|
|
65
|
-
formView?: FormView;
|
|
66
|
-
values?: any;
|
|
67
|
-
showFooter?: boolean;
|
|
68
|
-
getDataFromAction?: boolean;
|
|
69
|
-
mustClearAfterSave?: boolean;
|
|
70
|
-
submitMode?: "api" | "values" | "2many";
|
|
71
|
-
onSubmitSucceed?: (
|
|
72
|
-
id?: number,
|
|
73
|
-
values?: any,
|
|
74
|
-
formValues?: any,
|
|
75
|
-
x2manyPendingLink?: boolean
|
|
76
|
-
) => void;
|
|
77
|
-
onSubmitError?: (error: any) => void;
|
|
78
|
-
onCancel?: () => void;
|
|
79
|
-
onFieldsChange?: (values: any) => void;
|
|
80
|
-
postSaveAction?: (event: any) => Promise<void>;
|
|
81
|
-
insideButtonModal?: boolean;
|
|
82
|
-
parentContext?: any;
|
|
83
|
-
actionDomain?: any;
|
|
84
|
-
visible?: boolean;
|
|
85
|
-
rootForm?: boolean;
|
|
86
|
-
defaultValues?: any;
|
|
87
|
-
forcedValues?: any;
|
|
88
|
-
parentWidth?: number;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const WIDTH_BREAKPOINT = 800;
|
|
92
|
-
|
|
93
|
-
function Form(props: FormProps, ref: any) {
|
|
94
|
-
const {
|
|
95
|
-
model,
|
|
96
|
-
id,
|
|
97
|
-
onCancel: propsOnCancel,
|
|
98
|
-
onSubmitSucceed: propsOnSubmitSucceed,
|
|
99
|
-
showFooter = false,
|
|
100
|
-
getDataFromAction = false,
|
|
101
|
-
onFieldsChange,
|
|
102
|
-
onSubmitError: propsOnSubmitError,
|
|
103
|
-
readOnly = false,
|
|
104
|
-
mustClearAfterSave = false,
|
|
105
|
-
submitMode = "api",
|
|
106
|
-
values: valuesProps,
|
|
107
|
-
formView: formViewProps,
|
|
108
|
-
postSaveAction,
|
|
109
|
-
insideButtonModal = false,
|
|
110
|
-
parentContext = {},
|
|
111
|
-
actionDomain,
|
|
112
|
-
visible = true,
|
|
113
|
-
rootForm = false,
|
|
114
|
-
defaultValues,
|
|
115
|
-
forcedValues = {},
|
|
116
|
-
parentWidth,
|
|
117
|
-
} = props;
|
|
118
|
-
const { t, lang } = useContext(LocaleContext) as LocaleContextType;
|
|
119
|
-
|
|
120
|
-
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
121
|
-
const [error, setError] = useState<string>();
|
|
122
|
-
const [formOoui, setFormOoui] = useState<FormOoui>();
|
|
123
|
-
const [antForm] = AntForm.useForm();
|
|
124
|
-
const [arch, setArch] = useState<string>();
|
|
125
|
-
const [fields, setFields] = useState<any>();
|
|
126
|
-
const formModalContext = useContext(FormModalContext) as FormModalContextType;
|
|
127
|
-
const [containerWidth, setContainerWidth] = useState<any>();
|
|
128
|
-
const [defaultGetCalled, setDefaultGetCalled] = useState<boolean>(false);
|
|
129
|
-
|
|
130
|
-
const createdId = useRef<number>();
|
|
131
|
-
const originalFormValues = useRef<any>({});
|
|
132
|
-
const lastAssignedValues = useRef<any>({});
|
|
133
|
-
const warningIsShown = useRef<boolean>(false);
|
|
134
|
-
const formSubmitting = useRef<boolean>(false);
|
|
135
|
-
const x2manyPendingLink = useRef<boolean>(false);
|
|
136
|
-
|
|
137
|
-
const widthToEvaluate =
|
|
138
|
-
parentWidth !== undefined ? parentWidth : containerWidth;
|
|
139
|
-
const responsiveBehaviour = widthToEvaluate < WIDTH_BREAKPOINT;
|
|
140
|
-
|
|
141
|
-
const formContext = useContext(FormContext) as FormContextType;
|
|
142
|
-
const { activeId: parentId, getPlainValues: getParentPlainValues } =
|
|
143
|
-
formContext || {};
|
|
144
|
-
|
|
145
|
-
const actionViewContext = useContext(
|
|
146
|
-
ActionViewContext
|
|
147
|
-
) as ActionViewContextType;
|
|
148
|
-
const {
|
|
149
|
-
setFormIsSaving = undefined,
|
|
150
|
-
setFormHasChanges = undefined,
|
|
151
|
-
setCurrentId = undefined,
|
|
152
|
-
setFormIsLoading = undefined,
|
|
153
|
-
setAttachments = undefined,
|
|
154
|
-
title = undefined,
|
|
155
|
-
setTitle = undefined,
|
|
156
|
-
} = (rootForm ? actionViewContext : {}) || {};
|
|
157
|
-
|
|
158
|
-
const contentRootContext = useContext(
|
|
159
|
-
ContentRootContext
|
|
160
|
-
) as ContentRootContextType;
|
|
161
|
-
const { processAction, globalValues } = contentRootContext || {};
|
|
162
|
-
|
|
163
|
-
useImperativeHandle(ref, () => ({
|
|
164
|
-
submitForm,
|
|
165
|
-
getFields,
|
|
166
|
-
getValues,
|
|
167
|
-
getPlainValues,
|
|
168
|
-
getContext,
|
|
169
|
-
fetchValues,
|
|
170
|
-
cancelUnsavedChanges,
|
|
171
|
-
clearAndReload: () => {
|
|
172
|
-
createdId.current = undefined;
|
|
173
|
-
setFormOoui(undefined);
|
|
174
|
-
fetchData();
|
|
175
|
-
},
|
|
176
|
-
}));
|
|
177
|
-
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
setError(undefined);
|
|
180
|
-
|
|
181
|
-
if (!model && !formViewProps) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (!visible) {
|
|
186
|
-
createdId.current = undefined;
|
|
187
|
-
setFormOoui(undefined);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// In the case we set the id to undefined for creating a new item
|
|
192
|
-
if (
|
|
193
|
-
(id === undefined && fields) ||
|
|
194
|
-
(id !== undefined && fields && id < 0)
|
|
195
|
-
) {
|
|
196
|
-
createdId.current = undefined;
|
|
197
|
-
setFormOoui(undefined);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
fetchData();
|
|
201
|
-
}, [id, model, valuesProps, formViewProps, visible]);
|
|
202
|
-
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
if (defaultGetCalled) {
|
|
205
|
-
checkFieldsChanges({
|
|
206
|
-
elementHasLostFocus: true,
|
|
207
|
-
});
|
|
208
|
-
setDefaultGetCalled(false);
|
|
209
|
-
}
|
|
210
|
-
}, [defaultGetCalled]);
|
|
211
|
-
|
|
212
|
-
const onSubmitSucceed = (
|
|
213
|
-
id?: number,
|
|
214
|
-
values?: any,
|
|
215
|
-
formValues?: any,
|
|
216
|
-
x2manyPendingLink?: boolean
|
|
217
|
-
) => {
|
|
218
|
-
setFormHasChanges?.(false);
|
|
219
|
-
setFormIsSaving?.(false);
|
|
220
|
-
propsOnSubmitSucceed?.(id, values, formValues, x2manyPendingLink);
|
|
221
|
-
setCurrentId?.(id);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const onCancel = () => {
|
|
225
|
-
setFormIsSaving?.(false);
|
|
226
|
-
propsOnCancel?.();
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const onSubmitError = (error: any) => {
|
|
230
|
-
setFormIsSaving?.(false);
|
|
231
|
-
propsOnSubmitError?.(error);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
function getCurrentId() {
|
|
235
|
-
return id || createdId.current;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function getFields() {
|
|
239
|
-
return fields;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function getValues() {
|
|
243
|
-
const values = {
|
|
244
|
-
...getCurrentValues(fields),
|
|
245
|
-
...getAdditionalValues(),
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
for (const key in values) {
|
|
249
|
-
if (values[key] === undefined) {
|
|
250
|
-
delete values[key];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return values;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function getPlainValues() {
|
|
258
|
-
const values: any = getValues();
|
|
259
|
-
const fields: any = getFields();
|
|
260
|
-
let reformattedValues: { [key: string]: any } = {};
|
|
261
|
-
|
|
262
|
-
Object.keys(values).forEach((key) => {
|
|
263
|
-
const value = values[key];
|
|
264
|
-
|
|
265
|
-
if (
|
|
266
|
-
fields[key] &&
|
|
267
|
-
fields[key].type === "many2one" &&
|
|
268
|
-
value &&
|
|
269
|
-
Array.isArray(value) &&
|
|
270
|
-
value.length === 2
|
|
271
|
-
) {
|
|
272
|
-
reformattedValues[key] = value[0];
|
|
273
|
-
} else if (
|
|
274
|
-
fields[key] &&
|
|
275
|
-
(fields[key].type === "one2many" || fields[key].type === "many2many") &&
|
|
276
|
-
value &&
|
|
277
|
-
value.items
|
|
278
|
-
) {
|
|
279
|
-
reformattedValues[key] = value.items
|
|
280
|
-
.filter((item: One2manyItem) => item.operation !== "pendingRemove")
|
|
281
|
-
.map((val: any) => val.id);
|
|
282
|
-
} else {
|
|
283
|
-
reformattedValues[key] = value;
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
return reformattedValues;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function getFormValues() {
|
|
291
|
-
const values = {
|
|
292
|
-
...getCurrentValues(fields),
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
for (const key in values) {
|
|
296
|
-
if (values[key] === undefined) {
|
|
297
|
-
delete values[key];
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return values;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
function getContext() {
|
|
305
|
-
return { ...parentContext, ...formOoui?.context };
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function getActiveIdsContext() {
|
|
309
|
-
const currentId = getCurrentId()!;
|
|
310
|
-
|
|
311
|
-
if (!currentId) {
|
|
312
|
-
return {};
|
|
313
|
-
}
|
|
314
|
-
return { active_id: getCurrentId()!, active_ids: [getCurrentId()!] };
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function getAdditionalValues() {
|
|
318
|
-
return {
|
|
319
|
-
id: getCurrentId()!,
|
|
320
|
-
active_id: getCurrentId()!,
|
|
321
|
-
active_ids: [getCurrentId()!],
|
|
322
|
-
parent_id: parentId,
|
|
323
|
-
...globalValues,
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const getDefaultValues = async (fields: any) => {
|
|
328
|
-
const formContext = getCurrentId() ? formOoui?.context : {};
|
|
329
|
-
return await ConnectionProvider.getHandler().defaultGet({
|
|
330
|
-
model,
|
|
331
|
-
fields,
|
|
332
|
-
context: { ...parentContext, ...formContext },
|
|
333
|
-
extraValues: defaultValues,
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const formHasChanges = () => {
|
|
338
|
-
return (
|
|
339
|
-
Object.keys(
|
|
340
|
-
getTouchedValues({
|
|
341
|
-
source: originalFormValues.current,
|
|
342
|
-
target: getCurrentValues(fields),
|
|
343
|
-
fields,
|
|
344
|
-
})
|
|
345
|
-
).length !== 0
|
|
346
|
-
);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
const getCurrentValues = (fields: any) => {
|
|
350
|
-
const currentValues = antForm.getFieldsValue(true);
|
|
351
|
-
return processValues(currentValues, fields);
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
const setFieldValue = (field: string, value?: string) => {
|
|
355
|
-
assignNewValuesToForm({
|
|
356
|
-
values: {
|
|
357
|
-
...processValues(antForm.getFieldsValue(true), fields),
|
|
358
|
-
[field]: value,
|
|
359
|
-
},
|
|
360
|
-
fields,
|
|
361
|
-
reset: false,
|
|
362
|
-
});
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
const getFieldValue = (field: string) => {
|
|
366
|
-
const values = antForm.getFieldsValue(true);
|
|
367
|
-
return values[field];
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
async function checkIfFormHasErrors() {
|
|
371
|
-
try {
|
|
372
|
-
await antForm.validateFields();
|
|
373
|
-
return false;
|
|
374
|
-
} catch (verror) {
|
|
375
|
-
message.error(t("fillRequiredFields"));
|
|
376
|
-
return true;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
const fetchData = async () => {
|
|
380
|
-
setError(undefined);
|
|
381
|
-
setFormIsLoading?.(true);
|
|
382
|
-
|
|
383
|
-
let view;
|
|
384
|
-
|
|
385
|
-
try {
|
|
386
|
-
if (formViewProps) {
|
|
387
|
-
view = { arch: formViewProps.arch, fields: formViewProps.fields };
|
|
388
|
-
} else {
|
|
389
|
-
view = await getFormView();
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
const { fields, arch } = view;
|
|
393
|
-
setFields(fields);
|
|
394
|
-
setArch(arch);
|
|
395
|
-
|
|
396
|
-
await fetchValues({
|
|
397
|
-
fields,
|
|
398
|
-
arch,
|
|
399
|
-
});
|
|
400
|
-
} catch (err) {
|
|
401
|
-
setError(err?.message ? err.message + err.stack : err);
|
|
402
|
-
setFormIsLoading?.(false);
|
|
403
|
-
// setLoading(false);
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
type FetchValuesOptions = {
|
|
408
|
-
fields?: any;
|
|
409
|
-
arch?: string;
|
|
410
|
-
forceRefresh?: boolean;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const fetchValues = async (options?: FetchValuesOptions) => {
|
|
414
|
-
let values;
|
|
415
|
-
let _fields;
|
|
416
|
-
let _arch;
|
|
417
|
-
let hasDefaultGetCalled;
|
|
418
|
-
|
|
419
|
-
setFormIsLoading?.(true);
|
|
420
|
-
setError(undefined);
|
|
421
|
-
|
|
422
|
-
if (options?.fields) {
|
|
423
|
-
_fields = options.fields;
|
|
424
|
-
_arch = options.arch;
|
|
425
|
-
} else {
|
|
426
|
-
_fields = fields;
|
|
427
|
-
_arch = arch;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (valuesProps && options?.forceRefresh !== true) {
|
|
431
|
-
values = valuesProps;
|
|
432
|
-
} else {
|
|
433
|
-
({ values, defaultGetCalled: hasDefaultGetCalled } =
|
|
434
|
-
await fetchValuesFromApi({
|
|
435
|
-
fields: _fields,
|
|
436
|
-
arch: _arch!,
|
|
437
|
-
}));
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if (actionDomain) {
|
|
441
|
-
values = { ...getValuesForDomain(actionDomain), ...values };
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
originalFormValues.current = processValues(values, _fields);
|
|
445
|
-
|
|
446
|
-
assignNewValuesToForm({
|
|
447
|
-
values,
|
|
448
|
-
fields: _fields,
|
|
449
|
-
reset: true,
|
|
450
|
-
isDefaultGet: hasDefaultGetCalled,
|
|
451
|
-
});
|
|
452
|
-
parseForm({ fields: _fields, arch: _arch!, values });
|
|
453
|
-
setFormIsLoading?.(false);
|
|
454
|
-
setFormHasChanges?.(false);
|
|
455
|
-
|
|
456
|
-
if (hasDefaultGetCalled) {
|
|
457
|
-
setDefaultGetCalled(true);
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
const cancelUnsavedChanges = async () => {
|
|
462
|
-
return new Promise(async (resolve) => {
|
|
463
|
-
if (formHasChanges()) {
|
|
464
|
-
showUnsavedChangesDialog({
|
|
465
|
-
lang,
|
|
466
|
-
onOk: () => {
|
|
467
|
-
onCancel?.();
|
|
468
|
-
resolve(true);
|
|
469
|
-
},
|
|
470
|
-
onCancel: () => {
|
|
471
|
-
resolve(false);
|
|
472
|
-
},
|
|
473
|
-
});
|
|
474
|
-
} else {
|
|
475
|
-
onCancel?.();
|
|
476
|
-
resolve(true);
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
const getFormView = async (): Promise<FormView> => {
|
|
482
|
-
if (getDataFromAction) {
|
|
483
|
-
const action =
|
|
484
|
-
await ConnectionProvider.getHandler().getActionStringForModel(model);
|
|
485
|
-
const viewsForAction =
|
|
486
|
-
await ConnectionProvider.getHandler().getViewsForAction({
|
|
487
|
-
action,
|
|
488
|
-
context: parentContext,
|
|
489
|
-
});
|
|
490
|
-
return viewsForAction.views.get("form");
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
return (await ConnectionProvider.getHandler().getView({
|
|
494
|
-
model,
|
|
495
|
-
type: "form",
|
|
496
|
-
context: parentContext,
|
|
497
|
-
})) as FormView;
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
const assignNewValuesToForm = ({
|
|
501
|
-
values: newValues,
|
|
502
|
-
fields,
|
|
503
|
-
reset,
|
|
504
|
-
isDefaultGet = false,
|
|
505
|
-
}: {
|
|
506
|
-
values: any;
|
|
507
|
-
fields: any;
|
|
508
|
-
reset: boolean;
|
|
509
|
-
isDefaultGet?: boolean;
|
|
510
|
-
}) => {
|
|
511
|
-
const currentValues = reset ? {} : antForm.getFieldsValue(true);
|
|
512
|
-
const mergedValues = { ...currentValues, ...newValues };
|
|
513
|
-
const valuesProcessed = processValues(mergedValues, fields);
|
|
514
|
-
const fieldsToUpdate = Object.keys(fields).map((fieldName) => {
|
|
515
|
-
const fieldValue =
|
|
516
|
-
valuesProcessed[fieldName] !== undefined
|
|
517
|
-
? valuesProcessed[fieldName]
|
|
518
|
-
: undefined;
|
|
519
|
-
return {
|
|
520
|
-
name: fieldName,
|
|
521
|
-
touched: false,
|
|
522
|
-
value: fieldValue,
|
|
523
|
-
};
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
if (!isDefaultGet) {
|
|
527
|
-
lastAssignedValues.current = valuesProcessed;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
antForm.setFields(fieldsToUpdate);
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
const fetchValuesFromApi = async ({
|
|
534
|
-
fields,
|
|
535
|
-
arch,
|
|
536
|
-
}: {
|
|
537
|
-
fields: any;
|
|
538
|
-
arch: string;
|
|
539
|
-
}) => {
|
|
540
|
-
let values = {};
|
|
541
|
-
let defaultGetCalled = false;
|
|
542
|
-
|
|
543
|
-
if (getCurrentId()!) {
|
|
544
|
-
values = (
|
|
545
|
-
await ConnectionProvider.getHandler().readObjects({
|
|
546
|
-
model,
|
|
547
|
-
ids: [getCurrentId()!],
|
|
548
|
-
fields,
|
|
549
|
-
context: parentContext,
|
|
550
|
-
})
|
|
551
|
-
)[0];
|
|
552
|
-
|
|
553
|
-
const results = await ConnectionProvider.getHandler().search({
|
|
554
|
-
params: [
|
|
555
|
-
["res_model", "=", model],
|
|
556
|
-
["res_id", "=", getCurrentId()!],
|
|
557
|
-
],
|
|
558
|
-
fields: ["id", "name"],
|
|
559
|
-
context: getContext(),
|
|
560
|
-
model: "ir.attachment",
|
|
561
|
-
});
|
|
562
|
-
setAttachments?.(results);
|
|
563
|
-
} else {
|
|
564
|
-
setAttachments?.([]);
|
|
565
|
-
values = await getDefaultValues(fields);
|
|
566
|
-
defaultGetCalled = true;
|
|
567
|
-
}
|
|
568
|
-
return { values, defaultGetCalled };
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
const submitApi = async (options?: { callOnSubmitSucceed?: boolean }) => {
|
|
572
|
-
const { callOnSubmitSucceed = true } = options || {};
|
|
573
|
-
|
|
574
|
-
if (getCurrentId()) {
|
|
575
|
-
const touchedValues = getTouchedValues({
|
|
576
|
-
source: originalFormValues.current,
|
|
577
|
-
target: getCurrentValues(fields),
|
|
578
|
-
fields,
|
|
579
|
-
});
|
|
580
|
-
|
|
581
|
-
await ConnectionProvider.getHandler().update({
|
|
582
|
-
model,
|
|
583
|
-
id: getCurrentId()!,
|
|
584
|
-
values: { ...touchedValues, ...forcedValues },
|
|
585
|
-
fields,
|
|
586
|
-
context: {
|
|
587
|
-
...parentContext,
|
|
588
|
-
...formOoui?.context,
|
|
589
|
-
},
|
|
590
|
-
});
|
|
591
|
-
originalFormValues.current = getCurrentValues(fields);
|
|
592
|
-
} else {
|
|
593
|
-
const currentValues = getCurrentValues(fields);
|
|
594
|
-
|
|
595
|
-
const newId = await ConnectionProvider.getHandler().create({
|
|
596
|
-
model,
|
|
597
|
-
values: { ...currentValues, ...forcedValues },
|
|
598
|
-
fields,
|
|
599
|
-
context: {
|
|
600
|
-
...parentContext,
|
|
601
|
-
...formOoui?.context,
|
|
602
|
-
},
|
|
603
|
-
});
|
|
604
|
-
createdId.current = newId;
|
|
605
|
-
originalFormValues.current = currentValues;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
if (postSaveAction) {
|
|
609
|
-
await postSaveAction([getCurrentId()]);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (!insideButtonModal && callOnSubmitSucceed) {
|
|
613
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
const submitValues = async (options?: { callOnSubmitSucceed?: boolean }) => {
|
|
618
|
-
const { callOnSubmitSucceed = true } = options || {};
|
|
619
|
-
|
|
620
|
-
if (!insideButtonModal && callOnSubmitSucceed) {
|
|
621
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
const submitForm = async (options?: { callOnSubmitSucceed?: boolean }) => {
|
|
626
|
-
let submitSucceed = false;
|
|
627
|
-
const { callOnSubmitSucceed = true } = options || {};
|
|
628
|
-
formSubmitting.current = true;
|
|
629
|
-
|
|
630
|
-
setError(undefined);
|
|
631
|
-
|
|
632
|
-
if (
|
|
633
|
-
x2manyPendingLink.current &&
|
|
634
|
-
!formHasChanges() &&
|
|
635
|
-
getCurrentId()! &&
|
|
636
|
-
callOnSubmitSucceed
|
|
637
|
-
) {
|
|
638
|
-
formSubmitting.current = false;
|
|
639
|
-
setFormHasChanges?.(false);
|
|
640
|
-
onSubmitSucceed?.(
|
|
641
|
-
getCurrentId(),
|
|
642
|
-
getValues(),
|
|
643
|
-
getFormValues(),
|
|
644
|
-
x2manyPendingLink.current
|
|
645
|
-
);
|
|
646
|
-
x2manyPendingLink.current = false;
|
|
647
|
-
const currentId = getCurrentId()!;
|
|
648
|
-
|
|
649
|
-
if (mustClearAfterSave) {
|
|
650
|
-
createdId.current = undefined;
|
|
651
|
-
assignNewValuesToForm({ values: {}, fields, reset: true });
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
return { succeed: true, id: currentId };
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
if (!formHasChanges() && getCurrentId()! && callOnSubmitSucceed) {
|
|
658
|
-
formSubmitting.current = false;
|
|
659
|
-
setFormHasChanges?.(false);
|
|
660
|
-
onCancel?.();
|
|
661
|
-
return { succeed: true, id: getCurrentId()! };
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
if (await checkIfFormHasErrors()) {
|
|
665
|
-
formSubmitting.current = false;
|
|
666
|
-
formErrorsDialog(lang);
|
|
667
|
-
return { succeed: false, id: getCurrentId()! };
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
setIsSubmitting(true);
|
|
671
|
-
setFormIsSaving?.(true);
|
|
672
|
-
|
|
673
|
-
try {
|
|
674
|
-
if (submitMode === "api") {
|
|
675
|
-
await submitApi(options);
|
|
676
|
-
} else {
|
|
677
|
-
await submitValues(options);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
if (mustClearAfterSave) {
|
|
681
|
-
createdId.current = undefined;
|
|
682
|
-
assignNewValuesToForm({ values: {}, fields, reset: true });
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
await fetchValues({ forceRefresh: true });
|
|
686
|
-
submitSucceed = true;
|
|
687
|
-
message.success(t("savedRegisters"));
|
|
688
|
-
} catch (err) {
|
|
689
|
-
formSubmitting.current = false;
|
|
690
|
-
setIsSubmitting(false);
|
|
691
|
-
setFormIsSaving?.(false);
|
|
692
|
-
onSubmitError?.(err);
|
|
693
|
-
message.error(t("errorWhileSavingForm"));
|
|
694
|
-
setError(err?.message ? err.message : err);
|
|
695
|
-
} finally {
|
|
696
|
-
formSubmitting.current = false;
|
|
697
|
-
setFormIsSaving?.(false);
|
|
698
|
-
setIsSubmitting(false);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
return { succeed: submitSucceed, id: getCurrentId()! };
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
const parseForm = ({
|
|
705
|
-
fields,
|
|
706
|
-
arch,
|
|
707
|
-
values,
|
|
708
|
-
operationInProgress = false,
|
|
709
|
-
}: {
|
|
710
|
-
arch: string;
|
|
711
|
-
fields: any;
|
|
712
|
-
values: any;
|
|
713
|
-
operationInProgress?: boolean;
|
|
714
|
-
}) => {
|
|
715
|
-
const ooui = new FormOoui(fields);
|
|
716
|
-
// TODO: Here we must inject `values` to the ooui parser in order to evaluate arch+values and get the new form container
|
|
717
|
-
ooui.parse(arch, {
|
|
718
|
-
readOnly: readOnly || operationInProgress,
|
|
719
|
-
values: convertToPlain2ManyValues(
|
|
720
|
-
{
|
|
721
|
-
...values,
|
|
722
|
-
...getAdditionalValues(),
|
|
723
|
-
},
|
|
724
|
-
fields
|
|
725
|
-
),
|
|
726
|
-
});
|
|
727
|
-
setFormOoui(ooui);
|
|
728
|
-
|
|
729
|
-
if (ooui.string && ooui.string !== title) {
|
|
730
|
-
setTitle?.(ooui.string);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
if (formModalContext && ooui.string)
|
|
734
|
-
formModalContext.setTitle?.(ooui.string);
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
const checkFieldsChanges = async ({
|
|
738
|
-
elementHasLostFocus = false,
|
|
739
|
-
}: {
|
|
740
|
-
elementHasLostFocus?: boolean;
|
|
741
|
-
}) => {
|
|
742
|
-
if (formSubmitting.current) return;
|
|
743
|
-
|
|
744
|
-
const touchedValues = getTouchedValues({
|
|
745
|
-
source: lastAssignedValues.current,
|
|
746
|
-
target: getCurrentValues(fields),
|
|
747
|
-
fields,
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
const changedFields = Object.keys(touchedValues);
|
|
751
|
-
|
|
752
|
-
if (changedFields.length !== 0) {
|
|
753
|
-
// We check if there are any field of type text, email, url or char inside the changed values
|
|
754
|
-
// in order to ignore the call, because it will fire when element lost focus
|
|
755
|
-
if (
|
|
756
|
-
checkFieldsType({
|
|
757
|
-
changedFields,
|
|
758
|
-
formOoui: formOoui!,
|
|
759
|
-
types: [
|
|
760
|
-
"text",
|
|
761
|
-
"codeeditor",
|
|
762
|
-
"email",
|
|
763
|
-
"url",
|
|
764
|
-
"char",
|
|
765
|
-
"float",
|
|
766
|
-
"float_time",
|
|
767
|
-
"integer",
|
|
768
|
-
"many2one",
|
|
769
|
-
],
|
|
770
|
-
}) &&
|
|
771
|
-
elementHasLostFocus !== true
|
|
772
|
-
) {
|
|
773
|
-
return;
|
|
774
|
-
} else {
|
|
775
|
-
const values = processValues(antForm.getFieldsValue(true), fields);
|
|
776
|
-
lastAssignedValues.current = values;
|
|
777
|
-
|
|
778
|
-
onFieldsChange?.(values);
|
|
779
|
-
setFormHasChanges?.(true);
|
|
780
|
-
|
|
781
|
-
evaluateChanges(changedFields);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
const debouncedCheckFieldsChanges = debounce(checkFieldsChanges, 100);
|
|
787
|
-
|
|
788
|
-
const evaluateChanges = async (changedFields: any) => {
|
|
789
|
-
try {
|
|
790
|
-
for (let i = 0; i < changedFields.length; i += 1) {
|
|
791
|
-
const changedField = changedFields[i];
|
|
792
|
-
await processFieldOnChange(changedField);
|
|
793
|
-
}
|
|
794
|
-
} catch (err) {
|
|
795
|
-
showErrorDialog(err);
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
const processFieldOnChange = async (fieldName: string) => {
|
|
800
|
-
const onChangeFieldAction = formOoui?.onChangeFields[fieldName];
|
|
801
|
-
|
|
802
|
-
if (!onChangeFieldAction) {
|
|
803
|
-
parseForm({
|
|
804
|
-
fields,
|
|
805
|
-
arch: arch!,
|
|
806
|
-
values: getCurrentValues(fields),
|
|
807
|
-
});
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
const payload = getOnChangePayload({
|
|
812
|
-
values: {
|
|
813
|
-
...getCurrentValues(fields),
|
|
814
|
-
context: {
|
|
815
|
-
...parentContext,
|
|
816
|
-
...formOoui?.context,
|
|
817
|
-
},
|
|
818
|
-
},
|
|
819
|
-
parentValues: getParentPlainValues?.(),
|
|
820
|
-
onChangeFieldActionArgs: onChangeFieldAction.args,
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
const response = await ConnectionProvider.getHandler().executeOnChange({
|
|
824
|
-
model,
|
|
825
|
-
action: onChangeFieldAction.method,
|
|
826
|
-
ids: getCurrentId()! ? [getCurrentId()!] : [],
|
|
827
|
-
payload,
|
|
828
|
-
fields,
|
|
829
|
-
});
|
|
830
|
-
|
|
831
|
-
if (response.value) {
|
|
832
|
-
const processedValues = {
|
|
833
|
-
...getCurrentValues(fields),
|
|
834
|
-
...response.value,
|
|
835
|
-
};
|
|
836
|
-
parseForm({ fields, arch: arch!, values: processedValues });
|
|
837
|
-
assignNewValuesToForm({
|
|
838
|
-
values: processedValues,
|
|
839
|
-
fields: fields,
|
|
840
|
-
reset: false,
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
response.warning &&
|
|
846
|
-
response.warning.title &&
|
|
847
|
-
response.warning.message &&
|
|
848
|
-
!warningIsShown.current
|
|
849
|
-
) {
|
|
850
|
-
const { title, message } = response.warning;
|
|
851
|
-
warningIsShown.current = true;
|
|
852
|
-
showWarningDialog(title, message, () => {
|
|
853
|
-
warningIsShown.current = false;
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
if (response.domain && Object.keys(response.domain).length > 0) {
|
|
858
|
-
const proccessedFields = mergeFieldsDomain({
|
|
859
|
-
fieldsDomain: response.domain,
|
|
860
|
-
fields,
|
|
861
|
-
});
|
|
862
|
-
|
|
863
|
-
parseForm({
|
|
864
|
-
fields: proccessedFields,
|
|
865
|
-
arch: arch!,
|
|
866
|
-
values: getCurrentValues(proccessedFields),
|
|
867
|
-
});
|
|
868
|
-
setFields(proccessedFields);
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
async function runObjectButton({
|
|
873
|
-
action,
|
|
874
|
-
context,
|
|
875
|
-
}: {
|
|
876
|
-
action: string;
|
|
877
|
-
context: any;
|
|
878
|
-
}) {
|
|
879
|
-
const response = await ConnectionProvider.getHandler().execute({
|
|
880
|
-
model,
|
|
881
|
-
action,
|
|
882
|
-
payload: [getCurrentId()!],
|
|
883
|
-
context: {
|
|
884
|
-
...formOoui?.context,
|
|
885
|
-
...parentContext,
|
|
886
|
-
...context,
|
|
887
|
-
},
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
if (
|
|
891
|
-
typeof response === "object" &&
|
|
892
|
-
response !== null &&
|
|
893
|
-
Object.keys(response).length === 0 &&
|
|
894
|
-
insideButtonModal
|
|
895
|
-
) {
|
|
896
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
897
|
-
} else if (
|
|
898
|
-
response.type &&
|
|
899
|
-
response.type === "ir.actions.act_window_close"
|
|
900
|
-
) {
|
|
901
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
902
|
-
} else if (response.type) {
|
|
903
|
-
let responseContext = {};
|
|
904
|
-
|
|
905
|
-
if (response.context) {
|
|
906
|
-
responseContext = parseContext({
|
|
907
|
-
context: response.context,
|
|
908
|
-
fields,
|
|
909
|
-
values: getValues(),
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
await runAction({
|
|
914
|
-
actionData: response,
|
|
915
|
-
context: { ...context, ...responseContext },
|
|
916
|
-
});
|
|
917
|
-
} else {
|
|
918
|
-
await fetchValues({ forceRefresh: true });
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
async function runWorkflowButton({ action }: { action: string }) {
|
|
923
|
-
const response = await ConnectionProvider.getHandler().executeWorkflow({
|
|
924
|
-
model,
|
|
925
|
-
action,
|
|
926
|
-
payload: getCurrentId()!,
|
|
927
|
-
});
|
|
928
|
-
|
|
929
|
-
if (response.type && response.type === "ir.actions.act_window_close") {
|
|
930
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
931
|
-
} else {
|
|
932
|
-
await fetchValues({ forceRefresh: true });
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
async function runActionButton({
|
|
937
|
-
action,
|
|
938
|
-
context,
|
|
939
|
-
}: {
|
|
940
|
-
action: string;
|
|
941
|
-
context: any;
|
|
942
|
-
}) {
|
|
943
|
-
const actionData = (
|
|
944
|
-
await ConnectionProvider.getHandler().readObjects({
|
|
945
|
-
model: "ir.actions.actions",
|
|
946
|
-
ids: [parseInt(action)],
|
|
947
|
-
context: parentContext,
|
|
948
|
-
})
|
|
949
|
-
)[0];
|
|
950
|
-
|
|
951
|
-
await runAction({ actionData, context });
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
async function runAction({
|
|
955
|
-
actionData,
|
|
956
|
-
context,
|
|
957
|
-
}: {
|
|
958
|
-
actionData: any;
|
|
959
|
-
context: any;
|
|
960
|
-
}) {
|
|
961
|
-
const { closeParent } =
|
|
962
|
-
(await processAction?.({
|
|
963
|
-
actionData,
|
|
964
|
-
fields,
|
|
965
|
-
values: getValues(),
|
|
966
|
-
context: {
|
|
967
|
-
...parentContext,
|
|
968
|
-
...formOoui?.context,
|
|
969
|
-
...context,
|
|
970
|
-
},
|
|
971
|
-
onRefreshParentValues: () => {
|
|
972
|
-
fetchValues({ forceRefresh: true });
|
|
973
|
-
},
|
|
974
|
-
})) || {};
|
|
975
|
-
|
|
976
|
-
if (!rootForm && closeParent) {
|
|
977
|
-
onSubmitSucceed?.(getCurrentId(), getValues(), getFormValues());
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
function elementHasLostFocus() {
|
|
982
|
-
checkFieldsChanges({ elementHasLostFocus: true });
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
function updateOperationInProgress(value: boolean) {
|
|
986
|
-
parseForm({
|
|
987
|
-
fields,
|
|
988
|
-
arch: arch!,
|
|
989
|
-
values: getCurrentValues(fields),
|
|
990
|
-
operationInProgress: value,
|
|
991
|
-
});
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
async function executeButtonAction({
|
|
995
|
-
type,
|
|
996
|
-
action,
|
|
997
|
-
context,
|
|
998
|
-
}: {
|
|
999
|
-
type: string;
|
|
1000
|
-
action: string;
|
|
1001
|
-
context?: any;
|
|
1002
|
-
}) {
|
|
1003
|
-
// If the type of the button it's a cancel, we just close our form
|
|
1004
|
-
if (type === "cancel") {
|
|
1005
|
-
onCancel?.();
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// We check for required fields
|
|
1010
|
-
if (await checkIfFormHasErrors()) {
|
|
1011
|
-
formErrorsDialog(lang);
|
|
1012
|
-
return;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
let mustBlockButtons = false;
|
|
1016
|
-
|
|
1017
|
-
try {
|
|
1018
|
-
if (formHasChanges() || getCurrentId() === undefined) {
|
|
1019
|
-
mustBlockButtons = true;
|
|
1020
|
-
updateOperationInProgress(true);
|
|
1021
|
-
if (submitMode === "2many") {
|
|
1022
|
-
await submitApi({ callOnSubmitSucceed: false });
|
|
1023
|
-
x2manyPendingLink.current = true;
|
|
1024
|
-
} else {
|
|
1025
|
-
await submitForm({ callOnSubmitSucceed: false });
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
const additionalContext = x2manyPendingLink.current
|
|
1030
|
-
? getActiveIdsContext()
|
|
1031
|
-
: {};
|
|
1032
|
-
|
|
1033
|
-
const updatedContext = { ...context, ...additionalContext };
|
|
1034
|
-
|
|
1035
|
-
if (type === "object") {
|
|
1036
|
-
await runObjectButton({ action, context: updatedContext });
|
|
1037
|
-
} else if (type === "workflow") {
|
|
1038
|
-
await runWorkflowButton({ action });
|
|
1039
|
-
} else if (type === "action") {
|
|
1040
|
-
await runActionButton({ action, context: updatedContext });
|
|
1041
|
-
}
|
|
1042
|
-
mustBlockButtons && updateOperationInProgress(false);
|
|
1043
|
-
} catch (err) {
|
|
1044
|
-
mustBlockButtons && updateOperationInProgress(false);
|
|
1045
|
-
showErrorDialog(err);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
const content = () => {
|
|
1050
|
-
if (!formOoui && !error) {
|
|
1051
|
-
return <Spin />;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
if (!model && !formViewProps) {
|
|
1055
|
-
return null;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
if (!visible) {
|
|
1059
|
-
return null;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
return (
|
|
1063
|
-
<>
|
|
1064
|
-
<FormProvider
|
|
1065
|
-
getValues={getValues}
|
|
1066
|
-
getPlainValues={getPlainValues}
|
|
1067
|
-
getFields={getFields}
|
|
1068
|
-
domain={actionDomain}
|
|
1069
|
-
activeId={id}
|
|
1070
|
-
activeModel={model}
|
|
1071
|
-
setFieldValue={setFieldValue}
|
|
1072
|
-
getFieldValue={getFieldValue}
|
|
1073
|
-
executeButtonAction={executeButtonAction}
|
|
1074
|
-
getContext={getContext}
|
|
1075
|
-
submitForm={submitForm}
|
|
1076
|
-
fetchValues={fetchValues}
|
|
1077
|
-
formHasChanges={formHasChanges}
|
|
1078
|
-
elementHasLostFocus={elementHasLostFocus}
|
|
1079
|
-
>
|
|
1080
|
-
<AntForm
|
|
1081
|
-
form={antForm}
|
|
1082
|
-
onFieldsChange={() => {
|
|
1083
|
-
debouncedCheckFieldsChanges({ elementHasLostFocus: false });
|
|
1084
|
-
}}
|
|
1085
|
-
component={false}
|
|
1086
|
-
>
|
|
1087
|
-
{formOoui && (
|
|
1088
|
-
<Container
|
|
1089
|
-
container={formOoui.container}
|
|
1090
|
-
responsiveBehaviour={responsiveBehaviour}
|
|
1091
|
-
/>
|
|
1092
|
-
)}
|
|
1093
|
-
</AntForm>
|
|
1094
|
-
</FormProvider>
|
|
1095
|
-
</>
|
|
1096
|
-
);
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
const footer = () => {
|
|
1100
|
-
return (
|
|
1101
|
-
<>
|
|
1102
|
-
<Divider />
|
|
1103
|
-
<Row justify="end">
|
|
1104
|
-
<Space>
|
|
1105
|
-
<Button
|
|
1106
|
-
icon={<CloseOutlined />}
|
|
1107
|
-
disabled={isSubmitting}
|
|
1108
|
-
onClick={async () => {
|
|
1109
|
-
await cancelUnsavedChanges();
|
|
1110
|
-
}}
|
|
1111
|
-
>
|
|
1112
|
-
Cancel
|
|
1113
|
-
</Button>
|
|
1114
|
-
<Button
|
|
1115
|
-
disabled={isSubmitting || readOnly}
|
|
1116
|
-
loading={isSubmitting}
|
|
1117
|
-
icon={<CheckOutlined />}
|
|
1118
|
-
onClick={async () => {
|
|
1119
|
-
await submitForm();
|
|
1120
|
-
}}
|
|
1121
|
-
type="primary"
|
|
1122
|
-
>
|
|
1123
|
-
OK
|
|
1124
|
-
</Button>
|
|
1125
|
-
</Space>
|
|
1126
|
-
</Row>
|
|
1127
|
-
</>
|
|
1128
|
-
);
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
|
-
if (!visible) {
|
|
1132
|
-
return null;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
return (
|
|
1136
|
-
<Measure
|
|
1137
|
-
bounds
|
|
1138
|
-
onResize={(contentRect) => {
|
|
1139
|
-
setContainerWidth(contentRect.bounds?.width!);
|
|
1140
|
-
}}
|
|
1141
|
-
>
|
|
1142
|
-
{({ measureRef }) => (
|
|
1143
|
-
<div className="pb-2" ref={measureRef}>
|
|
1144
|
-
{error && <ErrorAlert className="mt-5 mb-10" error={error} />}
|
|
1145
|
-
{content()}
|
|
1146
|
-
{showFooter && footer()}
|
|
1147
|
-
</div>
|
|
1148
|
-
)}
|
|
1149
|
-
</Measure>
|
|
1150
|
-
);
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
export default forwardRef(Form);
|