@wavemaker/react-runtime 11.14.1-rc.236
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/actions/base-action.js +32 -0
- package/actions/login-action.js +53 -0
- package/actions/logout-action.js +41 -0
- package/actions/navigation-action.js +145 -0
- package/actions/notification-action.js +147 -0
- package/actions/timer-action.js +164 -0
- package/actions/toast-provider.js +111 -0
- package/actions/toast.js +115 -0
- package/actions/toast.service.js +94 -0
- package/actions/types/index.js +11 -0
- package/components/advanced/carousel/index.js +456 -0
- package/components/advanced/carousel/props.js +5 -0
- package/components/advanced/carousel/template.js +72 -0
- package/components/advanced/login/index.js +307 -0
- package/components/advanced/login/props.js +5 -0
- package/components/advanced/marquee/index.js +158 -0
- package/components/advanced/marquee/props.js +5 -0
- package/components/basic/anchor/index.js +239 -0
- package/components/basic/anchor/props.js +5 -0
- package/components/basic/audio/index.js +61 -0
- package/components/basic/html/index.js +158 -0
- package/components/basic/icon/index.js +85 -0
- package/components/basic/iframe/iframe.utils.js +10 -0
- package/components/basic/iframe/index.js +95 -0
- package/components/basic/label/index.js +139 -0
- package/components/basic/message/index.js +120 -0
- package/components/basic/message/props.js +5 -0
- package/components/basic/picture/index.js +117 -0
- package/components/basic/picture/props.js +5 -0
- package/components/basic/progress-bar/index.js +168 -0
- package/components/basic/progress-bar/props.js +18 -0
- package/components/basic/progress-circle/index.js +196 -0
- package/components/basic/progress-circle/props.js +16 -0
- package/components/basic/richtexteditor/index.js +533 -0
- package/components/basic/richtexteditor/props.js +5 -0
- package/components/basic/search/index.js +1023 -0
- package/components/basic/search/props.js +5 -0
- package/components/basic/search/providers.js +350 -0
- package/components/basic/spinner/index.js +202 -0
- package/components/basic/spinner/props.js +12 -0
- package/components/basic/tile/index.js +91 -0
- package/components/basic/tree/Components/TreeNodeComponent.js +142 -0
- package/components/basic/tree/index.js +503 -0
- package/components/basic/tree/props.js +5 -0
- package/components/basic/tree/utils.js +154 -0
- package/components/basic/video/index.js +85 -0
- package/components/basic/video/props.js +5 -0
- package/components/chart/components/barColumnChart/index.js +132 -0
- package/components/chart/components/barColumnChart/props.js +5 -0
- package/components/chart/components/bubbleChart/index.js +176 -0
- package/components/chart/components/bubbleChart/props.js +5 -0
- package/components/chart/components/chartLegend/components/ClassicLegendItem.js +39 -0
- package/components/chart/components/chartLegend/components/FuriousLegendItem.js +81 -0
- package/components/chart/components/chartLegend/index.js +69 -0
- package/components/chart/components/chartLegend/props.js +5 -0
- package/components/chart/components/chartLegend/utils.js +31 -0
- package/components/chart/components/chartTooltip/index.js +53 -0
- package/components/chart/components/chartTooltip/styles.js +37 -0
- package/components/chart/components/chartTooltip/utils.js +23 -0
- package/components/chart/components/cumulativeLineChart/index.js +113 -0
- package/components/chart/components/cumulativeLineChart/props.js +5 -0
- package/components/chart/components/cumulativeLineChart/utils.js +34 -0
- package/components/chart/components/index.js +40 -0
- package/components/chart/components/lineAreaChart/index.js +140 -0
- package/components/chart/components/lineAreaChart/props.js +5 -0
- package/components/chart/components/noDataMessage/index.js +27 -0
- package/components/chart/components/pieDonutChart/index.js +171 -0
- package/components/chart/components/pieDonutChart/props.js +5 -0
- package/components/chart/constant.js +72 -0
- package/components/chart/index.js +930 -0
- package/components/chart/props.js +5 -0
- package/components/chart/utils.js +691 -0
- package/components/common/AppSpinner.js +36 -0
- package/components/common/app-spinner.js +26 -0
- package/components/common/index.js +12 -0
- package/components/constants.js +1208 -0
- package/components/container/accordion/accordion-pane/index.js +108 -0
- package/components/container/accordion/accordion-pane/props.js +11 -0
- package/components/container/accordion/index.js +232 -0
- package/components/container/accordion/props.js +13 -0
- package/components/container/alignment-utils.js +183 -0
- package/components/container/index.js +188 -0
- package/components/container/layout-grid/grid-column/index.js +34 -0
- package/components/container/layout-grid/grid-row/index.js +24 -0
- package/components/container/layout-grid/index.js +33 -0
- package/components/container/linear-layout/index.js +72 -0
- package/components/container/linear-layout/linear-layout-item/index.js +43 -0
- package/components/container/panel/components/panel-header/index.js +144 -0
- package/components/container/panel/components/panel-header/props.js +5 -0
- package/components/container/panel/hooks.js +144 -0
- package/components/container/panel/index.js +286 -0
- package/components/container/panel/props.js +5 -0
- package/components/container/props.js +5 -0
- package/components/container/tabs/index.js +379 -0
- package/components/container/tabs/props.js +20 -0
- package/components/container/tabs/tab-pane/index.js +42 -0
- package/components/container/tabs/tab-pane/props.js +5 -0
- package/components/container/wizard/WizardContext.js +16 -0
- package/components/container/wizard/components/StepComponents.js +100 -0
- package/components/container/wizard/components/WizardStep.js +89 -0
- package/components/container/wizard/index.js +710 -0
- package/components/container/wizard/props.js +5 -0
- package/components/container/wizard/utils.js +133 -0
- package/components/container/wizard/wizard-action/index.js +22 -0
- package/components/container/wizard/wizard-step/index.js +94 -0
- package/components/data/card/card-actions/index.js +24 -0
- package/components/data/card/card-content/index.js +38 -0
- package/components/data/card/card-footer/index.js +24 -0
- package/components/data/card/index.js +246 -0
- package/components/data/card/props.js +5 -0
- package/components/data/form/base-form/constant.js +39 -0
- package/components/data/form/base-form/index.js +460 -0
- package/components/data/form/base-form/props.js +29 -0
- package/components/data/form/base-form/utils.js +42 -0
- package/components/data/form/dynamic-fields/index.js +196 -0
- package/components/data/form/dynamic-fields/props.js +5 -0
- package/components/data/form/dynamic-fields/utils.js +237 -0
- package/components/data/form/form-action/index.js +71 -0
- package/components/data/form/form-body/index.js +26 -0
- package/components/data/form/form-context.js +34 -0
- package/components/data/form/form-controller/props.js +19 -0
- package/components/data/form/form-controller/validation-contrustor.js +313 -0
- package/components/data/form/form-controller/withFormController.js +320 -0
- package/components/data/form/form-field/base-field.js +138 -0
- package/components/data/form/form-field/index.js +36 -0
- package/components/data/form/form-field/props.js +5 -0
- package/components/data/form/form-footer/index.js +26 -0
- package/components/data/form/form-header/index.js +56 -0
- package/components/data/form/index.js +39 -0
- package/components/data/form/props.js +5 -0
- package/components/data/list/components/GroupHeader.js +35 -0
- package/components/data/list/components/GroupedListItems.js +98 -0
- package/components/data/list/components/ListContainer.js +27 -0
- package/components/data/list/components/ListDND.js +241 -0
- package/components/data/list/components/ListHeader.js +59 -0
- package/components/data/list/components/ListItem.js +148 -0
- package/components/data/list/components/ListItemWithTemplate.js +59 -0
- package/components/data/list/components/ListItems.js +231 -0
- package/components/data/list/components/ListPagination.js +165 -0
- package/components/data/list/components/LoadMoreButton.js +39 -0
- package/components/data/list/components/NoDataMessage.js +22 -0
- package/components/data/list/components/StandardListItems.js +84 -0
- package/components/data/list/components/index.js +119 -0
- package/components/data/list/components/props.js +5 -0
- package/components/data/list/hooks/index.js +75 -0
- package/components/data/list/hooks/props.js +5 -0
- package/components/data/list/hooks/useCurrentPageItems.js +48 -0
- package/components/data/list/hooks/useGroupedData.js +37 -0
- package/components/data/list/hooks/useListData.js +60 -0
- package/components/data/list/hooks/useListEffects.js +285 -0
- package/components/data/list/hooks/useListEventHandlers.js +291 -0
- package/components/data/list/hooks/useListPagination.js +168 -0
- package/components/data/list/hooks/useListState.js +98 -0
- package/components/data/list/hooks/useListStateManager.js +195 -0
- package/components/data/list/hooks/usePaginatedGroupedData.js +121 -0
- package/components/data/list/index.js +611 -0
- package/components/data/list/props.js +5 -0
- package/components/data/list/templates/media-template.js +53 -0
- package/components/data/list/utils/constants.js +81 -0
- package/components/data/list/utils/list-helpers.js +173 -0
- package/components/data/list/utils/list-widget-methods.js +114 -0
- package/components/data/live-filter/index.js +279 -0
- package/components/data/live-filter/props.js +12 -0
- package/components/data/live-form/index.js +93 -0
- package/components/data/live-form/props.js +16 -0
- package/components/data/pagination/components/BasicPagination.js +77 -0
- package/components/data/pagination/components/ClassicPagination.js +191 -0
- package/components/data/pagination/components/InlinePagination.js +99 -0
- package/components/data/pagination/components/LoadingComponent.js +31 -0
- package/components/data/pagination/components/PageSizeSelector.js +175 -0
- package/components/data/pagination/components/PagerNavigation.js +105 -0
- package/components/data/pagination/components/TotalRecords.js +52 -0
- package/components/data/pagination/components/index.js +47 -0
- package/components/data/pagination/components/props.js +5 -0
- package/components/data/pagination/hooks/index.js +19 -0
- package/components/data/pagination/hooks/props.js +5 -0
- package/components/data/pagination/hooks/useNavigationSize.js +44 -0
- package/components/data/pagination/hooks/usePagination.js +796 -0
- package/components/data/pagination/index.js +322 -0
- package/components/data/table/components/AddNewRow.js +190 -0
- package/components/data/table/components/EditableCell.js +91 -0
- package/components/data/table/components/FieldValidationError.js +24 -0
- package/components/data/table/components/RowExpansionButton.js +74 -0
- package/components/data/table/components/TableBody.js +279 -0
- package/components/data/table/components/TableFilters.js +325 -0
- package/components/data/table/components/TableFooterActions.js +48 -0
- package/components/data/table/components/TableHeader.js +174 -0
- package/components/data/table/components/TablePanelHeading.js +68 -0
- package/components/data/table/components/index.js +74 -0
- package/components/data/table/hooks/index.js +219 -0
- package/components/data/table/hooks/useCellState.js +117 -0
- package/components/data/table/hooks/useDynamicColumns.js +85 -0
- package/components/data/table/hooks/useEditingState.js +47 -0
- package/components/data/table/hooks/useFormWidget.js +184 -0
- package/components/data/table/hooks/usePaginationState.js +60 -0
- package/components/data/table/hooks/usePanelStructure.js +40 -0
- package/components/data/table/hooks/useResponsiveColumns.js +34 -0
- package/components/data/table/hooks/useRowExpansion.js +110 -0
- package/components/data/table/hooks/useRowHandlers.js +38 -0
- package/components/data/table/hooks/useRowSelection.js +213 -0
- package/components/data/table/hooks/useServerSideSorting.js +165 -0
- package/components/data/table/hooks/useTableColumns.js +263 -0
- package/components/data/table/hooks/useTableData.js +154 -0
- package/components/data/table/hooks/useTableEdit.js +467 -0
- package/components/data/table/hooks/useTableEffects.js +139 -0
- package/components/data/table/hooks/useTableFilter.js +389 -0
- package/components/data/table/hooks/useTableInitialization.js +103 -0
- package/components/data/table/hooks/useTableState.js +69 -0
- package/components/data/table/hooks/useTableStateManager.js +558 -0
- package/components/data/table/index.js +1295 -0
- package/components/data/table/live-table/index.js +232 -0
- package/components/data/table/props.js +5 -0
- package/components/data/table/table-action/index.js +78 -0
- package/components/data/table/table-column/index.js +35 -0
- package/components/data/table/table-row/index.js +49 -0
- package/components/data/table/table-row-action/index.js +74 -0
- package/components/data/table/utils/buildSelectionColumns.js +173 -0
- package/components/data/table/utils/columnBuilder.js +209 -0
- package/components/data/table/utils/columnProxy.js +48 -0
- package/components/data/table/utils/columnWidthDistribution.js +98 -0
- package/components/data/table/utils/constants.js +80 -0
- package/components/data/table/utils/crud-handlers.js +518 -0
- package/components/data/table/utils/dynamic-columns.js +118 -0
- package/components/data/table/utils/index.js +607 -0
- package/components/data/table/utils/renderDisplayCell.js +183 -0
- package/components/data/table/utils/selectionUtils.js +166 -0
- package/components/data/table/utils/table-helpers.js +100 -0
- package/components/data/table/utils/validation.js +124 -0
- package/components/data/types.js +113 -0
- package/components/data/utils/field-data-utils.js +66 -0
- package/components/data/utils/filter-field-util.js +81 -0
- package/components/data/utils/index.js +216 -0
- package/components/dialogs/alert-dialog/index.js +80 -0
- package/components/dialogs/confirm-dialog/index.js +105 -0
- package/components/dialogs/dialog/index.js +56 -0
- package/components/dialogs/dialog-actions/index.js +18 -0
- package/components/dialogs/dialog-body/index.js +21 -0
- package/components/dialogs/dialog-content/index.js +30 -0
- package/components/dialogs/dialog-header/index.js +93 -0
- package/components/dialogs/iframe-dialog/index.js +114 -0
- package/components/dialogs/index.js +129 -0
- package/components/dialogs/login-dialog/index.js +369 -0
- package/components/dialogs/login-dialog/props.js +5 -0
- package/components/dialogs/page-dialog/index.js +96 -0
- package/components/dialogs/withDialogWrapper.js +108 -0
- package/components/form/button/index.js +216 -0
- package/components/form/button-group/index.js +60 -0
- package/components/input/calendar/index.js +546 -0
- package/components/input/calendar/props.js +5 -0
- package/components/input/calendar/utils.js +340 -0
- package/components/input/chips/SortableChip/index.js +115 -0
- package/components/input/chips/SortableChip/props.js +5 -0
- package/components/input/chips/index.js +488 -0
- package/components/input/chips/props.js +5 -0
- package/components/input/chips/utils.js +259 -0
- package/components/input/color-picker/index.js +678 -0
- package/components/input/color-picker/props.js +5 -0
- package/components/input/composite/index.js +137 -0
- package/components/input/currency/index.js +263 -0
- package/components/input/currency/props.js +5 -0
- package/components/input/default/checkbox/index.js +230 -0
- package/components/input/default/checkbox/props.js +5 -0
- package/components/input/default/checkboxset/index.js +476 -0
- package/components/input/default/checkboxset/props.js +5 -0
- package/components/input/default/radioset/index.js +379 -0
- package/components/input/default/radioset/props.js +5 -0
- package/components/input/default/switch/index.js +490 -0
- package/components/input/default/switch/prop.js +5 -0
- package/components/input/epoch/date/components/DatePickerPopover.js +220 -0
- package/components/input/epoch/date/index.js +520 -0
- package/components/input/epoch/date/props.js +5 -0
- package/components/input/epoch/date/styled.js +70 -0
- package/components/input/epoch/date/utils.js +108 -0
- package/components/input/epoch/datetime/index.js +656 -0
- package/components/input/epoch/datetime/props.js +5 -0
- package/components/input/epoch/datetime/styled.js +90 -0
- package/components/input/epoch/datetime/utils.js +244 -0
- package/components/input/epoch/time/index.js +412 -0
- package/components/input/epoch/time/props.js +5 -0
- package/components/input/epoch/time/utils.js +209 -0
- package/components/input/fileupload/Utils.js +134 -0
- package/components/input/fileupload/components/ListItems.js +140 -0
- package/components/input/fileupload/components/MultiUpload.js +85 -0
- package/components/input/fileupload/components/SingleUpload.js +65 -0
- package/components/input/fileupload/index.js +170 -0
- package/components/input/fileupload/props.js +5 -0
- package/components/input/fileupload/useFileUpload.js +400 -0
- package/components/input/number/index.js +295 -0
- package/components/input/number/props.js +5 -0
- package/components/input/rating/index.js +368 -0
- package/components/input/rating/props.js +5 -0
- package/components/input/select/index.js +344 -0
- package/components/input/select/props.js +5 -0
- package/components/input/slider/index.js +167 -0
- package/components/input/slider/props.js +5 -0
- package/components/input/text/index.js +434 -0
- package/components/input/text/props.js +5 -0
- package/components/input/text/util.js +179 -0
- package/components/input/textarea/index.js +347 -0
- package/components/input/textarea/props.js +5 -0
- package/components/layout/footer/index.js +30 -0
- package/components/layout/header/index.js +30 -0
- package/components/layout/leftnav/index.js +44 -0
- package/components/layout/rightnav/index.js +32 -0
- package/components/layout/topnav/index.js +34 -0
- package/components/navbar/index.js +41 -0
- package/components/navbar/nav/index.js +102 -0
- package/components/navbar/nav/props.js +5 -0
- package/components/navbar/nav-item/index.js +44 -0
- package/components/navigation/breadcrumb/index.js +56 -0
- package/components/navigation/breadcrumb/props.js +5 -0
- package/components/navigation/menu/components/ListItems.js +66 -0
- package/components/navigation/menu/constants.js +101 -0
- package/components/navigation/menu/index.js +807 -0
- package/components/navigation/menu/props.js +5 -0
- package/components/navigation/popover/index.js +209 -0
- package/components/navigation/popover/props.js +15 -0
- package/components/page/content/index.js +28 -0
- package/components/page/error-boundary/index.js +108 -0
- package/components/page/index.js +137 -0
- package/components/page/page-content/index.js +23 -0
- package/components/page/partial/index.js +36 -0
- package/components/page/partial-container/index.js +48 -0
- package/components/page/props.js +5 -0
- package/components/page/toast-container/index.js +33 -0
- package/components/prefab/container/index.js +46 -0
- package/components/prefab/index.js +67 -0
- package/context/AppContext.js +25 -0
- package/context/AppSpinnerProvider.js +43 -0
- package/context/LocalizationProvider.js +79 -0
- package/context/PrefabContext.js +66 -0
- package/context/WidgetProvider.js +187 -0
- package/core/app-config.js +1 -0
- package/core/app.service.js +357 -0
- package/core/appVariablesStore.js +20 -0
- package/core/appstore.js +88 -0
- package/core/constants/currency-constant.js +1071 -0
- package/core/constants/events.js +34 -0
- package/core/constants/index.js +27 -0
- package/core/dialog.service.js +76 -0
- package/core/event-notifier.js +151 -0
- package/core/formatter/date-formatters.js +222 -0
- package/core/formatter/index.js +131 -0
- package/core/formatter/number-formatters.js +142 -0
- package/core/formatter/security-formatters.js +323 -0
- package/core/formatter/string-formatters.js +52 -0
- package/core/formatter/types.js +18 -0
- package/core/formatters.js +24 -0
- package/core/proxy-service.js +412 -0
- package/core/script-registry.js +63 -0
- package/core/security.service.js +11 -0
- package/core/util/common.js +33 -0
- package/core/util/dom.js +107 -0
- package/core/util/index.js +136 -0
- package/core/util/security.js +184 -0
- package/core/util/utils.js +189 -0
- package/core/widget-observer.js +98 -0
- package/higherOrder/BaseApp.js +430 -0
- package/higherOrder/BaseAppProps.js +5 -0
- package/higherOrder/BaseDateTime.js +251 -0
- package/higherOrder/BasePage.js +715 -0
- package/higherOrder/BasePartial.js +124 -0
- package/higherOrder/BasePrefab.js +145 -0
- package/higherOrder/DataNav.js +377 -0
- package/higherOrder/helper.js +43 -0
- package/higherOrder/props.js +5 -0
- package/higherOrder/withBaseWrapper.js +183 -0
- package/hooks/useAccess.js +308 -0
- package/hooks/useAppConfig.js +42 -0
- package/hooks/useAuth.js +562 -0
- package/hooks/useDataSourceSubscription.js +125 -0
- package/hooks/useDebounce.js +76 -0
- package/hooks/useDeviceVisibility.js +49 -0
- package/hooks/useHttp.js +338 -0
- package/libs/index.js +20 -0
- package/mui-config/theme-provider.js +17 -0
- package/mui-config/theme.js +371 -0
- package/package-lock.json +10183 -0
- package/package.json +95 -0
- package/store/index.js +33 -0
- package/store/middleware/navigationMiddleware.js +48 -0
- package/store/slices/appConfigSlice.js +103 -0
- package/store/slices/authSlice.js +508 -0
- package/store/slices/i18nSlice.js +206 -0
- package/types/index.js +15 -0
- package/utils/dataset-util.js +174 -0
- package/utils/eval-expression.js +32 -0
- package/utils/form-state.util.js +140 -0
- package/utils/form-utils.js +187 -0
- package/utils/format-util.js +260 -0
- package/utils/page-params-util.js +24 -0
- package/utils/resource-url.js +27 -0
- package/utils/state-persistance.js +343 -0
- package/utils/style-utils.js +73 -0
- package/utils/transformedDataset-utils.js +633 -0
- package/utils/widget-cleanup-util.js +84 -0
- package/utils/widgets.js +99 -0
- package/variables/base-variable.js +173 -0
- package/variables/constants.js +27 -0
- package/variables/live-variable.js +166 -0
- package/variables/model-variable.js +77 -0
- package/variables/service-variable.js +307 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.refreshDataSource = exports.handleServerOperation = exports.handleDeleteOperation = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
var _uniqueId = _interopRequireDefault(require("lodash-es/uniqueId"));
|
|
14
|
+
var _filter = _interopRequireDefault(require("lodash-es/filter"));
|
|
15
|
+
var _findIndex = _interopRequireDefault(require("lodash-es/findIndex"));
|
|
16
|
+
var _slice = _interopRequireDefault(require("lodash-es/slice"));
|
|
17
|
+
var _forEach = _interopRequireDefault(require("lodash-es/forEach"));
|
|
18
|
+
var _some = _interopRequireDefault(require("lodash-es/some"));
|
|
19
|
+
var _types = require("../../types");
|
|
20
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
+
// ==================== DATASOURCE UTILITIES ====================
|
|
23
|
+
|
|
24
|
+
var getDatasourceInfo = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(datasource) {
|
|
26
|
+
var _datasource$paginatio, _datasource$paginatio2;
|
|
27
|
+
var _yield$Promise$all, _yield$Promise$all2, supportsCrud, isApiAware, currentPageNum, shouldUseServer;
|
|
28
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
29
|
+
while (1) switch (_context.prev = _context.next) {
|
|
30
|
+
case 0:
|
|
31
|
+
_context.next = 2;
|
|
32
|
+
return Promise.all([datasource.execute(_types.DataSource.Operation.SUPPORTS_CRUD), datasource.execute(_types.DataSource.Operation.IS_API_AWARE)]);
|
|
33
|
+
case 2:
|
|
34
|
+
_yield$Promise$all = _context.sent;
|
|
35
|
+
_yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 2);
|
|
36
|
+
supportsCrud = _yield$Promise$all2[0];
|
|
37
|
+
isApiAware = _yield$Promise$all2[1];
|
|
38
|
+
currentPageNum = ((_datasource$paginatio = (_datasource$paginatio2 = datasource.pagination) === null || _datasource$paginatio2 === void 0 ? void 0 : _datasource$paginatio2.number) !== null && _datasource$paginatio !== void 0 ? _datasource$paginatio : 0) + 1;
|
|
39
|
+
shouldUseServer = supportsCrud || !isApiAware || datasource.category === "wm.CrudVariable";
|
|
40
|
+
return _context.abrupt("return", {
|
|
41
|
+
supportsCrud: supportsCrud,
|
|
42
|
+
isApiAware: isApiAware,
|
|
43
|
+
currentPageNum: currentPageNum,
|
|
44
|
+
shouldUseServer: shouldUseServer
|
|
45
|
+
});
|
|
46
|
+
case 9:
|
|
47
|
+
case "end":
|
|
48
|
+
return _context.stop();
|
|
49
|
+
}
|
|
50
|
+
}, _callee);
|
|
51
|
+
}));
|
|
52
|
+
return function getDatasourceInfo(_x) {
|
|
53
|
+
return _ref.apply(this, arguments);
|
|
54
|
+
};
|
|
55
|
+
}();
|
|
56
|
+
|
|
57
|
+
// ==================== OPERATION HANDLERS ====================
|
|
58
|
+
|
|
59
|
+
var handleOperationResult = function handleOperationResult(operation, response, error, options) {
|
|
60
|
+
var showToast = options.showToast,
|
|
61
|
+
onSuccess = options.onSuccess,
|
|
62
|
+
onRowCallback = options.onRowCallback,
|
|
63
|
+
message = options.message,
|
|
64
|
+
onError = options.onError,
|
|
65
|
+
errormessage = options.errormessage;
|
|
66
|
+
if (error) {
|
|
67
|
+
showToast === null || showToast === void 0 || showToast(error || errormessage, "Error");
|
|
68
|
+
onError === null || onError === void 0 || onError(operation, error);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (!onRowCallback && showToast && message) {
|
|
72
|
+
showToast(message, "Success");
|
|
73
|
+
}
|
|
74
|
+
onSuccess === null || onSuccess === void 0 || onSuccess(operation, response);
|
|
75
|
+
onRowCallback === null || onRowCallback === void 0 || onRowCallback(null, response);
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ==================== DATA MANAGEMENT ====================
|
|
80
|
+
|
|
81
|
+
var createCompleteRecord = function createCompleteRecord(editingData, wmTableColumns, serverResponse) {
|
|
82
|
+
var completeRecord = {};
|
|
83
|
+
(0, _forEach["default"])(wmTableColumns, function (column) {
|
|
84
|
+
if (column.field) {
|
|
85
|
+
var _ref2, _editingData$column$f;
|
|
86
|
+
completeRecord[column.field] = (_ref2 = (_editingData$column$f = editingData[column.field]) !== null && _editingData$column$f !== void 0 ? _editingData$column$f : column.defaultvalue) !== null && _ref2 !== void 0 ? _ref2 : "";
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return _objectSpread(_objectSpread(_objectSpread({}, completeRecord), serverResponse), {}, {
|
|
90
|
+
_wmTableRowId: (0, _uniqueId["default"])("new_row_")
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
var hasValidData = function hasValidData(record) {
|
|
94
|
+
return (0, _some["default"])(record, function (value) {
|
|
95
|
+
return value !== undefined && value !== null && value !== "";
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
var updateDataset = function updateDataset(isNewRow, rowId, editingData, wmTableColumns, serverResponse, options) {
|
|
99
|
+
var setInternalDataset = options.setInternalDataset,
|
|
100
|
+
onNewRowAdded = options.onNewRowAdded,
|
|
101
|
+
onRowUpdate = options.onRowUpdate,
|
|
102
|
+
showToast = options.showToast,
|
|
103
|
+
insertmessage = options.insertmessage,
|
|
104
|
+
updatemessage = options.updatemessage;
|
|
105
|
+
if (isNewRow) {
|
|
106
|
+
var completeRecord = createCompleteRecord(editingData, wmTableColumns, serverResponse);
|
|
107
|
+
if (!hasValidData(completeRecord)) return false;
|
|
108
|
+
setInternalDataset(function (prevDataset) {
|
|
109
|
+
var updatedDataset = [].concat((0, _toConsumableArray2["default"])(prevDataset), [completeRecord]);
|
|
110
|
+
onNewRowAdded === null || onNewRowAdded === void 0 || onNewRowAdded(completeRecord);
|
|
111
|
+
if (showToast && insertmessage) showToast(insertmessage, "Success");
|
|
112
|
+
return updatedDataset;
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
setInternalDataset(function (prevDataset) {
|
|
116
|
+
var rowIndex = (0, _findIndex["default"])(prevDataset, function (row) {
|
|
117
|
+
return row._wmTableRowId === rowId;
|
|
118
|
+
});
|
|
119
|
+
var updatedDataset = prevDataset.map(function (row) {
|
|
120
|
+
return row._wmTableRowId === rowId ? _objectSpread(_objectSpread(_objectSpread({}, row), editingData), serverResponse) : row;
|
|
121
|
+
});
|
|
122
|
+
if (onRowUpdate && rowIndex !== -1) {
|
|
123
|
+
setTimeout(function () {
|
|
124
|
+
return onRowUpdate(editingData, rowIndex, updatedDataset);
|
|
125
|
+
}, 0);
|
|
126
|
+
}
|
|
127
|
+
if (showToast && updatemessage) showToast(updatemessage, "Success");
|
|
128
|
+
return updatedDataset;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// ==================== FORM DATA PROCESSING ====================
|
|
135
|
+
|
|
136
|
+
var processFieldValue = function processFieldValue(value, column, isNewRow) {
|
|
137
|
+
var _column$editWidgetTyp, _column$defaultvalue;
|
|
138
|
+
var fields = column.field.split(".");
|
|
139
|
+
if (fields.length === 1 && ((_column$editWidgetTyp = column.editWidgetType) === null || _column$editWidgetTyp === void 0 ? void 0 : _column$editWidgetTyp.toLowerCase()) === "wmupload") return value;
|
|
140
|
+
if (value === "null") value = null;
|
|
141
|
+
|
|
142
|
+
// Validate and transform
|
|
143
|
+
if (value === null || value === undefined) value = (_column$defaultvalue = column.defaultvalue) !== null && _column$defaultvalue !== void 0 ? _column$defaultvalue : "";
|
|
144
|
+
if (column.editWidgetType === "WmCheckbox" || column.editWidgetType === "WmSwitch") return Boolean(value);
|
|
145
|
+
if (column.editWidgetType === "WmNumber" || column.editWidgetType === "WmCurrency") {
|
|
146
|
+
var numValue = Number(value);
|
|
147
|
+
return isNaN(numValue) ? 0 : numValue;
|
|
148
|
+
}
|
|
149
|
+
if (value === null) {
|
|
150
|
+
if (fields.length > 1) return null;
|
|
151
|
+
return isNewRow ? null : "";
|
|
152
|
+
}
|
|
153
|
+
return value;
|
|
154
|
+
};
|
|
155
|
+
var collectFormData = function collectFormData(currentEditingData, wmTableColumns, isNewRow) {
|
|
156
|
+
var formData = {};
|
|
157
|
+
(0, _forEach["default"])(wmTableColumns, function (column) {
|
|
158
|
+
if (!column.field) return;
|
|
159
|
+
var fields = column.field.split(".");
|
|
160
|
+
var processedValue = processFieldValue(currentEditingData[column.field], column, isNewRow);
|
|
161
|
+
if (processedValue === null && fields.length > 1) {
|
|
162
|
+
formData[fields[0]] = null;
|
|
163
|
+
} else if (processedValue !== undefined) {
|
|
164
|
+
formData[column.field] = processedValue;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return formData;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ==================== PAGINATION UTILITIES ====================
|
|
171
|
+
|
|
172
|
+
var adjustPaginationAfterDelete = /*#__PURE__*/function () {
|
|
173
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(tableInstance, internalDataset, datasource, isServerSidePagination) {
|
|
174
|
+
var _tableInstance$getSta, _tableInstance$getSta2, currentPage, pageSize, _datasource$paginatio3, numberOfElements, totalElements, pageItems;
|
|
175
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
176
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
177
|
+
case 0:
|
|
178
|
+
if (tableInstance) {
|
|
179
|
+
_context2.next = 2;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
return _context2.abrupt("return", {
|
|
183
|
+
shouldRefresh: false,
|
|
184
|
+
targetPage: 0
|
|
185
|
+
});
|
|
186
|
+
case 2:
|
|
187
|
+
_tableInstance$getSta = tableInstance.getState(), _tableInstance$getSta2 = _tableInstance$getSta.pagination, currentPage = _tableInstance$getSta2.pageIndex, pageSize = _tableInstance$getSta2.pageSize;
|
|
188
|
+
if (!(isServerSidePagination && datasource !== null && datasource !== void 0 && datasource.pagination)) {
|
|
189
|
+
_context2.next = 12;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
_datasource$paginatio3 = datasource.pagination, numberOfElements = _datasource$paginatio3.numberOfElements, totalElements = _datasource$paginatio3.totalElements;
|
|
193
|
+
if (!(numberOfElements === 1 && currentPage > 0)) {
|
|
194
|
+
_context2.next = 8;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
tableInstance.setPageIndex(currentPage - 1);
|
|
198
|
+
return _context2.abrupt("return", {
|
|
199
|
+
shouldRefresh: true,
|
|
200
|
+
targetPage: currentPage
|
|
201
|
+
});
|
|
202
|
+
case 8:
|
|
203
|
+
if (!(totalElements === 1)) {
|
|
204
|
+
_context2.next = 11;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
tableInstance.setPageIndex(0);
|
|
208
|
+
return _context2.abrupt("return", {
|
|
209
|
+
shouldRefresh: true,
|
|
210
|
+
targetPage: 1
|
|
211
|
+
});
|
|
212
|
+
case 11:
|
|
213
|
+
return _context2.abrupt("return", {
|
|
214
|
+
shouldRefresh: true,
|
|
215
|
+
targetPage: currentPage + 1
|
|
216
|
+
});
|
|
217
|
+
case 12:
|
|
218
|
+
// Client-side pagination
|
|
219
|
+
pageItems = (0, _slice["default"])(internalDataset, currentPage * pageSize, (currentPage + 1) * pageSize);
|
|
220
|
+
if (pageItems.length === 1 && currentPage > 0) {
|
|
221
|
+
tableInstance.setPageIndex(currentPage - 1);
|
|
222
|
+
}
|
|
223
|
+
return _context2.abrupt("return", {
|
|
224
|
+
shouldRefresh: false,
|
|
225
|
+
targetPage: currentPage
|
|
226
|
+
});
|
|
227
|
+
case 15:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context2.stop();
|
|
230
|
+
}
|
|
231
|
+
}, _callee2);
|
|
232
|
+
}));
|
|
233
|
+
return function adjustPaginationAfterDelete(_x2, _x3, _x4, _x5) {
|
|
234
|
+
return _ref3.apply(this, arguments);
|
|
235
|
+
};
|
|
236
|
+
}();
|
|
237
|
+
|
|
238
|
+
// ==================== NON-API AWARE OPERATIONS ====================
|
|
239
|
+
|
|
240
|
+
var handleNonApiAwareOperation = /*#__PURE__*/function () {
|
|
241
|
+
var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(datasource, binddataset, formData, operation) {
|
|
242
|
+
var path, parentIndex, parentPath;
|
|
243
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
244
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
245
|
+
case 0:
|
|
246
|
+
path = binddataset.split(".");
|
|
247
|
+
parentIndex = parseInt(path[path.length - 1]);
|
|
248
|
+
parentPath = path.slice(0, -1).join(".");
|
|
249
|
+
return _context3.abrupt("return", datasource.execute(_types.DataSource.Operation[operation], {
|
|
250
|
+
item: formData,
|
|
251
|
+
path: parentPath,
|
|
252
|
+
parentIndex: parentIndex
|
|
253
|
+
}));
|
|
254
|
+
case 4:
|
|
255
|
+
case "end":
|
|
256
|
+
return _context3.stop();
|
|
257
|
+
}
|
|
258
|
+
}, _callee3);
|
|
259
|
+
}));
|
|
260
|
+
return function handleNonApiAwareOperation(_x6, _x7, _x8, _x9) {
|
|
261
|
+
return _ref4.apply(this, arguments);
|
|
262
|
+
};
|
|
263
|
+
}();
|
|
264
|
+
|
|
265
|
+
// ==================== EXPORTED FUNCTIONS ====================
|
|
266
|
+
|
|
267
|
+
var refreshDataSource = exports.refreshDataSource = /*#__PURE__*/function () {
|
|
268
|
+
var _ref5 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(datasource, options) {
|
|
269
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
270
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
271
|
+
case 0:
|
|
272
|
+
if (datasource) {
|
|
273
|
+
_context4.next = 2;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
throw new Error("Datasource is required");
|
|
277
|
+
case 2:
|
|
278
|
+
return _context4.abrupt("return", datasource.execute(_types.DataSource.Operation.LIST_RECORDS, {
|
|
279
|
+
filterFields: options.filterFields || {},
|
|
280
|
+
orderBy: options.orderBy,
|
|
281
|
+
page: options.page || 1,
|
|
282
|
+
logicalOp: options.condition || ""
|
|
283
|
+
}));
|
|
284
|
+
case 3:
|
|
285
|
+
case "end":
|
|
286
|
+
return _context4.stop();
|
|
287
|
+
}
|
|
288
|
+
}, _callee4);
|
|
289
|
+
}));
|
|
290
|
+
return function refreshDataSource(_x0, _x1) {
|
|
291
|
+
return _ref5.apply(this, arguments);
|
|
292
|
+
};
|
|
293
|
+
}();
|
|
294
|
+
var handleServerOperation = exports.handleServerOperation = /*#__PURE__*/function () {
|
|
295
|
+
var _ref6 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(options) {
|
|
296
|
+
var datasource, binddataset, isNewRow, rowId, currentEditingData, wmTableColumns, setInternalDataset, onNewRowAdded, onRowUpdate, showToast, insertmessage, updatemessage, onRowinsert, onRowupdate, onSuccess, onError, errormessage, tableInstance, isServerSidePagination, formData, response, _yield$getDatasourceI, isApiAware, currentPageNum, shouldUseServer, _datasource$paginatio4, totalElements, _datasource$paginatio5, size, lastPage, _datasource$paginatio6;
|
|
297
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
298
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
299
|
+
case 0:
|
|
300
|
+
datasource = options.datasource, binddataset = options.binddataset, isNewRow = options.isNewRow, rowId = options.rowId, currentEditingData = options.currentEditingData, wmTableColumns = options.wmTableColumns, setInternalDataset = options.setInternalDataset, onNewRowAdded = options.onNewRowAdded, onRowUpdate = options.onRowUpdate, showToast = options.showToast, insertmessage = options.insertmessage, updatemessage = options.updatemessage, onRowinsert = options.onRowinsert, onRowupdate = options.onRowupdate, onSuccess = options.onSuccess, onError = options.onError, errormessage = options.errormessage, tableInstance = options.tableInstance, isServerSidePagination = options.isServerSidePagination;
|
|
301
|
+
_context5.prev = 1;
|
|
302
|
+
formData = collectFormData(currentEditingData, wmTableColumns, isNewRow);
|
|
303
|
+
response = currentEditingData;
|
|
304
|
+
if (!datasource) {
|
|
305
|
+
_context5.next = 37;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
_context5.next = 7;
|
|
309
|
+
return getDatasourceInfo(datasource);
|
|
310
|
+
case 7:
|
|
311
|
+
_yield$getDatasourceI = _context5.sent;
|
|
312
|
+
isApiAware = _yield$getDatasourceI.isApiAware;
|
|
313
|
+
currentPageNum = _yield$getDatasourceI.currentPageNum;
|
|
314
|
+
shouldUseServer = _yield$getDatasourceI.shouldUseServer;
|
|
315
|
+
if (!shouldUseServer) {
|
|
316
|
+
_context5.next = 37;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
if (!(!isApiAware && binddataset)) {
|
|
320
|
+
_context5.next = 17;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
_context5.next = 15;
|
|
324
|
+
return handleNonApiAwareOperation(datasource, binddataset, formData, isNewRow ? "ADD_ITEM" : "SET_ITEM");
|
|
325
|
+
case 15:
|
|
326
|
+
_context5.next = 37;
|
|
327
|
+
break;
|
|
328
|
+
case 17:
|
|
329
|
+
_context5.next = 19;
|
|
330
|
+
return datasource.execute(isNewRow ? _types.DataSource.Operation.INSERT_RECORD : _types.DataSource.Operation.UPDATE_RECORD, {
|
|
331
|
+
row: formData,
|
|
332
|
+
skipNotification: true
|
|
333
|
+
});
|
|
334
|
+
case 19:
|
|
335
|
+
response = _context5.sent;
|
|
336
|
+
if (!response.error) {
|
|
337
|
+
_context5.next = 22;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
throw response.error;
|
|
341
|
+
case 22:
|
|
342
|
+
if (!(isNewRow && isServerSidePagination && datasource.pagination)) {
|
|
343
|
+
_context5.next = 34;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
_datasource$paginatio4 = datasource.pagination, totalElements = _datasource$paginatio4.totalElements, _datasource$paginatio5 = _datasource$paginatio4.size, size = _datasource$paginatio5 === void 0 ? 10 : _datasource$paginatio5;
|
|
347
|
+
if (!(totalElements !== undefined && size > 0)) {
|
|
348
|
+
_context5.next = 32;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
lastPage = Math.ceil((totalElements + 1) / size);
|
|
352
|
+
if (!(tableInstance && lastPage > currentPageNum)) {
|
|
353
|
+
_context5.next = 30;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
tableInstance.setPageIndex(lastPage - 1);
|
|
357
|
+
_context5.next = 32;
|
|
358
|
+
break;
|
|
359
|
+
case 30:
|
|
360
|
+
_context5.next = 32;
|
|
361
|
+
return refreshDataSource(datasource, {
|
|
362
|
+
page: currentPageNum,
|
|
363
|
+
pagesize: size
|
|
364
|
+
});
|
|
365
|
+
case 32:
|
|
366
|
+
_context5.next = 37;
|
|
367
|
+
break;
|
|
368
|
+
case 34:
|
|
369
|
+
if (!isServerSidePagination) {
|
|
370
|
+
_context5.next = 37;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
_context5.next = 37;
|
|
374
|
+
return refreshDataSource(datasource, {
|
|
375
|
+
page: currentPageNum,
|
|
376
|
+
pagesize: ((_datasource$paginatio6 = datasource.pagination) === null || _datasource$paginatio6 === void 0 ? void 0 : _datasource$paginatio6.size) || 10
|
|
377
|
+
});
|
|
378
|
+
case 37:
|
|
379
|
+
updateDataset(isNewRow, rowId, currentEditingData, wmTableColumns, response, {
|
|
380
|
+
setInternalDataset: setInternalDataset,
|
|
381
|
+
onNewRowAdded: onNewRowAdded,
|
|
382
|
+
onRowUpdate: onRowUpdate,
|
|
383
|
+
showToast: showToast,
|
|
384
|
+
insertmessage: insertmessage,
|
|
385
|
+
updatemessage: updatemessage
|
|
386
|
+
});
|
|
387
|
+
return _context5.abrupt("return", handleOperationResult(isNewRow ? "insert" : "update", response, null, {
|
|
388
|
+
showToast: showToast,
|
|
389
|
+
onSuccess: onSuccess,
|
|
390
|
+
onRowCallback: isNewRow ? onRowinsert : onRowupdate,
|
|
391
|
+
message: isNewRow ? insertmessage : updatemessage,
|
|
392
|
+
onError: onError
|
|
393
|
+
}));
|
|
394
|
+
case 41:
|
|
395
|
+
_context5.prev = 41;
|
|
396
|
+
_context5.t0 = _context5["catch"](1);
|
|
397
|
+
return _context5.abrupt("return", handleOperationResult(isNewRow ? "insert" : "update", null, _context5.t0, {
|
|
398
|
+
showToast: showToast,
|
|
399
|
+
onError: onError,
|
|
400
|
+
errormessage: errormessage
|
|
401
|
+
}));
|
|
402
|
+
case 44:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context5.stop();
|
|
405
|
+
}
|
|
406
|
+
}, _callee5, null, [[1, 41]]);
|
|
407
|
+
}));
|
|
408
|
+
return function handleServerOperation(_x10) {
|
|
409
|
+
return _ref6.apply(this, arguments);
|
|
410
|
+
};
|
|
411
|
+
}();
|
|
412
|
+
var handleDeleteOperation = exports.handleDeleteOperation = /*#__PURE__*/function () {
|
|
413
|
+
var _ref7 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(options) {
|
|
414
|
+
var rowData, tableInstance, internalDataset, setInternalDataset, datasource, binddataset, onRowDelete, showToast, deletemessage, onSuccess, onRowdelete, onError, errormessage, isServerSidePagination, rowIndex, response, _yield$getDatasourceI2, isApiAware, currentPageNum, shouldUseServer, newDataset, paginationResult, _datasource$paginatio7;
|
|
415
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
416
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
rowData = options.rowData, tableInstance = options.tableInstance, internalDataset = options.internalDataset, setInternalDataset = options.setInternalDataset, datasource = options.datasource, binddataset = options.binddataset, onRowDelete = options.onRowDelete, showToast = options.showToast, deletemessage = options.deletemessage, onSuccess = options.onSuccess, onRowdelete = options.onRowdelete, onError = options.onError, errormessage = options.errormessage, isServerSidePagination = options.isServerSidePagination;
|
|
419
|
+
_context6.prev = 1;
|
|
420
|
+
// Find row first
|
|
421
|
+
rowIndex = (0, _findIndex["default"])(internalDataset, function (row) {
|
|
422
|
+
return row._wmTableRowId === rowData._wmTableRowId || row.id !== undefined && row.id === rowData.id;
|
|
423
|
+
});
|
|
424
|
+
if (!(rowIndex === -1)) {
|
|
425
|
+
_context6.next = 6;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
console.warn("Row not found for deletion");
|
|
429
|
+
return _context6.abrupt("return", false);
|
|
430
|
+
case 6:
|
|
431
|
+
response = rowData; // Handle server operations first, before updating local dataset
|
|
432
|
+
if (!datasource) {
|
|
433
|
+
_context6.next = 25;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
_context6.next = 10;
|
|
437
|
+
return getDatasourceInfo(datasource);
|
|
438
|
+
case 10:
|
|
439
|
+
_yield$getDatasourceI2 = _context6.sent;
|
|
440
|
+
isApiAware = _yield$getDatasourceI2.isApiAware;
|
|
441
|
+
currentPageNum = _yield$getDatasourceI2.currentPageNum;
|
|
442
|
+
shouldUseServer = _yield$getDatasourceI2.shouldUseServer;
|
|
443
|
+
if (!shouldUseServer) {
|
|
444
|
+
_context6.next = 25;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
if (!(!isApiAware && binddataset)) {
|
|
448
|
+
_context6.next = 20;
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
_context6.next = 18;
|
|
452
|
+
return handleNonApiAwareOperation(datasource, binddataset, rowData, "REMOVE_ITEM");
|
|
453
|
+
case 18:
|
|
454
|
+
_context6.next = 25;
|
|
455
|
+
break;
|
|
456
|
+
case 20:
|
|
457
|
+
_context6.next = 22;
|
|
458
|
+
return datasource.execute(_types.DataSource.Operation.DELETE_RECORD, {
|
|
459
|
+
row: rowData,
|
|
460
|
+
skipNotification: true
|
|
461
|
+
});
|
|
462
|
+
case 22:
|
|
463
|
+
response = _context6.sent;
|
|
464
|
+
if (!response.error) {
|
|
465
|
+
_context6.next = 25;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
throw response.error;
|
|
469
|
+
case 25:
|
|
470
|
+
// Only update dataset after successful server operation
|
|
471
|
+
newDataset = (0, _filter["default"])(internalDataset, function (row) {
|
|
472
|
+
return row._wmTableRowId !== rowData._wmTableRowId && (row.id === undefined || row.id !== rowData.id);
|
|
473
|
+
});
|
|
474
|
+
setInternalDataset(function () {
|
|
475
|
+
return newDataset;
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Handle pagination
|
|
479
|
+
_context6.next = 29;
|
|
480
|
+
return adjustPaginationAfterDelete(tableInstance, internalDataset, datasource, isServerSidePagination || false);
|
|
481
|
+
case 29:
|
|
482
|
+
paginationResult = _context6.sent;
|
|
483
|
+
if (!(isServerSidePagination && paginationResult.shouldRefresh && datasource)) {
|
|
484
|
+
_context6.next = 33;
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
_context6.next = 33;
|
|
488
|
+
return datasource.invoke({
|
|
489
|
+
page: paginationResult.targetPage,
|
|
490
|
+
pagesize: ((_datasource$paginatio7 = datasource.pagination) === null || _datasource$paginatio7 === void 0 ? void 0 : _datasource$paginatio7.size) || 10
|
|
491
|
+
});
|
|
492
|
+
case 33:
|
|
493
|
+
onRowDelete === null || onRowDelete === void 0 || onRowDelete(rowData, rowIndex, newDataset);
|
|
494
|
+
return _context6.abrupt("return", handleOperationResult("delete", response, null, {
|
|
495
|
+
showToast: showToast,
|
|
496
|
+
onSuccess: onSuccess,
|
|
497
|
+
onRowCallback: onRowdelete,
|
|
498
|
+
message: deletemessage,
|
|
499
|
+
onError: onError
|
|
500
|
+
}));
|
|
501
|
+
case 37:
|
|
502
|
+
_context6.prev = 37;
|
|
503
|
+
_context6.t0 = _context6["catch"](1);
|
|
504
|
+
return _context6.abrupt("return", handleOperationResult("delete", null, _context6.t0, {
|
|
505
|
+
showToast: showToast,
|
|
506
|
+
onError: onError,
|
|
507
|
+
errormessage: errormessage
|
|
508
|
+
}));
|
|
509
|
+
case 40:
|
|
510
|
+
case "end":
|
|
511
|
+
return _context6.stop();
|
|
512
|
+
}
|
|
513
|
+
}, _callee6, null, [[1, 37]]);
|
|
514
|
+
}));
|
|
515
|
+
return function handleDeleteOperation(_x11) {
|
|
516
|
+
return _ref7.apply(this, arguments);
|
|
517
|
+
};
|
|
518
|
+
}();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isValidDataForColumns = exports.isInternalField = exports.generateColumnsFromData = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _lodashEs = require("lodash-es");
|
|
10
|
+
var _columnBuilder = require("./columnBuilder");
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
var _index = require("./index");
|
|
13
|
+
/**
|
|
14
|
+
* List of internal WaveMaker field prefixes that should be excluded
|
|
15
|
+
* from dynamic column generation
|
|
16
|
+
*/
|
|
17
|
+
var INTERNAL_FIELD_PATTERNS = ["_wm",
|
|
18
|
+
// All fields starting with _wm (like _wmTableRowId, _wmListItemId, etc.)
|
|
19
|
+
"__" // Double underscore fields (system fields)
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if a field should be excluded from dynamic column generation
|
|
24
|
+
* Combines existing INTERNAL_PROPERTIES with pattern-based detection
|
|
25
|
+
* @param fieldName - The field name to check
|
|
26
|
+
* @returns true if the field should be excluded
|
|
27
|
+
*/
|
|
28
|
+
var isInternalField = exports.isInternalField = function isInternalField(fieldName) {
|
|
29
|
+
// Check exact matches from INTERNAL_PROPERTIES
|
|
30
|
+
if (_index.INTERNAL_PROPERTIES.includes(fieldName)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check pattern-based exclusions
|
|
35
|
+
return INTERNAL_FIELD_PATTERNS.some(function (pattern) {
|
|
36
|
+
return fieldName.startsWith(pattern);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Infer column type from data value
|
|
42
|
+
*/
|
|
43
|
+
var inferColumnType = function inferColumnType(value) {
|
|
44
|
+
if (value === null || value === undefined) {
|
|
45
|
+
return "string";
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === "number") {
|
|
48
|
+
return "number";
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === "boolean") {
|
|
51
|
+
return "boolean";
|
|
52
|
+
}
|
|
53
|
+
if (value instanceof Date) {
|
|
54
|
+
return "date";
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "string") {
|
|
57
|
+
// Check if it looks like a date
|
|
58
|
+
if (!isNaN(Date.parse(value)) && value.match(/^\d{4}-\d{2}-\d{2}/)) {
|
|
59
|
+
return "date";
|
|
60
|
+
}
|
|
61
|
+
// Check if it looks like a number
|
|
62
|
+
if (!isNaN(Number(value)) && value.trim() !== "") {
|
|
63
|
+
return "number";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return "string";
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Generate column definitions from data array
|
|
71
|
+
* Similar to Angular's prepareFieldDefs function
|
|
72
|
+
*/
|
|
73
|
+
var generateColumnsFromData = exports.generateColumnsFromData = function generateColumnsFromData(data) {
|
|
74
|
+
if (!data || data.length === 0) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Get all unique keys from the first few rows to handle sparse data
|
|
79
|
+
var allKeys = new Set();
|
|
80
|
+
var sampleSize = Math.min(_constants.DYNAMIC_COLUMNS_CONFIG.sampleSize, data.length);
|
|
81
|
+
for (var i = 0; i < sampleSize; i++) {
|
|
82
|
+
if (data[i] && (0, _typeof2["default"])(data[i]) === "object") {
|
|
83
|
+
Object.keys(data[i]).forEach(function (key) {
|
|
84
|
+
// Only add non-internal fields
|
|
85
|
+
if (!isInternalField(key)) {
|
|
86
|
+
allKeys.add(key);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
var keys = Array.from(allKeys).slice(0, _constants.DYNAMIC_COLUMNS_CONFIG.maxColumns);
|
|
92
|
+
if (keys.length === 0) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Generate column definitions using existing utility functions
|
|
97
|
+
var columns = keys.map(function (key, index) {
|
|
98
|
+
var _data$find;
|
|
99
|
+
var firstNonNullValue = (_data$find = data.find(function (row) {
|
|
100
|
+
return row && row[key] !== null && row[key] !== undefined;
|
|
101
|
+
})) === null || _data$find === void 0 ? void 0 : _data$find[key];
|
|
102
|
+
var inferredType = inferColumnType(firstNonNullValue);
|
|
103
|
+
var displayName = (0, _lodashEs.startCase)(key); // Convert snake_case/kebab-case to Title Case
|
|
104
|
+
|
|
105
|
+
// Create column using the existing utility function
|
|
106
|
+
return (0, _columnBuilder.createDefaultColumnProps)(key, displayName, inferredType, index);
|
|
107
|
+
});
|
|
108
|
+
return columns;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check if data is valid for column generation
|
|
113
|
+
*/
|
|
114
|
+
var isValidDataForColumns = exports.isValidDataForColumns = function isValidDataForColumns(data) {
|
|
115
|
+
return Array.isArray(data) && data.length > 0 && data.some(function (row) {
|
|
116
|
+
return row && (0, _typeof2["default"])(row) === "object" && Object.keys(row).length > 0;
|
|
117
|
+
});
|
|
118
|
+
};
|