@kaspernj/api-maker 1.0.2054 → 1.0.2055
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/build/api.js +64 -212
- package/build/api.js.map +1 -1
- package/build/attribute-not-loaded-error.js +2 -25
- package/build/attribute-not-loaded-error.js.map +1 -1
- package/build/base-component.js +3 -26
- package/build/base-component.js.map +1 -1
- package/build/base-error.js +20 -45
- package/build/base-error.js.map +1 -1
- package/build/base-model/attribute.js +14 -21
- package/build/base-model/attribute.js.map +1 -1
- package/build/base-model/column.js +4 -8
- package/build/base-model/column.js.map +1 -1
- package/build/base-model/reflection.js +11 -51
- package/build/base-model/reflection.js.map +1 -1
- package/build/base-model/scope.js +8 -45
- package/build/base-model/scope.js.map +1 -1
- package/build/base-model.js +583 -836
- package/build/base-model.js.map +1 -1
- package/build/bootstrap/attribute-row.js +87 -172
- package/build/bootstrap/attribute-row.js.map +1 -1
- package/build/bootstrap/attribute-rows.js +21 -50
- package/build/bootstrap/attribute-rows.js.map +1 -1
- package/build/bootstrap/card.js +76 -159
- package/build/bootstrap/card.js.map +1 -1
- package/build/bootstrap/checkbox.js +53 -102
- package/build/bootstrap/checkbox.js.map +1 -1
- package/build/bootstrap/checkboxes.js +116 -202
- package/build/bootstrap/checkboxes.js.map +1 -1
- package/build/bootstrap/input.js +80 -131
- package/build/bootstrap/input.js.map +1 -1
- package/build/bootstrap/invalid-feedback.js +18 -46
- package/build/bootstrap/invalid-feedback.js.map +1 -1
- package/build/bootstrap/paginate.js +99 -164
- package/build/bootstrap/paginate.js.map +1 -1
- package/build/bootstrap/radio-buttons.js +43 -80
- package/build/bootstrap/radio-buttons.js.map +1 -1
- package/build/bootstrap/select.js +43 -90
- package/build/bootstrap/select.js.map +1 -1
- package/build/bootstrap/sort-link.js +68 -151
- package/build/bootstrap/sort-link.js.map +1 -1
- package/build/cable-connection-pool.js +43 -65
- package/build/cable-connection-pool.js.map +1 -1
- package/build/cable-subscription-pool.js +104 -161
- package/build/cable-subscription-pool.js.map +1 -1
- package/build/cable-subscription.js +9 -16
- package/build/cable-subscription.js.map +1 -1
- package/build/cache-key-generator.js +27 -36
- package/build/cache-key-generator.js.map +1 -1
- package/build/can-can.js +80 -201
- package/build/can-can.js.map +1 -1
- package/build/channels-consumer.js +5 -10
- package/build/channels-consumer.js.map +1 -1
- package/build/collection-loader.js +35 -53
- package/build/collection-loader.js.map +1 -1
- package/build/collection.js +160 -307
- package/build/collection.js.map +1 -1
- package/build/command-submit-data.d.ts +1 -1
- package/build/command-submit-data.d.ts.map +1 -1
- package/build/command-submit-data.js +29 -38
- package/build/command-submit-data.js.map +1 -1
- package/build/commands-pool.js +139 -215
- package/build/commands-pool.js.map +1 -1
- package/build/compose.js +3 -11
- package/build/compose.js.map +1 -1
- package/build/config.js +20 -67
- package/build/config.js.map +1 -1
- package/build/custom-error.js +4 -29
- package/build/custom-error.js.map +1 -1
- package/build/data-set-to-attributes.js +5 -41
- package/build/data-set-to-attributes.js.map +1 -1
- package/build/deserializer.js +26 -79
- package/build/deserializer.js.map +1 -1
- package/build/destroy-error.js +4 -29
- package/build/destroy-error.js.map +1 -1
- package/build/devise.js +83 -187
- package/build/devise.js.map +1 -1
- package/build/draggable-sort/controller.js +87 -110
- package/build/draggable-sort/controller.js.map +1 -1
- package/build/draggable-sort/index.js +67 -144
- package/build/draggable-sort/index.js.map +1 -1
- package/build/draggable-sort/item.js +131 -197
- package/build/draggable-sort/item.js.map +1 -1
- package/build/error-logger.js +78 -163
- package/build/error-logger.js.map +1 -1
- package/build/error-messages.js +4 -7
- package/build/error-messages.js.map +1 -1
- package/build/event-connection.js +23 -61
- package/build/event-connection.js.map +1 -1
- package/build/event-emitter-listener.js +6 -23
- package/build/event-emitter-listener.js.map +1 -1
- package/build/event-model-class.js +19 -46
- package/build/event-model-class.js.map +1 -1
- package/build/events.js +3 -8
- package/build/events.js.map +1 -1
- package/build/form.js +65 -153
- package/build/form.js.map +1 -1
- package/build/history-expo.js +12 -24
- package/build/history-expo.js.map +1 -1
- package/build/history-react-native.js +14 -26
- package/build/history-react-native.js.map +1 -1
- package/build/history.js +2 -4
- package/build/history.js.map +1 -1
- package/build/index.js +2 -5
- package/build/index.js.map +1 -1
- package/build/inputs/attachment.js +71 -122
- package/build/inputs/attachment.js.map +1 -1
- package/build/inputs/auto-submit.js +15 -54
- package/build/inputs/auto-submit.js.map +1 -1
- package/build/inputs/checkbox.js +77 -166
- package/build/inputs/checkbox.js.map +1 -1
- package/build/inputs/checkboxes.js +75 -158
- package/build/inputs/checkboxes.js.map +1 -1
- package/build/inputs/id-for-component.js +4 -40
- package/build/inputs/id-for-component.js.map +1 -1
- package/build/inputs/input-wrapper.js +7 -26
- package/build/inputs/input-wrapper.js.map +1 -1
- package/build/inputs/input.js +158 -244
- package/build/inputs/input.js.map +1 -1
- package/build/inputs/money.js +123 -185
- package/build/inputs/money.js.map +1 -1
- package/build/inputs/name-for-component.js +4 -40
- package/build/inputs/name-for-component.js.map +1 -1
- package/build/inputs/select.js +68 -122
- package/build/inputs/select.js.map +1 -1
- package/build/instance-of-class-name.js +15 -20
- package/build/instance-of-class-name.js.map +1 -1
- package/build/is-expo.js +8 -10
- package/build/is-expo.js.map +1 -1
- package/build/key-value-store.js +51 -127
- package/build/key-value-store.js.map +1 -1
- package/build/link.js +51 -114
- package/build/link.js.map +1 -1
- package/build/logger.js +19 -25
- package/build/logger.js.map +1 -1
- package/build/merge-styles.js +5 -9
- package/build/merge-styles.js.map +1 -1
- package/build/modal.js +14 -61
- package/build/modal.js.map +1 -1
- package/build/model-class-require.js +8 -43
- package/build/model-class-require.js.map +1 -1
- package/build/model-events.js +24 -33
- package/build/model-events.js.map +1 -1
- package/build/model-name.js +15 -56
- package/build/model-name.js.map +1 -1
- package/build/model-prop-type.js +51 -62
- package/build/model-prop-type.js.map +1 -1
- package/build/model-recipes-loader.js +16 -24
- package/build/model-recipes-loader.js.map +1 -1
- package/build/model-recipes-model-loader.d.ts +1 -1
- package/build/model-recipes-model-loader.js +129 -207
- package/build/model-recipes-model-loader.js.map +1 -1
- package/build/models-response-reader.js +24 -65
- package/build/models-response-reader.js.map +1 -1
- package/build/models.js +5 -10
- package/build/models.js.map +1 -1
- package/build/money-formatter.d.ts +2 -2
- package/build/money-formatter.d.ts.map +1 -1
- package/build/money-formatter.js +45 -55
- package/build/money-formatter.js.map +1 -1
- package/build/not-loaded-error.js +2 -25
- package/build/not-loaded-error.js.map +1 -1
- package/build/params.js +31 -41
- package/build/params.js.map +1 -1
- package/build/preloaded.js +18 -58
- package/build/preloaded.js.map +1 -1
- package/build/resize-observer.js +5 -11
- package/build/resize-observer.js.map +1 -1
- package/build/rest-props-validator.js +4 -6
- package/build/rest-props-validator.js.map +1 -1
- package/build/result.js +10 -14
- package/build/result.js.map +1 -1
- package/build/router/route.js +178 -311
- package/build/router/route.js.map +1 -1
- package/build/router/switch.js +55 -129
- package/build/router/switch.js.map +1 -1
- package/build/router.js +33 -93
- package/build/router.js.map +1 -1
- package/build/routes-native.js +63 -147
- package/build/routes-native.js.map +1 -1
- package/build/routes.js +25 -79
- package/build/routes.js.map +1 -1
- package/build/run-last.js +19 -24
- package/build/run-last.js.map +1 -1
- package/build/serializer.js +28 -33
- package/build/serializer.js.map +1 -1
- package/build/services.js +9 -18
- package/build/services.js.map +1 -1
- package/build/session-status-updater.js +84 -183
- package/build/session-status-updater.js.map +1 -1
- package/build/source-maps-loader.d.ts +37 -0
- package/build/source-maps-loader.d.ts.map +1 -0
- package/build/source-maps-loader.js +102 -224
- package/build/source-maps-loader.js.map +1 -1
- package/build/super-admin/config-reader.d.ts +2 -2
- package/build/super-admin/config-reader.js +41 -82
- package/build/super-admin/config-reader.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-checkbox.js +52 -114
- package/build/super-admin/edit-page/edit-attribute-checkbox.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-content.js +46 -76
- package/build/super-admin/edit-page/edit-attribute-content.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute-input.js +56 -118
- package/build/super-admin/edit-page/edit-attribute-input.js.map +1 -1
- package/build/super-admin/edit-page/edit-attribute.js +39 -103
- package/build/super-admin/edit-page/edit-attribute.js.map +1 -1
- package/build/super-admin/edit-page.js +87 -200
- package/build/super-admin/edit-page.js.map +1 -1
- package/build/super-admin/has-edit-config.js +6 -12
- package/build/super-admin/has-edit-config.js.map +1 -1
- package/build/super-admin/index-page.js +16 -43
- package/build/super-admin/index-page.js.map +1 -1
- package/build/super-admin/index.js +86 -209
- package/build/super-admin/index.js.map +1 -1
- package/build/super-admin/layout/header/index.js +90 -151
- package/build/super-admin/layout/header/index.js.map +1 -1
- package/build/super-admin/layout/index.js +69 -152
- package/build/super-admin/layout/index.js.map +1 -1
- package/build/super-admin/layout/menu/index.js +84 -160
- package/build/super-admin/layout/menu/index.js.map +1 -1
- package/build/super-admin/layout/menu/menu-content.js +24 -84
- package/build/super-admin/layout/menu/menu-content.js.map +1 -1
- package/build/super-admin/layout/menu/menu-item.js +51 -101
- package/build/super-admin/layout/menu/menu-item.js.map +1 -1
- package/build/super-admin/layout/no-access.js +18 -44
- package/build/super-admin/layout/no-access.js.map +1 -1
- package/build/super-admin/model-class-table.js +44 -128
- package/build/super-admin/model-class-table.js.map +1 -1
- package/build/super-admin/models.js +5 -41
- package/build/super-admin/models.js.map +1 -1
- package/build/super-admin/show-nav.js +26 -88
- package/build/super-admin/show-nav.js.map +1 -1
- package/build/super-admin/show-page/belongs-to-attribute-row.js +17 -75
- package/build/super-admin/show-page/belongs-to-attribute-row.js.map +1 -1
- package/build/super-admin/show-page/index.js +100 -186
- package/build/super-admin/show-page/index.js.map +1 -1
- package/build/super-admin/show-reflection-actions.js +38 -99
- package/build/super-admin/show-reflection-actions.js.map +1 -1
- package/build/super-admin/show-reflection-link.js +26 -98
- package/build/super-admin/show-reflection-link.js.map +1 -1
- package/build/super-admin/show-reflection-page.js +33 -96
- package/build/super-admin/show-reflection-page.js.map +1 -1
- package/build/table/column-content.js +76 -120
- package/build/table/column-content.js.map +1 -1
- package/build/table/column-identifier.js +6 -10
- package/build/table/column-identifier.js.map +1 -1
- package/build/table/column-visible.js +1 -4
- package/build/table/column-visible.js.map +1 -1
- package/build/table/components/column.js +12 -59
- package/build/table/components/column.js.map +1 -1
- package/build/table/components/flat-list.js +12 -59
- package/build/table/components/flat-list.js.map +1 -1
- package/build/table/components/header.js +14 -61
- package/build/table/components/header.js.map +1 -1
- package/build/table/components/row.js +15 -62
- package/build/table/components/row.js.map +1 -1
- package/build/table/filters/attribute-element.js +33 -61
- package/build/table/filters/attribute-element.js.map +1 -1
- package/build/table/filters/filter-form.js +279 -482
- package/build/table/filters/filter-form.js.map +1 -1
- package/build/table/filters/filter.js +44 -72
- package/build/table/filters/filter.js.map +1 -1
- package/build/table/filters/index.js +94 -138
- package/build/table/filters/index.js.map +1 -1
- package/build/table/filters/load-search-modal.js +63 -211
- package/build/table/filters/load-search-modal.js.map +1 -1
- package/build/table/filters/reflection-element.js +26 -54
- package/build/table/filters/reflection-element.js.map +1 -1
- package/build/table/filters/save-search-modal.js +43 -139
- package/build/table/filters/save-search-modal.js.map +1 -1
- package/build/table/filters/scope-element.js +27 -55
- package/build/table/filters/scope-element.js.map +1 -1
- package/build/table/header-column-content.js +32 -70
- package/build/table/header-column-content.js.map +1 -1
- package/build/table/header-column.js +88 -217
- package/build/table/header-column.js.map +1 -1
- package/build/table/header-select.js +44 -76
- package/build/table/header-select.js.map +1 -1
- package/build/table/model-callback-args.js +4 -40
- package/build/table/model-callback-args.js.map +1 -1
- package/build/table/model-column.js +58 -143
- package/build/table/model-column.js.map +1 -1
- package/build/table/model-row.js +74 -186
- package/build/table/model-row.js.map +1 -1
- package/build/table/select-calculator.js +26 -85
- package/build/table/select-calculator.js.map +1 -1
- package/build/table/settings/column-row.js +65 -185
- package/build/table/settings/column-row.js.map +1 -1
- package/build/table/settings/download-action.js +37 -73
- package/build/table/settings/download-action.js.map +1 -1
- package/build/table/settings/index.js +37 -101
- package/build/table/settings/index.js.map +1 -1
- package/build/table/table-settings.js +184 -322
- package/build/table/table-settings.js.map +1 -1
- package/build/table/table.js +582 -780
- package/build/table/table.js.map +1 -1
- package/build/table/use-sorting.js +15 -34
- package/build/table/use-sorting.js.map +1 -1
- package/build/table/widths.js +31 -37
- package/build/table/widths.js.map +1 -1
- package/build/table/worker-plugins-check-all-checkbox.js +76 -224
- package/build/table/worker-plugins-check-all-checkbox.js.map +1 -1
- package/build/table/worker-plugins-checkbox.js +73 -184
- package/build/table/worker-plugins-checkbox.js.map +1 -1
- package/build/translated-attributes.js +5 -10
- package/build/translated-attributes.js.map +1 -1
- package/build/translated-collections.js +10 -19
- package/build/translated-collections.js.map +1 -1
- package/build/updated-attribute.js +46 -119
- package/build/updated-attribute.js.map +1 -1
- package/build/url-encode.js +5 -11
- package/build/url-encode.js.map +1 -1
- package/build/use-breakpoint.js +42 -94
- package/build/use-breakpoint.js.map +1 -1
- package/build/use-can-can.js +29 -91
- package/build/use-can-can.js.map +1 -1
- package/build/use-collection.js +118 -228
- package/build/use-collection.js.map +1 -1
- package/build/use-created-event.js +26 -43
- package/build/use-created-event.js.map +1 -1
- package/build/use-current-user-context.js +56 -150
- package/build/use-current-user-context.js.map +1 -1
- package/build/use-current-user.js +13 -31
- package/build/use-current-user.js.map +1 -1
- package/build/use-destroyed-event.js +21 -42
- package/build/use-destroyed-event.js.map +1 -1
- package/build/use-event-emitter.js +9 -14
- package/build/use-event-emitter.js.map +1 -1
- package/build/use-event-listener.js +12 -21
- package/build/use-event-listener.js.map +1 -1
- package/build/use-input.js +48 -68
- package/build/use-input.js.map +1 -1
- package/build/use-model-event.js +21 -42
- package/build/use-model-event.js.map +1 -1
- package/build/use-model.js +95 -198
- package/build/use-model.js.map +1 -1
- package/build/use-resize-observer.js +10 -20
- package/build/use-resize-observer.js.map +1 -1
- package/build/use-router.js +64 -106
- package/build/use-router.js.map +1 -1
- package/build/use-screen-layout.js +16 -18
- package/build/use-screen-layout.js.map +1 -1
- package/build/use-styles.js +23 -74
- package/build/use-styles.js.map +1 -1
- package/build/use-updated-event.js +21 -43
- package/build/use-updated-event.js.map +1 -1
- package/build/use-validation-errors.js +11 -17
- package/build/use-validation-errors.js.map +1 -1
- package/build/utils/button.js +85 -135
- package/build/utils/button.js.map +1 -1
- package/build/utils/card.js +30 -105
- package/build/utils/card.js.map +1 -1
- package/build/utils/checkbox.js +50 -111
- package/build/utils/checkbox.js.map +1 -1
- package/build/utils/checkboxes.js +108 -181
- package/build/utils/checkboxes.js.map +1 -1
- package/build/utils/default-style.js +28 -102
- package/build/utils/default-style.js.map +1 -1
- package/build/utils/header.js +7 -34
- package/build/utils/header.js.map +1 -1
- package/build/utils/icon.js +35 -116
- package/build/utils/icon.js.map +1 -1
- package/build/utils/invalid-feedback.js +15 -42
- package/build/utils/invalid-feedback.js.map +1 -1
- package/build/utils/modal.js +24 -107
- package/build/utils/modal.js.map +1 -1
- package/build/utils/text.js +9 -36
- package/build/utils/text.js.map +1 -1
- package/build/validation-error.js +30 -88
- package/build/validation-error.js.map +1 -1
- package/build/validation-errors.js +60 -110
- package/build/validation-errors.js.map +1 -1
- package/build/with-api-maker.js +14 -66
- package/build/with-api-maker.js.map +1 -1
- package/build/with-collection.js +13 -63
- package/build/with-collection.js.map +1 -1
- package/build/with-current-user.js +6 -22
- package/build/with-current-user.js.map +1 -1
- package/build/with-model.js +10 -26
- package/build/with-model.js.map +1 -1
- package/build/with-router.js +7 -34
- package/build/with-router.js.map +1 -1
- package/package.json +1 -1
package/build/table/table.js
CHANGED
|
@@ -1,810 +1,612 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { digg, digs } from "diggerize";
|
|
3
|
+
import React, { createContext, useContext, useMemo, useRef } from "react";
|
|
4
|
+
import { Animated, Platform, Pressable, View } from "react-native";
|
|
5
|
+
import BaseComponent from "../base-component.js";
|
|
6
|
+
import Card from "../bootstrap/card";
|
|
7
|
+
import classNames from "classnames";
|
|
8
|
+
import Collection from "../collection.js";
|
|
9
|
+
import columnVisible from "./column-visible.js";
|
|
10
|
+
import debounce from "debounce";
|
|
11
|
+
import DraggableSort from "../draggable-sort/index";
|
|
12
|
+
import EventEmitter from "events";
|
|
13
|
+
import Filters from "./filters/index";
|
|
14
|
+
import FlatList from "./components/flat-list";
|
|
15
|
+
import { Form } from "../form";
|
|
16
|
+
import Header from "./components/header";
|
|
17
|
+
import HeaderColumn from "./header-column";
|
|
18
|
+
import HeaderSelect from "./header-select";
|
|
19
|
+
import Icon from "../utils/icon";
|
|
20
|
+
import { incorporate } from "incorporator";
|
|
21
|
+
import * as inflection from "inflection";
|
|
22
|
+
import memo from "set-state-compare/build/memo.js";
|
|
23
|
+
import modelClassRequire from "../model-class-require.js";
|
|
24
|
+
import ModelRow from "./model-row";
|
|
25
|
+
import Paginate from "../bootstrap/paginate";
|
|
26
|
+
import Params from "../params.js";
|
|
27
|
+
import PropTypes from "prop-types";
|
|
28
|
+
import Row from "./components/row";
|
|
29
|
+
import selectCalculator from "./select-calculator.js";
|
|
30
|
+
import Select from "../inputs/select";
|
|
31
|
+
import Settings from "./settings/index";
|
|
32
|
+
import { shapeComponent } from "set-state-compare/build/shape-component.js";
|
|
33
|
+
import TableSettings from "./table-settings.js";
|
|
34
|
+
import Text from "../utils/text";
|
|
35
|
+
import uniqunize from "uniqunize";
|
|
36
|
+
import useBreakpoint from "../use-breakpoint.js";
|
|
37
|
+
import useCollection from "../use-collection.js";
|
|
38
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs";
|
|
39
|
+
import useEventEmitter from "../use-event-emitter.js";
|
|
40
|
+
import useModelEvent from "../use-model-event.js";
|
|
41
|
+
import useQueryParams from "on-location-changed/build/use-query-params.js";
|
|
42
|
+
import Widths from "./widths.js";
|
|
43
|
+
import WorkerPluginsCheckAllCheckbox from "./worker-plugins-check-all-checkbox";
|
|
44
|
+
const paginationOptions = [30, 60, 90, ["All", "all"]];
|
|
45
|
+
const TableContext = createContext();
|
|
46
|
+
const ListHeaderComponent = memo(shapeComponent(class ListHeaderComponent extends BaseComponent {
|
|
47
|
+
setup() {
|
|
48
|
+
this.useStates({
|
|
49
|
+
lastUpdate: new Date()
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
const { mdUp } = useBreakpoint();
|
|
54
|
+
const tableContextValue = useContext(TableContext);
|
|
55
|
+
const table = tableContextValue.table;
|
|
56
|
+
const { collection, events, queryWithoutPagination, t } = table.tt;
|
|
57
|
+
const { query } = digs(collection, "query");
|
|
58
|
+
useEventEmitter(events, "columnVisibilityUpdated", this.tt.onColumnVisibilityUpdated);
|
|
59
|
+
return (_jsxs(Row, { style: table.styleForRowHeader(), testID: "api-maker/table/header-row", children: [table.p.workplace && table.s.currentWorkplace &&
|
|
60
|
+
_jsxs(Header, { style: table.styleForHeader({ style: { width: mdUp ? 41 : undefined } }), children: [_jsx(WorkerPluginsCheckAllCheckbox, { currentWorkplace: table.s.currentWorkplace, query: queryWithoutPagination, style: this.workerPlguinsCheckAllCheckboxStyle ||= { marginHorizontal: "auto" } }), !mdUp &&
|
|
61
|
+
_jsx(Text, { style: this.selectAllFoundTextStyle ||= { marginLeft: 3 }, children: t(".select_all_found", { defaultValue: "Select all found" }) })] }), !mdUp &&
|
|
62
|
+
_jsx(Header, { style: table.styleForHeader({ style: {} }), children: _jsx(HeaderSelect, { preparedColumns: table.s.preparedColumns, query: query, table: table }) }), mdUp &&
|
|
63
|
+
_jsxs(_Fragment, { children: [table.headersContentFromColumns(), _jsx(Header, { style: table.styleForHeader({ style: {}, type: "actions" }) })] })] }));
|
|
33
64
|
}
|
|
34
|
-
|
|
35
|
-
}) : (function(o, m, k, k2) {
|
|
36
|
-
if (k2 === undefined) k2 = k;
|
|
37
|
-
o[k2] = m[k];
|
|
65
|
+
onColumnVisibilityUpdated = () => this.setState({ lastUpdate: new Date() });
|
|
38
66
|
}));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
export default memo(shapeComponent(class ApiMakerTable extends BaseComponent {
|
|
68
|
+
static defaultProps = {
|
|
69
|
+
card: true,
|
|
70
|
+
currentUser: null,
|
|
71
|
+
destroyEnabled: true,
|
|
72
|
+
filterCard: true,
|
|
73
|
+
filterSubmitButton: true,
|
|
74
|
+
noRecordsAvailableContent: undefined,
|
|
75
|
+
noRecordsFoundContent: undefined,
|
|
76
|
+
preloads: [],
|
|
77
|
+
select: {},
|
|
78
|
+
styleUI: true,
|
|
79
|
+
workplace: false
|
|
52
80
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
static propTypes = {
|
|
82
|
+
abilities: PropTypes.object,
|
|
83
|
+
actionsContent: PropTypes.func,
|
|
84
|
+
appHistory: PropTypes.object,
|
|
85
|
+
card: PropTypes.bool.isRequired,
|
|
86
|
+
className: PropTypes.string,
|
|
87
|
+
collection: PropTypes.instanceOf(Collection),
|
|
88
|
+
columns: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
|
|
89
|
+
controls: PropTypes.func,
|
|
90
|
+
currentUser: PropTypes.object,
|
|
91
|
+
defaultDateFormatName: PropTypes.string,
|
|
92
|
+
defaultDateTimeFormatName: PropTypes.string,
|
|
93
|
+
defaultParams: PropTypes.object,
|
|
94
|
+
destroyEnabled: PropTypes.bool.isRequired,
|
|
95
|
+
destroyMessage: PropTypes.string,
|
|
96
|
+
editModelPath: PropTypes.func,
|
|
97
|
+
filterCard: PropTypes.bool.isRequired,
|
|
98
|
+
filterContent: PropTypes.func,
|
|
99
|
+
filterSubmitLabel: PropTypes.any,
|
|
100
|
+
groupBy: PropTypes.array,
|
|
101
|
+
header: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
102
|
+
identifier: PropTypes.string,
|
|
103
|
+
modelClass: PropTypes.func.isRequired,
|
|
104
|
+
noRecordsAvailableContent: PropTypes.func,
|
|
105
|
+
noRecordsFoundContent: PropTypes.func,
|
|
106
|
+
onModelsLoaded: PropTypes.func,
|
|
107
|
+
paginateContent: PropTypes.func,
|
|
108
|
+
paginationComponent: PropTypes.func,
|
|
109
|
+
preloads: PropTypes.array.isRequired,
|
|
110
|
+
queryMethod: PropTypes.func,
|
|
111
|
+
queryName: PropTypes.string,
|
|
112
|
+
select: PropTypes.object,
|
|
113
|
+
selectColumns: PropTypes.object,
|
|
114
|
+
styles: PropTypes.object,
|
|
115
|
+
styleUI: PropTypes.bool.isRequired,
|
|
116
|
+
viewModelPath: PropTypes.func,
|
|
117
|
+
workplace: PropTypes.bool.isRequired
|
|
59
118
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
119
|
+
draggableSortEvents = new EventEmitter();
|
|
120
|
+
events = new EventEmitter();
|
|
121
|
+
tableSettings = null;
|
|
122
|
+
setup() {
|
|
123
|
+
const { t } = useI18n({ namespace: "js.api_maker.table" });
|
|
124
|
+
const { name: breakpoint, mdUp } = useBreakpoint();
|
|
125
|
+
const queryParams = useQueryParams();
|
|
126
|
+
this.setInstance({
|
|
127
|
+
breakpoint,
|
|
128
|
+
filterFormRef: useRef(),
|
|
129
|
+
mdUp,
|
|
130
|
+
t
|
|
131
|
+
});
|
|
132
|
+
const collectionKey = digg(this.p.modelClass.modelClassData(), "collectionKey");
|
|
133
|
+
let queryName = this.props.queryName;
|
|
134
|
+
if (!queryName)
|
|
135
|
+
queryName = collectionKey;
|
|
136
|
+
const querySName = `${queryName}_s`;
|
|
137
|
+
this.useStates({
|
|
138
|
+
columns: () => this.columnsAsArray(),
|
|
139
|
+
currentWorkplace: undefined,
|
|
140
|
+
currentWorkplaceCount: null,
|
|
141
|
+
filterForm: null,
|
|
142
|
+
columnsToShow: null,
|
|
143
|
+
draggedColumn: null,
|
|
144
|
+
identifier: () => this.props.identifier || `${collectionKey}-default`,
|
|
145
|
+
lastUpdate: () => new Date(),
|
|
146
|
+
preload: undefined,
|
|
147
|
+
preparedColumns: undefined,
|
|
148
|
+
queryName,
|
|
149
|
+
queryQName: () => `${queryName}_q`,
|
|
150
|
+
queryPageName: () => `${queryName}_page`,
|
|
151
|
+
querySName,
|
|
152
|
+
resizing: false,
|
|
153
|
+
showFilters: () => Boolean(queryParams[querySName]),
|
|
154
|
+
showSettings: false,
|
|
155
|
+
tableSetting: undefined,
|
|
156
|
+
tableSettingLoaded: false,
|
|
157
|
+
tableSettingFullCacheKey: undefined,
|
|
158
|
+
width: undefined,
|
|
159
|
+
widths: null
|
|
160
|
+
});
|
|
161
|
+
this.tableContextValue = useMemo(() => ({
|
|
162
|
+
cacheKey: this.s.tableSettingFullCacheKey,
|
|
163
|
+
lastUpdate: this.s.lastUpdate,
|
|
164
|
+
resizing: this.s.resizing,
|
|
165
|
+
table: this
|
|
166
|
+
}), [this.s.lastUpdate, this.s.resizing, this.s.tableSettingFullCacheKey]);
|
|
167
|
+
useMemo(() => {
|
|
168
|
+
if (this.props.workplace) {
|
|
169
|
+
this.loadCurrentWorkplace().then(() => {
|
|
170
|
+
this.loadCurrentWorkplaceCount();
|
|
171
|
+
});
|
|
91
172
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
t[p[i]] = s[p[i]];
|
|
173
|
+
}, [this.p.currentUser?.id()]);
|
|
174
|
+
useMemo(() => {
|
|
175
|
+
if (!this.tt.tableSettings && this.s.width) {
|
|
176
|
+
this.loadTableSetting();
|
|
177
|
+
}
|
|
178
|
+
}, [this.p.currentUser?.id(), this.s.width]);
|
|
179
|
+
useModelEvent(this.s.currentWorkplace, "workplace_links_created", this.tt.onLinksCreated);
|
|
180
|
+
useModelEvent(this.s.currentWorkplace, "workplace_links_destroyed", this.tt.onLinksDestroyed);
|
|
181
|
+
let collectionReady = true;
|
|
182
|
+
let select;
|
|
183
|
+
if (!this.s.preparedColumns) {
|
|
184
|
+
collectionReady = false;
|
|
105
185
|
}
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var header_select_1 = __importDefault(require("./header-select"));
|
|
131
|
-
var icon_1 = __importDefault(require("../utils/icon"));
|
|
132
|
-
var incorporator_1 = require("incorporator");
|
|
133
|
-
var inflection = __importStar(require("inflection"));
|
|
134
|
-
var memo_js_1 = __importDefault(require("set-state-compare/build/memo.js"));
|
|
135
|
-
var model_class_require_js_1 = __importDefault(require("../model-class-require.js"));
|
|
136
|
-
var model_row_1 = __importDefault(require("./model-row"));
|
|
137
|
-
var paginate_1 = __importDefault(require("../bootstrap/paginate"));
|
|
138
|
-
var params_js_1 = __importDefault(require("../params.js"));
|
|
139
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
140
|
-
var row_1 = __importDefault(require("./components/row"));
|
|
141
|
-
var select_calculator_js_1 = __importDefault(require("./select-calculator.js"));
|
|
142
|
-
var select_1 = __importDefault(require("../inputs/select"));
|
|
143
|
-
var index_3 = __importDefault(require("./settings/index"));
|
|
144
|
-
var shape_component_js_1 = require("set-state-compare/build/shape-component.js");
|
|
145
|
-
var table_settings_js_1 = __importDefault(require("./table-settings.js"));
|
|
146
|
-
var text_1 = __importDefault(require("../utils/text"));
|
|
147
|
-
var uniqunize_1 = __importDefault(require("uniqunize"));
|
|
148
|
-
var use_breakpoint_js_1 = __importDefault(require("../use-breakpoint.js"));
|
|
149
|
-
var use_collection_js_1 = __importDefault(require("../use-collection.js"));
|
|
150
|
-
var use_i18n_mjs_1 = __importDefault(require("i18n-on-steroids/src/use-i18n.mjs"));
|
|
151
|
-
var use_event_emitter_js_1 = __importDefault(require("../use-event-emitter.js"));
|
|
152
|
-
var use_model_event_js_1 = __importDefault(require("../use-model-event.js"));
|
|
153
|
-
var use_query_params_js_1 = __importDefault(require("on-location-changed/build/use-query-params.js"));
|
|
154
|
-
var widths_js_1 = __importDefault(require("./widths.js"));
|
|
155
|
-
var worker_plugins_check_all_checkbox_1 = __importDefault(require("./worker-plugins-check-all-checkbox"));
|
|
156
|
-
var paginationOptions = [30, 60, 90, ["All", "all"]];
|
|
157
|
-
var TableContext = (0, react_1.createContext)();
|
|
158
|
-
var ListHeaderComponent = (0, memo_js_1.default)((0, shape_component_js_1.shapeComponent)(/** @class */ (function (_super) {
|
|
159
|
-
__extends(ListHeaderComponent, _super);
|
|
160
|
-
function ListHeaderComponent() {
|
|
161
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
162
|
-
_this.onColumnVisibilityUpdated = function () { return _this.setState({ lastUpdate: new Date() }); };
|
|
163
|
-
return _this;
|
|
186
|
+
if (collectionReady) {
|
|
187
|
+
select = selectCalculator({ table: this });
|
|
188
|
+
}
|
|
189
|
+
this.collection = useCollection({
|
|
190
|
+
abilities: this.abilitiesToLoad(),
|
|
191
|
+
defaultParams: this.props.defaultParams,
|
|
192
|
+
collection: this.props.collection,
|
|
193
|
+
groupBy: this.props.groupBy,
|
|
194
|
+
ifCondition: collectionReady,
|
|
195
|
+
modelClass: this.props.modelClass,
|
|
196
|
+
onModelsLoaded: this.props.onModelsLoaded,
|
|
197
|
+
noRecordsAvailableContent: this.props.noRecordsAvailableContent,
|
|
198
|
+
noRecordsFoundContent: this.props.noRecordsFoundContent,
|
|
199
|
+
pagination: true,
|
|
200
|
+
preloads: this.state.preload,
|
|
201
|
+
queryMethod: this.props.queryMethod,
|
|
202
|
+
queryName,
|
|
203
|
+
select,
|
|
204
|
+
selectColumns: this.props.selectColumns
|
|
205
|
+
});
|
|
206
|
+
this.queryWithoutPagination = useMemo(() => this.collection?.query?.clone()?.except("page"), [this.collection.query]);
|
|
207
|
+
useEventEmitter(this.tt.draggableSortEvents, "onDragStart", this.tt.onDragStart);
|
|
208
|
+
useEventEmitter(this.tt.draggableSortEvents, "onDragEndAnimation", this.tt.onDragEndAnimation);
|
|
209
|
+
useEventEmitter(this.tt.events, "columnVisibilityUpdated", this.tt.onColumnVisibilityUpdated);
|
|
164
210
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
211
|
+
onColumnVisibilityUpdated = () => this.setState({ columnsToShow: this.getColumnsToShow(this.s.columns), lastUpdate: new Date() });
|
|
212
|
+
onDragStart = ({ item }) => item.animatedZIndex.setValue(9999);
|
|
213
|
+
onDragEndAnimation = ({ item }) => item.animatedZIndex.setValue(0);
|
|
214
|
+
async loadCurrentWorkplace() {
|
|
215
|
+
const Workplace = modelClassRequire("Workplace");
|
|
216
|
+
const result = await Workplace.current();
|
|
217
|
+
const currentWorkplace = digg(result, "current", 0);
|
|
218
|
+
this.setState({ currentWorkplace });
|
|
219
|
+
}
|
|
220
|
+
async loadCurrentWorkplaceCount() {
|
|
221
|
+
const WorkplaceLink = modelClassRequire("WorkplaceLink");
|
|
222
|
+
const currentWorkplaceCount = await WorkplaceLink
|
|
223
|
+
.ransack({
|
|
224
|
+
resource_type_eq: this.p.modelClass.modelClassData().name,
|
|
225
|
+
workplace_id_eq: this.s.currentWorkplace.id()
|
|
226
|
+
})
|
|
227
|
+
.count();
|
|
228
|
+
this.setState({ currentWorkplaceCount });
|
|
229
|
+
}
|
|
230
|
+
getColumnsToShow(columns) {
|
|
231
|
+
return columns
|
|
232
|
+
.filter(({ column, tableSettingColumn }) => columnVisible(column, tableSettingColumn))
|
|
233
|
+
.sort((a, b) => a.tableSettingColumn.position() - b.tableSettingColumn.position());
|
|
234
|
+
}
|
|
235
|
+
async loadTableSetting() {
|
|
236
|
+
this.tableSettings = new TableSettings({ table: this });
|
|
237
|
+
const tableSetting = await this.tableSettings.loadExistingOrCreateTableSettings();
|
|
238
|
+
const { columns, preload } = this.tableSettings.preparedColumns(tableSetting);
|
|
239
|
+
const { width } = this.s;
|
|
240
|
+
const widths = new Widths({ columns, table: this, width });
|
|
241
|
+
const columnsToShow = this.getColumnsToShow(columns);
|
|
242
|
+
this.setState({
|
|
243
|
+
columns,
|
|
244
|
+
columnsToShow,
|
|
245
|
+
preparedColumns: columns,
|
|
246
|
+
preload: this.mergedPreloads(preload),
|
|
247
|
+
tableSetting,
|
|
248
|
+
tableSettingLoaded: true,
|
|
249
|
+
tableSettingFullCacheKey: tableSetting.fullCacheKey(),
|
|
250
|
+
widths
|
|
168
251
|
});
|
|
252
|
+
}
|
|
253
|
+
updateSettingsFullCacheKey = () => this.setState({ tableSettingFullCacheKey: this.state.tableSetting.fullCacheKey() });
|
|
254
|
+
columnsAsArray = () => {
|
|
255
|
+
if (typeof this.props.columns == "function") {
|
|
256
|
+
return this.props.columns();
|
|
257
|
+
}
|
|
258
|
+
return this.props.columns;
|
|
169
259
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
var item = _b.item;
|
|
195
|
-
return item.animatedZIndex.setValue(9999);
|
|
196
|
-
};
|
|
197
|
-
_this.onDragEndAnimation = function (_b) {
|
|
198
|
-
var item = _b.item;
|
|
199
|
-
return item.animatedZIndex.setValue(0);
|
|
200
|
-
};
|
|
201
|
-
_this.updateSettingsFullCacheKey = function () { return _this.setState({ tableSettingFullCacheKey: _this.state.tableSetting.fullCacheKey() }); };
|
|
202
|
-
_this.columnsAsArray = function () {
|
|
203
|
-
if (typeof _this.props.columns == "function") {
|
|
204
|
-
return _this.props.columns();
|
|
205
|
-
}
|
|
206
|
-
return _this.props.columns;
|
|
207
|
-
};
|
|
208
|
-
_this.onContainerLayout = function (e) {
|
|
209
|
-
var width = e.nativeEvent.layout.width;
|
|
210
|
-
var widths = _this.s.widths;
|
|
211
|
-
_this.setState({ width: width });
|
|
212
|
-
if (widths)
|
|
213
|
-
widths.tableWidth = width;
|
|
214
|
-
};
|
|
215
|
-
_this.onLinksCreated = function (_b) {
|
|
216
|
-
var args = _b.args;
|
|
217
|
-
var modelClassName = _this.p.modelClass.modelClassData().name;
|
|
218
|
-
if (args.created[modelClassName]) {
|
|
219
|
-
var amountCreated_1 = args.created[modelClassName].length;
|
|
220
|
-
_this.setState(function (prevState) { return ({
|
|
221
|
-
currentWorkplaceCount: prevState.currentWorkplaceCount + amountCreated_1
|
|
222
|
-
}); });
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
_this.onLinksDestroyed = function (_b) {
|
|
226
|
-
var args = _b.args;
|
|
227
|
-
var modelClassName = _this.p.modelClass.modelClassData().name;
|
|
228
|
-
if (args.destroyed[modelClassName]) {
|
|
229
|
-
var amountDestroyed_1 = args.destroyed[modelClassName].length;
|
|
230
|
-
_this.setState(function (prevState) { return ({
|
|
231
|
-
currentWorkplaceCount: prevState.currentWorkplaceCount - amountDestroyed_1
|
|
232
|
-
}); });
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
_this.keyExtrator = function (model) { return "".concat(_this.s.tableSettingFullCacheKey, "-").concat(model.id()); };
|
|
236
|
-
_this.filterForm = function () {
|
|
237
|
-
var _b = _this.tt, filterFormRef = _b.filterFormRef, submitFilter = _b.submitFilter, submitFilterDebounce = _b.submitFilterDebounce;
|
|
238
|
-
var _c = _this.p, filterContent = _c.filterContent, filterSubmitButton = _c.filterSubmitButton;
|
|
239
|
-
var queryQName = _this.s.queryQName;
|
|
240
|
-
var filterSubmitLabel = _this.props.filterSubmitLabel;
|
|
241
|
-
var qParams = (0, diggerize_1.digs)(_this.collection, "qParams").qParams;
|
|
242
|
-
return ((0, jsx_runtime_1.jsxs)(form_1.Form, { className: "live-table--filter-form", formRef: filterFormRef, onSubmit: _this.tt.onFilterFormSubmit, setForm: _this.setStates.filterForm, children: ["s" in qParams &&
|
|
243
|
-
(0, jsx_runtime_1.jsx)("input", { name: "s", type: "hidden", value: qParams.s }), filterContent({
|
|
244
|
-
onFilterChanged: submitFilter,
|
|
245
|
-
onFilterChangedWithDelay: submitFilterDebounce,
|
|
246
|
-
qParams: qParams,
|
|
247
|
-
queryQName: queryQName
|
|
248
|
-
}), filterSubmitButton &&
|
|
249
|
-
(0, jsx_runtime_1.jsx)("input", { className: "btn btn-primary live-table--submit-filter-button", type: "submit", style: { marginTop: "8px" }, value: filterSubmitLabel || _this.t(".filter", { defaultValue: "Filter" }) })] }));
|
|
250
|
-
};
|
|
251
|
-
_this.onFilterClicked = function (e) {
|
|
252
|
-
e.preventDefault();
|
|
253
|
-
_this.setState({ showFilters: !_this.state.showFilters });
|
|
254
|
-
};
|
|
255
|
-
_this.onPerPageChanged = function (e) {
|
|
256
|
-
var queryName = _this.s.queryName;
|
|
257
|
-
var newPerPageValue = (0, diggerize_1.digg)(e, "target", "value");
|
|
258
|
-
var perKey = "".concat(queryName, "_per");
|
|
259
|
-
var paramsChange = {};
|
|
260
|
-
paramsChange[perKey] = newPerPageValue;
|
|
261
|
-
params_js_1.default.changeParams(paramsChange);
|
|
262
|
-
};
|
|
263
|
-
_this.renderItem = function (_b) {
|
|
264
|
-
var index = _b.index, model = _b.item;
|
|
265
|
-
if (!_this.s.tableSettingLoaded) {
|
|
266
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { children: (0, jsx_runtime_1.jsx)(text_1.default, { children: _this.t(".loading_dot_dot_dot", { defaultValue: "Loading..." }) }) }));
|
|
267
|
-
}
|
|
268
|
-
return ((0, jsx_runtime_1.jsx)(model_row_1.default, { cacheKey: model.cacheKey(), columns: _this.s.columnsToShow, columnWidths: _this.columnWidths(), events: _this.tt.events, index: index, model: model, table: _this, tableSettingFullCacheKey: _this.s.tableSettingFullCacheKey }, model.id()));
|
|
269
|
-
};
|
|
270
|
-
_this.styleForColumn = function (_b) {
|
|
271
|
-
var column = _b.column, columnIndex = _b.columnIndex, even = _b.even, style = _b.style, type = _b.type;
|
|
272
|
-
var styleUI = _this.p.styleUI;
|
|
273
|
-
var defaultStyle = {
|
|
274
|
-
justifyContent: "center",
|
|
275
|
-
padding: 8,
|
|
276
|
-
overflow: "hidden"
|
|
277
|
-
};
|
|
278
|
-
if (styleUI) {
|
|
279
|
-
Object.assign(defaultStyle, {
|
|
280
|
-
backgroundColor: even ? "#f5f5f5" : "#fff"
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
if (type == "actions") {
|
|
284
|
-
defaultStyle.flexDirection = "row";
|
|
285
|
-
defaultStyle.alignItems = "center";
|
|
286
|
-
if (_this.tt.mdUp) {
|
|
287
|
-
defaultStyle.marginLeft = "auto";
|
|
260
|
+
mergedPreloads(preload) {
|
|
261
|
+
const { preloads } = this.props;
|
|
262
|
+
let mergedPreloads = [];
|
|
263
|
+
if (preloads)
|
|
264
|
+
mergedPreloads = mergedPreloads.concat(preloads);
|
|
265
|
+
if (preload)
|
|
266
|
+
mergedPreloads = mergedPreloads.concat(preload);
|
|
267
|
+
return uniqunize(mergedPreloads);
|
|
268
|
+
}
|
|
269
|
+
render() {
|
|
270
|
+
const { modelClass, noRecordsAvailableContent, noRecordsFoundContent } = this.p;
|
|
271
|
+
const { collection, currentUser } = this.props;
|
|
272
|
+
const { queryName, querySName, showFilters } = this.s;
|
|
273
|
+
const { models, overallCount, qParams, query, result, showNoRecordsAvailableContent, showNoRecordsFoundContent } = digs(this.collection, "models", "overallCount", "qParams", "query", "result", "showNoRecordsAvailableContent", "showNoRecordsFoundContent");
|
|
274
|
+
if (collection && collection.args.modelClass.modelClassData().name != modelClass.modelClassData().name) {
|
|
275
|
+
throw new Error(`Model class from collection '${collection.args.modelClass.modelClassData().name}' ` +
|
|
276
|
+
`didn't match model class on table: '${modelClass.modelClassData().name}'`);
|
|
277
|
+
}
|
|
278
|
+
return (_jsxs(View, { dataSet: this.cache("rootViewDataSet", { class: this.className() }, [this.className()]), onLayout: this.tt.onContainerLayout, style: this.props.styles?.container, children: [showNoRecordsAvailableContent &&
|
|
279
|
+
_jsx("div", { className: "live-table--no-records-available-content", children: noRecordsAvailableContent({ models, qParams, overallCount }) }), showNoRecordsFoundContent &&
|
|
280
|
+
_jsx("div", { className: "live-table--no-records-found-content", children: noRecordsFoundContent({ models, qParams, overallCount }) }), showFilters &&
|
|
281
|
+
_jsx(Filters, { currentUser: currentUser, modelClass: modelClass, queryName: queryName, querySName: querySName }), (() => {
|
|
282
|
+
if (qParams && query && result && models && !showNoRecordsAvailableContent && !showNoRecordsFoundContent) {
|
|
283
|
+
return this.cardOrTable();
|
|
288
284
|
}
|
|
289
285
|
else {
|
|
290
|
-
|
|
286
|
+
return (_jsx(View, { children: _jsx(Text, { children: this.t(".loading_dot_dot_dit", { defaultValue: "Loading..." }) }) }));
|
|
291
287
|
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (type != "actions" && mdUp && _this.p.styleUI) {
|
|
308
|
-
defaultStyle.borderRight = "1px solid #dbdbdb";
|
|
309
|
-
}
|
|
310
|
-
var actualStyle = Object.assign(defaultStyle, style);
|
|
311
|
-
return actualStyle;
|
|
312
|
-
};
|
|
313
|
-
_this.styleForRow = function (_b) {
|
|
314
|
-
var _c = _b === void 0 ? {} : _b, even = _c.even;
|
|
315
|
-
var actualStyle = {
|
|
316
|
-
flex: 1,
|
|
317
|
-
alignItems: "stretch"
|
|
318
|
-
};
|
|
319
|
-
if (even && _this.p.styleUI) {
|
|
320
|
-
actualStyle.backgroundColor = "#f5f5f5";
|
|
321
|
-
}
|
|
322
|
-
return actualStyle;
|
|
323
|
-
};
|
|
324
|
-
_this.styleForRowHeader = function () {
|
|
325
|
-
var actualStyle = {
|
|
326
|
-
flex: 1,
|
|
327
|
-
alignItems: "stretch"
|
|
328
|
-
};
|
|
329
|
-
return actualStyle;
|
|
330
|
-
};
|
|
331
|
-
_this.headersContentFromColumns = function () {
|
|
332
|
-
return ((0, jsx_runtime_1.jsx)(index_1.default, { data: _this.s.columnsToShow, events: _this.tt.draggableSortEvents, horizontal: true, keyExtractor: _this.tt.dragListkeyExtractor, onItemMoved: _this.tt.onItemMoved, onReordered: _this.tt.onReordered, renderItem: _this.tt.dragListRenderItemContent }));
|
|
333
|
-
};
|
|
334
|
-
_this.dragListCacheKeyExtractor = function (item) { return "".concat(item.tableSettingColumn.identifier(), "-").concat(_this.s.resizing); };
|
|
335
|
-
_this.dragListkeyExtractor = function (item) { return item.tableSettingColumn.identifier(); };
|
|
336
|
-
_this.onItemMoved = function (_b) {
|
|
337
|
-
var animationArgs = _b.animationArgs, itemIndex = _b.itemIndex, x = _b.x, y = _b.y;
|
|
338
|
-
var animatedPosition = (0, diggerize_1.digg)(_this, "s", "columnsToShow", itemIndex, "animatedPosition");
|
|
339
|
-
if (animationArgs) {
|
|
340
|
-
react_native_1.Animated.timing(animatedPosition, animationArgs).start();
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
animatedPosition.setValue({ x: x, y: y });
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
_this.onReordered = function (_b) { return __awaiter(_this, [_b], void 0, function (_c) {
|
|
347
|
-
var TableSettingColumn, toColumn;
|
|
348
|
-
var fromItem = _c.fromItem, fromPosition = _c.fromPosition, toItem = _c.toItem, toPosition = _c.toPosition;
|
|
349
|
-
return __generator(this, function (_d) {
|
|
350
|
-
switch (_d.label) {
|
|
351
|
-
case 0:
|
|
352
|
-
if (fromPosition == toPosition)
|
|
353
|
-
return [2 /*return*/]; // Only do requests and queries if changed
|
|
354
|
-
TableSettingColumn = fromItem.tableSettingColumn.constructor;
|
|
355
|
-
return [4 /*yield*/, TableSettingColumn.find(toItem.tableSettingColumn.id())]; // Need to load latest position because ActsAsList might have changed it
|
|
356
|
-
case 1:
|
|
357
|
-
toColumn = _d.sent() // Need to load latest position because ActsAsList might have changed it
|
|
358
|
-
;
|
|
359
|
-
return [4 /*yield*/, fromItem.tableSettingColumn.update({ position: toColumn.position() })];
|
|
360
|
-
case 2:
|
|
361
|
-
_d.sent();
|
|
362
|
-
return [2 /*return*/];
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}); };
|
|
366
|
-
_this.dragListRenderItemContent = function (_b) {
|
|
367
|
-
var isActive = _b.isActive, item = _b.item, touchProps = _b.touchProps;
|
|
368
|
-
var animatedWidth = item.animatedWidth, animatedZIndex = item.animatedZIndex, column = item.column, tableSettingColumn = item.tableSettingColumn;
|
|
369
|
-
return ((0, jsx_runtime_1.jsx)(header_column_1.default, { active: isActive, animatedWidth: animatedWidth, animatedZIndex: animatedZIndex, column: column, resizing: _this.s.resizing, table: _this, tableSettingColumn: tableSettingColumn, touchProps: touchProps, widths: _this.s.widths }, tableSettingColumn.identifier()));
|
|
370
|
-
};
|
|
371
|
-
_this.onFilterFormSubmit = function () { return _this.submitFilter(); };
|
|
372
|
-
_this.onRequestCloseSettings = function () { return _this.setState({ showSettings: false }); };
|
|
373
|
-
_this.onSettingsClicked = function (e) {
|
|
374
|
-
e.preventDefault();
|
|
375
|
-
_this.setState({ showSettings: !_this.s.showSettings });
|
|
376
|
-
};
|
|
377
|
-
_this.submitFilter = function () {
|
|
378
|
-
var appHistory = _this.props.appHistory;
|
|
379
|
-
var queryQName = _this.s.queryQName;
|
|
380
|
-
var changeParamsParams = {};
|
|
381
|
-
var qParams = _this.s.filterForm.asObject();
|
|
382
|
-
if (react_native_1.Platform.OS == "web") {
|
|
383
|
-
var filterForm = (0, diggerize_1.digg)(_this.tt.filterFormRef, "current");
|
|
384
|
-
var navtiveFormParams = params_js_1.default.serializeForm(filterForm);
|
|
385
|
-
(0, incorporator_1.incorporate)(qParams, navtiveFormParams);
|
|
386
|
-
}
|
|
387
|
-
changeParamsParams[queryQName] = JSON.stringify(qParams);
|
|
388
|
-
params_js_1.default.changeParams(changeParamsParams, { appHistory: appHistory });
|
|
389
|
-
};
|
|
390
|
-
_this.submitFilterDebounce = (0, debounce_1.default)(_this.tt.submitFilter);
|
|
391
|
-
return _this;
|
|
288
|
+
})()] }));
|
|
289
|
+
}
|
|
290
|
+
abilitiesToLoad() {
|
|
291
|
+
const abilitiesToLoad = {};
|
|
292
|
+
const { abilities, modelClass } = this.props;
|
|
293
|
+
const ownAbilities = [];
|
|
294
|
+
if (this.props.destroyEnabled)
|
|
295
|
+
ownAbilities.push("destroy");
|
|
296
|
+
if (this.props.editModelPath)
|
|
297
|
+
ownAbilities.push("edit");
|
|
298
|
+
if (this.props.viewModelPath)
|
|
299
|
+
ownAbilities.push("show");
|
|
300
|
+
if (ownAbilities.length > 0) {
|
|
301
|
+
const modelClassName = digg(modelClass.modelClassData(), "name");
|
|
302
|
+
abilitiesToLoad[modelClassName] = ownAbilities;
|
|
392
303
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
var _d = (0, use_breakpoint_js_1.default)(), breakpoint = _d.name, mdUp = _d.mdUp;
|
|
398
|
-
var queryParams = (0, use_query_params_js_1.default)();
|
|
399
|
-
this.setInstance({
|
|
400
|
-
breakpoint: breakpoint,
|
|
401
|
-
filterFormRef: (0, react_1.useRef)(),
|
|
402
|
-
mdUp: mdUp,
|
|
403
|
-
t: t
|
|
404
|
-
});
|
|
405
|
-
var collectionKey = (0, diggerize_1.digg)(this.p.modelClass.modelClassData(), "collectionKey");
|
|
406
|
-
var queryName = this.props.queryName;
|
|
407
|
-
if (!queryName)
|
|
408
|
-
queryName = collectionKey;
|
|
409
|
-
var querySName = "".concat(queryName, "_s");
|
|
410
|
-
this.useStates({
|
|
411
|
-
columns: function () { return _this.columnsAsArray(); },
|
|
412
|
-
currentWorkplace: undefined,
|
|
413
|
-
currentWorkplaceCount: null,
|
|
414
|
-
filterForm: null,
|
|
415
|
-
columnsToShow: null,
|
|
416
|
-
draggedColumn: null,
|
|
417
|
-
identifier: function () { return _this.props.identifier || "".concat(collectionKey, "-default"); },
|
|
418
|
-
lastUpdate: function () { return new Date(); },
|
|
419
|
-
preload: undefined,
|
|
420
|
-
preparedColumns: undefined,
|
|
421
|
-
queryName: queryName,
|
|
422
|
-
queryQName: function () { return "".concat(queryName, "_q"); },
|
|
423
|
-
queryPageName: function () { return "".concat(queryName, "_page"); },
|
|
424
|
-
querySName: querySName,
|
|
425
|
-
resizing: false,
|
|
426
|
-
showFilters: function () { return Boolean(queryParams[querySName]); },
|
|
427
|
-
showSettings: false,
|
|
428
|
-
tableSetting: undefined,
|
|
429
|
-
tableSettingLoaded: false,
|
|
430
|
-
tableSettingFullCacheKey: undefined,
|
|
431
|
-
width: undefined,
|
|
432
|
-
widths: null
|
|
433
|
-
});
|
|
434
|
-
this.tableContextValue = (0, react_1.useMemo)(function () { return ({
|
|
435
|
-
cacheKey: _this.s.tableSettingFullCacheKey,
|
|
436
|
-
lastUpdate: _this.s.lastUpdate,
|
|
437
|
-
resizing: _this.s.resizing,
|
|
438
|
-
table: _this
|
|
439
|
-
}); }, [this.s.lastUpdate, this.s.resizing, this.s.tableSettingFullCacheKey]);
|
|
440
|
-
(0, react_1.useMemo)(function () {
|
|
441
|
-
if (_this.props.workplace) {
|
|
442
|
-
_this.loadCurrentWorkplace().then(function () {
|
|
443
|
-
_this.loadCurrentWorkplaceCount();
|
|
444
|
-
});
|
|
304
|
+
if (abilities) {
|
|
305
|
+
for (const modelName in abilities) {
|
|
306
|
+
if (!(modelName in abilitiesToLoad)) {
|
|
307
|
+
abilitiesToLoad[modelName] = [];
|
|
445
308
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (!_this.tt.tableSettings && _this.s.width) {
|
|
449
|
-
_this.loadTableSetting();
|
|
309
|
+
for (const ability of abilities[modelName]) {
|
|
310
|
+
abilitiesToLoad[modelName].push(ability);
|
|
450
311
|
}
|
|
451
|
-
}, [(_c = this.p.currentUser) === null || _c === void 0 ? void 0 : _c.id(), this.s.width]);
|
|
452
|
-
(0, use_model_event_js_1.default)(this.s.currentWorkplace, "workplace_links_created", this.tt.onLinksCreated);
|
|
453
|
-
(0, use_model_event_js_1.default)(this.s.currentWorkplace, "workplace_links_destroyed", this.tt.onLinksDestroyed);
|
|
454
|
-
var collectionReady = true;
|
|
455
|
-
var select;
|
|
456
|
-
if (!this.s.preparedColumns) {
|
|
457
|
-
collectionReady = false;
|
|
458
312
|
}
|
|
459
|
-
|
|
460
|
-
|
|
313
|
+
}
|
|
314
|
+
return abilitiesToLoad;
|
|
315
|
+
}
|
|
316
|
+
cardOrTable() {
|
|
317
|
+
const { abilities, actionsContent, appHistory, card, className, collection, columns, controls, currentUser, defaultDateFormatName, defaultDateTimeFormatName, defaultParams, destroyEnabled, destroyMessage, editModelPath, filterCard, filterContent, filterSubmitButton, filterSubmitLabel, groupBy, header, identifier, modelClass, noRecordsAvailableContent, noRecordsFoundContent, onModelsLoaded, paginateContent, paginationComponent, preloads, queryMethod, queryName, select, selectColumns, styleUI, viewModelPath, workplace, ...restProps } = this.props;
|
|
318
|
+
const { models, qParams, query, result } = digs(this.collection, "models", "qParams", "query", "result");
|
|
319
|
+
let headerContent, PaginationComponent;
|
|
320
|
+
if (typeof header == "function") {
|
|
321
|
+
headerContent = header({ models, qParams, query, result });
|
|
322
|
+
}
|
|
323
|
+
else if (header) {
|
|
324
|
+
headerContent = header;
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
headerContent = modelClass.modelName().human({ count: 2 });
|
|
328
|
+
}
|
|
329
|
+
if (!paginateContent) {
|
|
330
|
+
if (paginationComponent) {
|
|
331
|
+
PaginationComponent = paginationComponent;
|
|
461
332
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
defaultParams: this.props.defaultParams,
|
|
465
|
-
collection: this.props.collection,
|
|
466
|
-
groupBy: this.props.groupBy,
|
|
467
|
-
ifCondition: collectionReady,
|
|
468
|
-
modelClass: this.props.modelClass,
|
|
469
|
-
onModelsLoaded: this.props.onModelsLoaded,
|
|
470
|
-
noRecordsAvailableContent: this.props.noRecordsAvailableContent,
|
|
471
|
-
noRecordsFoundContent: this.props.noRecordsFoundContent,
|
|
472
|
-
pagination: true,
|
|
473
|
-
preloads: this.state.preload,
|
|
474
|
-
queryMethod: this.props.queryMethod,
|
|
475
|
-
queryName: queryName,
|
|
476
|
-
select: select,
|
|
477
|
-
selectColumns: this.props.selectColumns
|
|
478
|
-
});
|
|
479
|
-
this.queryWithoutPagination = (0, react_1.useMemo)(function () { var _b, _c, _d; return (_d = (_c = (_b = _this.collection) === null || _b === void 0 ? void 0 : _b.query) === null || _c === void 0 ? void 0 : _c.clone()) === null || _d === void 0 ? void 0 : _d.except("page"); }, [this.collection.query]);
|
|
480
|
-
(0, use_event_emitter_js_1.default)(this.tt.draggableSortEvents, "onDragStart", this.tt.onDragStart);
|
|
481
|
-
(0, use_event_emitter_js_1.default)(this.tt.draggableSortEvents, "onDragEndAnimation", this.tt.onDragEndAnimation);
|
|
482
|
-
(0, use_event_emitter_js_1.default)(this.tt.events, "columnVisibilityUpdated", this.tt.onColumnVisibilityUpdated);
|
|
483
|
-
};
|
|
484
|
-
ApiMakerTable.prototype.loadCurrentWorkplace = function () {
|
|
485
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
486
|
-
var Workplace, result, currentWorkplace;
|
|
487
|
-
return __generator(this, function (_b) {
|
|
488
|
-
switch (_b.label) {
|
|
489
|
-
case 0:
|
|
490
|
-
Workplace = (0, model_class_require_js_1.default)("Workplace");
|
|
491
|
-
return [4 /*yield*/, Workplace.current()];
|
|
492
|
-
case 1:
|
|
493
|
-
result = _b.sent();
|
|
494
|
-
currentWorkplace = (0, diggerize_1.digg)(result, "current", 0);
|
|
495
|
-
this.setState({ currentWorkplace: currentWorkplace });
|
|
496
|
-
return [2 /*return*/];
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
};
|
|
501
|
-
ApiMakerTable.prototype.loadCurrentWorkplaceCount = function () {
|
|
502
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
503
|
-
var WorkplaceLink, currentWorkplaceCount;
|
|
504
|
-
return __generator(this, function (_b) {
|
|
505
|
-
switch (_b.label) {
|
|
506
|
-
case 0:
|
|
507
|
-
WorkplaceLink = (0, model_class_require_js_1.default)("WorkplaceLink");
|
|
508
|
-
return [4 /*yield*/, WorkplaceLink
|
|
509
|
-
.ransack({
|
|
510
|
-
resource_type_eq: this.p.modelClass.modelClassData().name,
|
|
511
|
-
workplace_id_eq: this.s.currentWorkplace.id()
|
|
512
|
-
})
|
|
513
|
-
.count()];
|
|
514
|
-
case 1:
|
|
515
|
-
currentWorkplaceCount = _b.sent();
|
|
516
|
-
this.setState({ currentWorkplaceCount: currentWorkplaceCount });
|
|
517
|
-
return [2 /*return*/];
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
ApiMakerTable.prototype.getColumnsToShow = function (columns) {
|
|
523
|
-
return columns
|
|
524
|
-
.filter(function (_b) {
|
|
525
|
-
var column = _b.column, tableSettingColumn = _b.tableSettingColumn;
|
|
526
|
-
return (0, column_visible_js_1.default)(column, tableSettingColumn);
|
|
527
|
-
})
|
|
528
|
-
.sort(function (a, b) { return a.tableSettingColumn.position() - b.tableSettingColumn.position(); });
|
|
529
|
-
};
|
|
530
|
-
ApiMakerTable.prototype.loadTableSetting = function () {
|
|
531
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
532
|
-
var tableSetting, _b, columns, preload, width, widths, columnsToShow;
|
|
533
|
-
return __generator(this, function (_c) {
|
|
534
|
-
switch (_c.label) {
|
|
535
|
-
case 0:
|
|
536
|
-
this.tableSettings = new table_settings_js_1.default({ table: this });
|
|
537
|
-
return [4 /*yield*/, this.tableSettings.loadExistingOrCreateTableSettings()];
|
|
538
|
-
case 1:
|
|
539
|
-
tableSetting = _c.sent();
|
|
540
|
-
_b = this.tableSettings.preparedColumns(tableSetting), columns = _b.columns, preload = _b.preload;
|
|
541
|
-
width = this.s.width;
|
|
542
|
-
widths = new widths_js_1.default({ columns: columns, table: this, width: width });
|
|
543
|
-
columnsToShow = this.getColumnsToShow(columns);
|
|
544
|
-
this.setState({
|
|
545
|
-
columns: columns,
|
|
546
|
-
columnsToShow: columnsToShow,
|
|
547
|
-
preparedColumns: columns,
|
|
548
|
-
preload: this.mergedPreloads(preload),
|
|
549
|
-
tableSetting: tableSetting,
|
|
550
|
-
tableSettingLoaded: true,
|
|
551
|
-
tableSettingFullCacheKey: tableSetting.fullCacheKey(),
|
|
552
|
-
widths: widths
|
|
553
|
-
});
|
|
554
|
-
return [2 /*return*/];
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
});
|
|
558
|
-
};
|
|
559
|
-
ApiMakerTable.prototype.mergedPreloads = function (preload) {
|
|
560
|
-
var preloads = this.props.preloads;
|
|
561
|
-
var mergedPreloads = [];
|
|
562
|
-
if (preloads)
|
|
563
|
-
mergedPreloads = mergedPreloads.concat(preloads);
|
|
564
|
-
if (preload)
|
|
565
|
-
mergedPreloads = mergedPreloads.concat(preload);
|
|
566
|
-
return (0, uniqunize_1.default)(mergedPreloads);
|
|
567
|
-
};
|
|
568
|
-
ApiMakerTable.prototype.render = function () {
|
|
569
|
-
var _this = this;
|
|
570
|
-
var _b;
|
|
571
|
-
var _c = this.p, modelClass = _c.modelClass, noRecordsAvailableContent = _c.noRecordsAvailableContent, noRecordsFoundContent = _c.noRecordsFoundContent;
|
|
572
|
-
var _d = this.props, collection = _d.collection, currentUser = _d.currentUser;
|
|
573
|
-
var _e = this.s, queryName = _e.queryName, querySName = _e.querySName, showFilters = _e.showFilters;
|
|
574
|
-
var _f = (0, diggerize_1.digs)(this.collection, "models", "overallCount", "qParams", "query", "result", "showNoRecordsAvailableContent", "showNoRecordsFoundContent"), models = _f.models, overallCount = _f.overallCount, qParams = _f.qParams, query = _f.query, result = _f.result, showNoRecordsAvailableContent = _f.showNoRecordsAvailableContent, showNoRecordsFoundContent = _f.showNoRecordsFoundContent;
|
|
575
|
-
if (collection && collection.args.modelClass.modelClassData().name != modelClass.modelClassData().name) {
|
|
576
|
-
throw new Error("Model class from collection '".concat(collection.args.modelClass.modelClassData().name, "' ") +
|
|
577
|
-
"didn't match model class on table: '".concat(modelClass.modelClassData().name, "'"));
|
|
333
|
+
else {
|
|
334
|
+
PaginationComponent = Paginate;
|
|
578
335
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
(0, jsx_runtime_1.jsx)(index_2.default, { currentUser: currentUser, modelClass: modelClass, queryName: queryName, querySName: querySName }), (function () {
|
|
583
|
-
if (qParams && query && result && models && !showNoRecordsAvailableContent && !showNoRecordsFoundContent) {
|
|
584
|
-
return _this.cardOrTable();
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { children: (0, jsx_runtime_1.jsx)(text_1.default, { children: _this.t(".loading_dot_dot_dit", { defaultValue: "Loading..." }) }) }));
|
|
588
|
-
}
|
|
589
|
-
})()] }));
|
|
336
|
+
}
|
|
337
|
+
const flatListStyle = {
|
|
338
|
+
overflowX: "auto"
|
|
590
339
|
};
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
340
|
+
if (styleUI) {
|
|
341
|
+
flatListStyle.border = "1px solid #dbdbdb";
|
|
342
|
+
flatListStyle.borderRadius = 5;
|
|
343
|
+
}
|
|
344
|
+
const flatList = (_jsx(TableContext.Provider, { value: this.tt.tableContextValue, children: _jsx(FlatList, { data: models, dataSet: {
|
|
345
|
+
class: classNames("api-maker--table", className),
|
|
346
|
+
cacheKey: this.s.tableSettingFullCacheKey,
|
|
347
|
+
lastUpdate: this.s.lastUpdate
|
|
348
|
+
}, extraData: this.s.lastUpdate, keyExtractor: this.tt.keyExtrator, ListHeaderComponent: ListHeaderComponent, renderItem: this.tt.renderItem, showsHorizontalScrollIndicator: true, style: flatListStyle, ...restProps }) }));
|
|
349
|
+
return (_jsxs(_Fragment, { children: [filterContent && filterCard &&
|
|
350
|
+
_jsx(Card, { className: "live-table--filter-card mb-4", children: this.filterForm() }), filterContent && !filterCard &&
|
|
351
|
+
this.filterForm(), card &&
|
|
352
|
+
_jsx(Card, { className: classNames("live-table--table-card", "mb-4", className), controls: this.tableControls(), header: headerContent, footer: this.tableFooter(), ...restProps, children: flatList }), !card && flatList, result && PaginationComponent &&
|
|
353
|
+
_jsx(PaginationComponent, { result: result }), result && paginateContent &&
|
|
354
|
+
paginateContent({ result })] }));
|
|
355
|
+
}
|
|
356
|
+
onContainerLayout = (e) => {
|
|
357
|
+
const { width } = e.nativeEvent.layout;
|
|
358
|
+
const { widths } = this.s;
|
|
359
|
+
this.setState({ width });
|
|
360
|
+
if (widths)
|
|
361
|
+
widths.tableWidth = width;
|
|
362
|
+
};
|
|
363
|
+
onLinksCreated = ({ args }) => {
|
|
364
|
+
const modelClassName = this.p.modelClass.modelClassData().name;
|
|
365
|
+
if (args.created[modelClassName]) {
|
|
366
|
+
const amountCreated = args.created[modelClassName].length;
|
|
367
|
+
this.setState((prevState) => ({
|
|
368
|
+
currentWorkplaceCount: prevState.currentWorkplaceCount + amountCreated
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
onLinksDestroyed = ({ args }) => {
|
|
373
|
+
const modelClassName = this.p.modelClass.modelClassData().name;
|
|
374
|
+
if (args.destroyed[modelClassName]) {
|
|
375
|
+
const amountDestroyed = args.destroyed[modelClassName].length;
|
|
376
|
+
this.setState((prevState) => ({
|
|
377
|
+
currentWorkplaceCount: prevState.currentWorkplaceCount - amountDestroyed
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
keyExtrator = (model) => `${this.s.tableSettingFullCacheKey}-${model.id()}`;
|
|
382
|
+
filterForm = () => {
|
|
383
|
+
const { filterFormRef, submitFilter, submitFilterDebounce } = this.tt;
|
|
384
|
+
const { filterContent, filterSubmitButton } = this.p;
|
|
385
|
+
const { queryQName } = this.s;
|
|
386
|
+
const { filterSubmitLabel } = this.props;
|
|
387
|
+
const { qParams } = digs(this.collection, "qParams");
|
|
388
|
+
return (_jsxs(Form, { className: "live-table--filter-form", formRef: filterFormRef, onSubmit: this.tt.onFilterFormSubmit, setForm: this.setStates.filterForm, children: ["s" in qParams &&
|
|
389
|
+
_jsx("input", { name: "s", type: "hidden", value: qParams.s }), filterContent({
|
|
390
|
+
onFilterChanged: submitFilter,
|
|
391
|
+
onFilterChangedWithDelay: submitFilterDebounce,
|
|
392
|
+
qParams,
|
|
393
|
+
queryQName
|
|
394
|
+
}), filterSubmitButton &&
|
|
395
|
+
_jsx("input", { className: "btn btn-primary live-table--submit-filter-button", type: "submit", style: { marginTop: "8px" }, value: filterSubmitLabel || this.t(".filter", { defaultValue: "Filter" }) })] }));
|
|
396
|
+
};
|
|
397
|
+
onFilterClicked = (e) => {
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
this.setState({ showFilters: !this.state.showFilters });
|
|
400
|
+
};
|
|
401
|
+
onPerPageChanged = (e) => {
|
|
402
|
+
const { queryName } = this.s;
|
|
403
|
+
const newPerPageValue = digg(e, "target", "value");
|
|
404
|
+
const perKey = `${queryName}_per`;
|
|
405
|
+
const paramsChange = {};
|
|
406
|
+
paramsChange[perKey] = newPerPageValue;
|
|
407
|
+
Params.changeParams(paramsChange);
|
|
408
|
+
};
|
|
409
|
+
renderItem = ({ index, item: model }) => {
|
|
410
|
+
if (!this.s.tableSettingLoaded) {
|
|
411
|
+
return (_jsx(View, { children: _jsx(Text, { children: this.t(".loading_dot_dot_dot", { defaultValue: "Loading..." }) }) }));
|
|
412
|
+
}
|
|
413
|
+
return (_jsx(ModelRow, { cacheKey: model.cacheKey(), columns: this.s.columnsToShow, columnWidths: this.columnWidths(), events: this.tt.events, index: index, model: model, table: this, tableSettingFullCacheKey: this.s.tableSettingFullCacheKey }, model.id()));
|
|
414
|
+
};
|
|
415
|
+
styleForColumn = ({ column, columnIndex, even, style, type }) => {
|
|
416
|
+
const { styleUI } = this.p;
|
|
417
|
+
const defaultStyle = {
|
|
418
|
+
justifyContent: "center",
|
|
419
|
+
padding: 8,
|
|
420
|
+
overflow: "hidden"
|
|
617
421
|
};
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
422
|
+
if (styleUI) {
|
|
423
|
+
Object.assign(defaultStyle, {
|
|
424
|
+
backgroundColor: even ? "#f5f5f5" : "#fff"
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
if (type == "actions") {
|
|
428
|
+
defaultStyle.flexDirection = "row";
|
|
429
|
+
defaultStyle.alignItems = "center";
|
|
430
|
+
if (this.tt.mdUp) {
|
|
431
|
+
defaultStyle.marginLeft = "auto";
|
|
627
432
|
}
|
|
628
433
|
else {
|
|
629
|
-
|
|
434
|
+
defaultStyle.marginRight = "auto";
|
|
630
435
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
flatListStyle.borderRadius = 5;
|
|
645
|
-
}
|
|
646
|
-
var flatList = ((0, jsx_runtime_1.jsx)(TableContext.Provider, { value: this.tt.tableContextValue, children: (0, jsx_runtime_1.jsx)(flat_list_1.default, __assign({ data: models, dataSet: {
|
|
647
|
-
class: (0, classnames_1.default)("api-maker--table", className),
|
|
648
|
-
cacheKey: this.s.tableSettingFullCacheKey,
|
|
649
|
-
lastUpdate: this.s.lastUpdate
|
|
650
|
-
}, extraData: this.s.lastUpdate, keyExtractor: this.tt.keyExtrator, ListHeaderComponent: ListHeaderComponent, renderItem: this.tt.renderItem, showsHorizontalScrollIndicator: true, style: flatListStyle }, restProps)) }));
|
|
651
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [filterContent && filterCard &&
|
|
652
|
-
(0, jsx_runtime_1.jsx)(card_1.default, { className: "live-table--filter-card mb-4", children: this.filterForm() }), filterContent && !filterCard &&
|
|
653
|
-
this.filterForm(), card &&
|
|
654
|
-
(0, jsx_runtime_1.jsx)(card_1.default, __assign({ className: (0, classnames_1.default)("live-table--table-card", "mb-4", className), controls: this.tableControls(), header: headerContent, footer: this.tableFooter() }, restProps, { children: flatList })), !card && flatList, result && PaginationComponent &&
|
|
655
|
-
(0, jsx_runtime_1.jsx)(PaginationComponent, { result: result }), result && paginateContent &&
|
|
656
|
-
paginateContent({ result: result })] }));
|
|
657
|
-
};
|
|
658
|
-
ApiMakerTable.prototype.styleForHeaderText = function () {
|
|
659
|
-
var actualStyle = { fontWeight: "bold" };
|
|
660
|
-
return actualStyle;
|
|
661
|
-
};
|
|
662
|
-
ApiMakerTable.prototype.tableControls = function () {
|
|
663
|
-
var controls = this.props.controls;
|
|
664
|
-
var showSettings = this.s.showSettings;
|
|
665
|
-
var _b = (0, diggerize_1.digs)(this.collection, "models", "qParams", "query", "result"), models = _b.models, qParams = _b.qParams, query = _b.query, result = _b.result;
|
|
666
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: this.rootViewStyle || (this.rootViewStyle = { flexDirection: "row" }), children: [controls && controls({ models: models, qParams: qParams, query: query, result: result }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { dataSet: { class: "filter-button" }, onPress: this.tt.onFilterClicked, children: (0, jsx_runtime_1.jsx)(icon_1.default, { name: "search", size: 20 }) }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [showSettings &&
|
|
667
|
-
(0, jsx_runtime_1.jsx)(index_3.default, { onRequestClose: this.tt.onRequestCloseSettings, table: this }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { dataSet: this.settingsButtonDataSet || (this.settingsButtonDataSet = { class: "settings-button" }), onPress: this.tt.onSettingsClicked, children: (0, jsx_runtime_1.jsx)(icon_1.default, { name: "gear", size: 20 }) })] })] }));
|
|
668
|
-
};
|
|
669
|
-
ApiMakerTable.prototype.tableFooter = function () {
|
|
670
|
-
var result = (0, diggerize_1.digs)(this.collection, "result").result;
|
|
671
|
-
var currentPage = result.currentPage();
|
|
672
|
-
var totalCount = result.totalCount();
|
|
673
|
-
var perPage = result.perPage();
|
|
674
|
-
var to = Math.min(currentPage * perPage, totalCount);
|
|
675
|
-
var defaultValue = "Showing %{from} to %{to} out of %{total_count} total.";
|
|
676
|
-
var from = ((currentPage - 1) * perPage) + 1;
|
|
677
|
-
if (to === 0)
|
|
678
|
-
from = 0;
|
|
679
|
-
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: this.rootViewStyle || (this.rootViewStyle = { flexDirection: "row", justifyContent: "space-between", marginTop: 10 }), children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { dataSet: this.showingCountsDataSet || (this.showingCountsDataSet = { class: "showing-counts" }), style: this.showingCountsStyle || (this.showingCountsStyle = { flexDirection: "row" }), children: [(0, jsx_runtime_1.jsx)(text_1.default, { children: this.t(".showing_from_to_out_of_total", { defaultValue: defaultValue, from: from, to: to, total_count: totalCount }) }), this.p.workplace && this.s.currentWorkplaceCount !== null &&
|
|
680
|
-
(0, jsx_runtime_1.jsx)(text_1.default, { style: this.xSelectedTextStyle || (this.xSelectedTextStyle = { marginLeft: 3 }), children: this.t(".x_selected", { defaultValue: "%{selected} selected.", selected: this.s.currentWorkplaceCount }) })] }), (0, jsx_runtime_1.jsx)(react_native_1.View, { children: (0, jsx_runtime_1.jsx)(select_1.default, { className: "per-page-select", defaultValue: perPage, onChange: this.tt.onPerPageChanged, options: paginationOptions }) })] }));
|
|
681
|
-
};
|
|
682
|
-
ApiMakerTable.prototype.className = function () {
|
|
683
|
-
var classNames = ["api-maker--table"];
|
|
684
|
-
if (this.props.className) {
|
|
685
|
-
classNames.push(this.props.className);
|
|
686
|
-
}
|
|
687
|
-
return classNames.join(" ");
|
|
436
|
+
}
|
|
437
|
+
else if (this.tt.mdUp && styleUI) {
|
|
438
|
+
defaultStyle.borderRight = "1px solid #dbdbdb";
|
|
439
|
+
}
|
|
440
|
+
const actualStyle = Object.assign(defaultStyle, style);
|
|
441
|
+
return actualStyle;
|
|
442
|
+
};
|
|
443
|
+
styleForHeader = ({ column, columnIndex, style, type }) => {
|
|
444
|
+
const { mdUp } = this.tt;
|
|
445
|
+
const defaultStyle = {
|
|
446
|
+
flexDirection: "row",
|
|
447
|
+
alignItems: "center",
|
|
448
|
+
padding: 8
|
|
688
449
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
450
|
+
if (type != "actions" && mdUp && this.p.styleUI) {
|
|
451
|
+
defaultStyle.borderRight = "1px solid #dbdbdb";
|
|
452
|
+
}
|
|
453
|
+
const actualStyle = Object.assign(defaultStyle, style);
|
|
454
|
+
return actualStyle;
|
|
455
|
+
};
|
|
456
|
+
styleForHeaderText() {
|
|
457
|
+
const actualStyle = { fontWeight: "bold" };
|
|
458
|
+
return actualStyle;
|
|
459
|
+
}
|
|
460
|
+
styleForRow = ({ even } = {}) => {
|
|
461
|
+
const actualStyle = {
|
|
462
|
+
flex: 1,
|
|
463
|
+
alignItems: "stretch"
|
|
700
464
|
};
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
return props;
|
|
465
|
+
if (even && this.p.styleUI) {
|
|
466
|
+
actualStyle.backgroundColor = "#f5f5f5";
|
|
467
|
+
}
|
|
468
|
+
return actualStyle;
|
|
469
|
+
};
|
|
470
|
+
styleForRowHeader = () => {
|
|
471
|
+
const actualStyle = {
|
|
472
|
+
flex: 1,
|
|
473
|
+
alignItems: "stretch"
|
|
712
474
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
475
|
+
return actualStyle;
|
|
476
|
+
};
|
|
477
|
+
tableControls() {
|
|
478
|
+
const { controls } = this.props;
|
|
479
|
+
const { showSettings } = this.s;
|
|
480
|
+
const { models, qParams, query, result } = digs(this.collection, "models", "qParams", "query", "result");
|
|
481
|
+
return (_jsxs(View, { style: this.rootViewStyle ||= { flexDirection: "row" }, children: [controls && controls({ models, qParams, query, result }), _jsx(Pressable, { dataSet: { class: "filter-button" }, onPress: this.tt.onFilterClicked, children: _jsx(Icon, { name: "search", size: 20 }) }), _jsxs(View, { children: [showSettings &&
|
|
482
|
+
_jsx(Settings, { onRequestClose: this.tt.onRequestCloseSettings, table: this }), _jsx(Pressable, { dataSet: this.settingsButtonDataSet ||= { class: "settings-button" }, onPress: this.tt.onSettingsClicked, children: _jsx(Icon, { name: "gear", size: 20 }) })] })] }));
|
|
483
|
+
}
|
|
484
|
+
tableFooter() {
|
|
485
|
+
const { result } = digs(this.collection, "result");
|
|
486
|
+
const currentPage = result.currentPage();
|
|
487
|
+
const totalCount = result.totalCount();
|
|
488
|
+
const perPage = result.perPage();
|
|
489
|
+
const to = Math.min(currentPage * perPage, totalCount);
|
|
490
|
+
const defaultValue = "Showing %{from} to %{to} out of %{total_count} total.";
|
|
491
|
+
let from = ((currentPage - 1) * perPage) + 1;
|
|
492
|
+
if (to === 0)
|
|
493
|
+
from = 0;
|
|
494
|
+
return (_jsxs(View, { style: this.rootViewStyle ||= { flexDirection: "row", justifyContent: "space-between", marginTop: 10 }, children: [_jsxs(View, { dataSet: this.showingCountsDataSet ||= { class: "showing-counts" }, style: this.showingCountsStyle ||= { flexDirection: "row" }, children: [_jsx(Text, { children: this.t(".showing_from_to_out_of_total", { defaultValue, from, to, total_count: totalCount }) }), this.p.workplace && this.s.currentWorkplaceCount !== null &&
|
|
495
|
+
_jsx(Text, { style: this.xSelectedTextStyle ||= { marginLeft: 3 }, children: this.t(".x_selected", { defaultValue: "%{selected} selected.", selected: this.s.currentWorkplaceCount }) })] }), _jsx(View, { children: _jsx(Select, { className: "per-page-select", defaultValue: perPage, onChange: this.tt.onPerPageChanged, options: paginationOptions }) })] }));
|
|
496
|
+
}
|
|
497
|
+
className() {
|
|
498
|
+
const classNames = ["api-maker--table"];
|
|
499
|
+
if (this.props.className) {
|
|
500
|
+
classNames.push(this.props.className);
|
|
501
|
+
}
|
|
502
|
+
return classNames.join(" ");
|
|
503
|
+
}
|
|
504
|
+
columnProps(column) {
|
|
505
|
+
const props = {};
|
|
506
|
+
if (column.textCenter) {
|
|
507
|
+
props.style ||= {};
|
|
508
|
+
props.style.textAlign = "center";
|
|
509
|
+
}
|
|
510
|
+
if (column.textRight) {
|
|
511
|
+
props.style ||= {};
|
|
512
|
+
props.style.textAlign = "right";
|
|
513
|
+
}
|
|
514
|
+
return props;
|
|
515
|
+
}
|
|
516
|
+
headerProps(column) {
|
|
517
|
+
const props = {};
|
|
518
|
+
if (column.textCenter) {
|
|
519
|
+
props.style ||= {};
|
|
520
|
+
props.style.justifyContent = "center";
|
|
521
|
+
}
|
|
522
|
+
if (column.textRight) {
|
|
523
|
+
props.style ||= {};
|
|
524
|
+
props.style.justifyContent = "end";
|
|
525
|
+
}
|
|
526
|
+
return props;
|
|
527
|
+
}
|
|
528
|
+
columnWidths() {
|
|
529
|
+
const columnWidths = {};
|
|
530
|
+
for (const column of this.s.preparedColumns) {
|
|
531
|
+
columnWidths[column.tableSettingColumn.identifier()] = column.width;
|
|
532
|
+
}
|
|
533
|
+
return columnWidths;
|
|
534
|
+
}
|
|
535
|
+
headersContentFromColumns = () => {
|
|
536
|
+
return (_jsx(DraggableSort, { data: this.s.columnsToShow, events: this.tt.draggableSortEvents, horizontal: true, keyExtractor: this.tt.dragListkeyExtractor, onItemMoved: this.tt.onItemMoved, onReordered: this.tt.onReordered, renderItem: this.tt.dragListRenderItemContent }));
|
|
537
|
+
};
|
|
538
|
+
dragListCacheKeyExtractor = (item) => `${item.tableSettingColumn.identifier()}-${this.s.resizing}`;
|
|
539
|
+
dragListkeyExtractor = (item) => item.tableSettingColumn.identifier();
|
|
540
|
+
onItemMoved = ({ animationArgs, itemIndex, x, y }) => {
|
|
541
|
+
const animatedPosition = digg(this, "s", "columnsToShow", itemIndex, "animatedPosition");
|
|
542
|
+
if (animationArgs) {
|
|
543
|
+
Animated.timing(animatedPosition, animationArgs).start();
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
animatedPosition.setValue({ x, y });
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
onReordered = async ({ fromItem, fromPosition, toItem, toPosition }) => {
|
|
550
|
+
if (fromPosition == toPosition)
|
|
551
|
+
return; // Only do requests and queries if changed
|
|
552
|
+
const TableSettingColumn = fromItem.tableSettingColumn.constructor;
|
|
553
|
+
const toColumn = await TableSettingColumn.find(toItem.tableSettingColumn.id()); // Need to load latest position because ActsAsList might have changed it
|
|
554
|
+
await fromItem.tableSettingColumn.update({ position: toColumn.position() });
|
|
555
|
+
};
|
|
556
|
+
dragListRenderItemContent = ({ isActive, item, touchProps }) => {
|
|
557
|
+
const { animatedWidth, animatedZIndex, column, tableSettingColumn } = item;
|
|
558
|
+
return (_jsx(HeaderColumn, { active: isActive, animatedWidth: animatedWidth, animatedZIndex: animatedZIndex, column: column, resizing: this.s.resizing, table: this, tableSettingColumn: tableSettingColumn, touchProps: touchProps, widths: this.s.widths }, tableSettingColumn.identifier()));
|
|
559
|
+
};
|
|
560
|
+
headerClassNameForColumn(column) {
|
|
561
|
+
const classNames = [];
|
|
562
|
+
if (column.commonProps && column.commonProps.className)
|
|
563
|
+
classNames.push(column.commonProps.className);
|
|
564
|
+
if (column.headerProps && column.headerProps.className)
|
|
565
|
+
classNames.push(column.headerProps.className);
|
|
566
|
+
return classNames;
|
|
567
|
+
}
|
|
568
|
+
headerLabelForColumn(column) {
|
|
569
|
+
const { modelClass } = this.p;
|
|
570
|
+
if ("label" in column) {
|
|
571
|
+
if (typeof column.label == "function") {
|
|
572
|
+
return column.label();
|
|
718
573
|
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
ApiMakerTable.prototype.headerClassNameForColumn = function (column) {
|
|
722
|
-
var classNames = [];
|
|
723
|
-
if (column.commonProps && column.commonProps.className)
|
|
724
|
-
classNames.push(column.commonProps.className);
|
|
725
|
-
if (column.headerProps && column.headerProps.className)
|
|
726
|
-
classNames.push(column.headerProps.className);
|
|
727
|
-
return classNames;
|
|
728
|
-
};
|
|
729
|
-
ApiMakerTable.prototype.headerLabelForColumn = function (column) {
|
|
730
|
-
var modelClass = this.p.modelClass;
|
|
731
|
-
if ("label" in column) {
|
|
732
|
-
if (typeof column.label == "function") {
|
|
733
|
-
return column.label();
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
return column.label;
|
|
737
|
-
}
|
|
574
|
+
else {
|
|
575
|
+
return column.label;
|
|
738
576
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
for (var _i = 0, _b = column.path; _i < _b.length; _i++) {
|
|
748
|
-
var pathPart = _b[_i];
|
|
749
|
-
_loop_1(pathPart);
|
|
750
|
-
}
|
|
577
|
+
}
|
|
578
|
+
let currentModelClass = modelClass;
|
|
579
|
+
// Calculate current model class through path
|
|
580
|
+
if (column.path) {
|
|
581
|
+
for (const pathPart of column.path) {
|
|
582
|
+
const relationships = digg(currentModelClass.modelClassData(), "relationships");
|
|
583
|
+
const relationship = relationships.find((relationshipInArray) => relationshipInArray.name == inflection.underscore(pathPart));
|
|
584
|
+
currentModelClass = modelClassRequire(digg(relationship, "resource_name"));
|
|
751
585
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
appHistory
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
columns: prop_types_1.default.oneOfType([prop_types_1.default.array, prop_types_1.default.func]),
|
|
779
|
-
controls: prop_types_1.default.func,
|
|
780
|
-
currentUser: prop_types_1.default.object,
|
|
781
|
-
defaultDateFormatName: prop_types_1.default.string,
|
|
782
|
-
defaultDateTimeFormatName: prop_types_1.default.string,
|
|
783
|
-
defaultParams: prop_types_1.default.object,
|
|
784
|
-
destroyEnabled: prop_types_1.default.bool.isRequired,
|
|
785
|
-
destroyMessage: prop_types_1.default.string,
|
|
786
|
-
editModelPath: prop_types_1.default.func,
|
|
787
|
-
filterCard: prop_types_1.default.bool.isRequired,
|
|
788
|
-
filterContent: prop_types_1.default.func,
|
|
789
|
-
filterSubmitLabel: prop_types_1.default.any,
|
|
790
|
-
groupBy: prop_types_1.default.array,
|
|
791
|
-
header: prop_types_1.default.oneOfType([prop_types_1.default.func, prop_types_1.default.string]),
|
|
792
|
-
identifier: prop_types_1.default.string,
|
|
793
|
-
modelClass: prop_types_1.default.func.isRequired,
|
|
794
|
-
noRecordsAvailableContent: prop_types_1.default.func,
|
|
795
|
-
noRecordsFoundContent: prop_types_1.default.func,
|
|
796
|
-
onModelsLoaded: prop_types_1.default.func,
|
|
797
|
-
paginateContent: prop_types_1.default.func,
|
|
798
|
-
paginationComponent: prop_types_1.default.func,
|
|
799
|
-
preloads: prop_types_1.default.array.isRequired,
|
|
800
|
-
queryMethod: prop_types_1.default.func,
|
|
801
|
-
queryName: prop_types_1.default.string,
|
|
802
|
-
select: prop_types_1.default.object,
|
|
803
|
-
selectColumns: prop_types_1.default.object,
|
|
804
|
-
styles: prop_types_1.default.object,
|
|
805
|
-
styleUI: prop_types_1.default.bool.isRequired,
|
|
806
|
-
viewModelPath: prop_types_1.default.func,
|
|
807
|
-
workplace: prop_types_1.default.bool.isRequired
|
|
808
|
-
},
|
|
809
|
-
_a)));
|
|
586
|
+
}
|
|
587
|
+
if (column.attribute)
|
|
588
|
+
return currentModelClass.humanAttributeName(column.attribute);
|
|
589
|
+
throw new Error("No 'label' or 'attribute' was given");
|
|
590
|
+
}
|
|
591
|
+
onFilterFormSubmit = () => this.submitFilter();
|
|
592
|
+
onRequestCloseSettings = () => this.setState({ showSettings: false });
|
|
593
|
+
onSettingsClicked = (e) => {
|
|
594
|
+
e.preventDefault();
|
|
595
|
+
this.setState({ showSettings: !this.s.showSettings });
|
|
596
|
+
};
|
|
597
|
+
submitFilter = () => {
|
|
598
|
+
const { appHistory } = this.props;
|
|
599
|
+
const { queryQName } = this.s;
|
|
600
|
+
const changeParamsParams = {};
|
|
601
|
+
const qParams = this.s.filterForm.asObject();
|
|
602
|
+
if (Platform.OS == "web") {
|
|
603
|
+
const filterForm = digg(this.tt.filterFormRef, "current");
|
|
604
|
+
const navtiveFormParams = Params.serializeForm(filterForm);
|
|
605
|
+
incorporate(qParams, navtiveFormParams);
|
|
606
|
+
}
|
|
607
|
+
changeParamsParams[queryQName] = JSON.stringify(qParams);
|
|
608
|
+
Params.changeParams(changeParamsParams, { appHistory });
|
|
609
|
+
};
|
|
610
|
+
submitFilterDebounce = debounce(this.tt.submitFilter);
|
|
611
|
+
}));
|
|
810
612
|
//# sourceMappingURL=table.js.map
|