@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
|
@@ -1,493 +1,290 @@
|
|
|
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
|
-
|
|
33
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
-
var ownKeys = function(o) {
|
|
35
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
-
var ar = [];
|
|
37
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
return ownKeys(o);
|
|
41
|
-
};
|
|
42
|
-
return function (mod) {
|
|
43
|
-
if (mod && mod.__esModule) return mod;
|
|
44
|
-
var result = {};
|
|
45
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
-
__setModuleDefault(result, mod);
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
})();
|
|
50
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
51
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
52
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
53
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
54
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
55
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
56
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import { ActivityIndicator, View } from "react-native";
|
|
4
|
+
import AttributeElement from "./attribute-element";
|
|
5
|
+
import BaseComponent from "../../base-component.js";
|
|
6
|
+
import Button from "../../utils/button";
|
|
7
|
+
import Card from "../../utils/card";
|
|
8
|
+
import { digg, digs } from "diggerize";
|
|
9
|
+
import * as inflection from "inflection";
|
|
10
|
+
import { Form } from "../../form";
|
|
11
|
+
import Header from "../../utils/header";
|
|
12
|
+
import Input from "../../inputs/input";
|
|
13
|
+
import memo from "set-state-compare/build/memo.js";
|
|
14
|
+
import Params from "../../params.js";
|
|
15
|
+
import PropTypes from "prop-types";
|
|
16
|
+
import PropTypesExact from "prop-types-exact";
|
|
17
|
+
import React from "react";
|
|
18
|
+
import ReflectionElement from "./reflection-element";
|
|
19
|
+
import ScopeElement from "./scope-element";
|
|
20
|
+
import Select from "../../inputs/select";
|
|
21
|
+
import Services from "../../services.js";
|
|
22
|
+
import { shapeComponent } from "set-state-compare/build/shape-component.js";
|
|
23
|
+
import Text from "../../utils/text";
|
|
24
|
+
import useBreakpoint from "../../use-breakpoint.js";
|
|
25
|
+
import useI18n from "i18n-on-steroids/src/use-i18n.mjs";
|
|
26
|
+
export default memo(shapeComponent(class ApiMakerTableFiltersFilterForm extends BaseComponent {
|
|
27
|
+
static propTypes = PropTypesExact({
|
|
28
|
+
filter: PropTypes.object,
|
|
29
|
+
modelClass: PropTypes.func.isRequired,
|
|
30
|
+
onApplyClicked: PropTypes.func.isRequired,
|
|
31
|
+
onRequestClose: PropTypes.func.isRequired,
|
|
32
|
+
querySearchName: PropTypes.string.isRequired
|
|
57
33
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
34
|
+
setup() {
|
|
35
|
+
const { t } = useI18n({ namespace: "js.api_maker.table.filters.filter_form" });
|
|
36
|
+
this.useStates({
|
|
37
|
+
associations: null,
|
|
38
|
+
attribute: undefined,
|
|
39
|
+
actualCurrentModelClass: () => ({ modelClass: this.p.modelClass }),
|
|
40
|
+
loading: 0,
|
|
41
|
+
modelClassName: digg(this.p.modelClass.modelClassData(), "className"),
|
|
42
|
+
path: [],
|
|
43
|
+
predicate: undefined,
|
|
44
|
+
predicates: undefined,
|
|
45
|
+
ransackableAttributes: undefined,
|
|
46
|
+
ransackableScopes: undefined,
|
|
47
|
+
scope: this.props.filter.sc,
|
|
48
|
+
value: this.props.filter.v
|
|
49
|
+
});
|
|
50
|
+
this.setInstance({
|
|
51
|
+
breakpoint: useBreakpoint(),
|
|
52
|
+
t,
|
|
53
|
+
valueInputRef: useRef(),
|
|
54
|
+
});
|
|
55
|
+
useMemo(() => {
|
|
56
|
+
this.loadRansackPredicates();
|
|
57
|
+
if (this.props.filter.v) {
|
|
58
|
+
this.loadInitialValuesWithLoadingIndicator();
|
|
80
59
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
}, []);
|
|
61
|
+
useMemo(() => {
|
|
62
|
+
this.loadAssociations();
|
|
63
|
+
}, [this.s.modelClassName]);
|
|
64
|
+
}
|
|
65
|
+
currentModelClass = () => digg(this.s.actualCurrentModelClass, "modelClass");
|
|
66
|
+
parseAssociationData(result) {
|
|
67
|
+
const associations = result.associations.map(({ human_name, model_class_name, reflection_name, resource }) => ({
|
|
68
|
+
humanName: human_name,
|
|
69
|
+
modelClassName: model_class_name,
|
|
70
|
+
reflectionName: inflection.camelize(reflection_name, true),
|
|
71
|
+
resource
|
|
72
|
+
}));
|
|
73
|
+
const ransackableAttributes = digg(result, "ransackable_attributes").map(({ attribute_name: attributeName, human_name: humanName }) => ({
|
|
74
|
+
attributeName, humanName
|
|
75
|
+
}));
|
|
76
|
+
const ransackableScopes = digg(result, "ransackable_scopes");
|
|
77
|
+
return { associations, ransackableAttributes, ransackableScopes };
|
|
84
78
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var react_native_1 = require("react-native");
|
|
94
|
-
var attribute_element_1 = __importDefault(require("./attribute-element"));
|
|
95
|
-
var base_component_js_1 = __importDefault(require("../../base-component.js"));
|
|
96
|
-
var button_1 = __importDefault(require("../../utils/button"));
|
|
97
|
-
var card_1 = __importDefault(require("../../utils/card"));
|
|
98
|
-
var diggerize_1 = require("diggerize");
|
|
99
|
-
var inflection = __importStar(require("inflection"));
|
|
100
|
-
var form_1 = require("../../form");
|
|
101
|
-
var header_1 = __importDefault(require("../../utils/header"));
|
|
102
|
-
var input_1 = __importDefault(require("../../inputs/input"));
|
|
103
|
-
var memo_js_1 = __importDefault(require("set-state-compare/build/memo.js"));
|
|
104
|
-
var params_js_1 = __importDefault(require("../../params.js"));
|
|
105
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
106
|
-
var prop_types_exact_1 = __importDefault(require("prop-types-exact"));
|
|
107
|
-
var react_2 = __importDefault(require("react"));
|
|
108
|
-
var reflection_element_1 = __importDefault(require("./reflection-element"));
|
|
109
|
-
var scope_element_1 = __importDefault(require("./scope-element"));
|
|
110
|
-
var select_1 = __importDefault(require("../../inputs/select"));
|
|
111
|
-
var services_js_1 = __importDefault(require("../../services.js"));
|
|
112
|
-
var shape_component_js_1 = require("set-state-compare/build/shape-component.js");
|
|
113
|
-
var text_1 = __importDefault(require("../../utils/text"));
|
|
114
|
-
var use_breakpoint_js_1 = __importDefault(require("../../use-breakpoint.js"));
|
|
115
|
-
var use_i18n_mjs_1 = __importDefault(require("i18n-on-steroids/src/use-i18n.mjs"));
|
|
116
|
-
exports.default = (0, memo_js_1.default)((0, shape_component_js_1.shapeComponent)((_a = /** @class */ (function (_super) {
|
|
117
|
-
__extends(ApiMakerTableFiltersFilterForm, _super);
|
|
118
|
-
function ApiMakerTableFiltersFilterForm() {
|
|
119
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
120
|
-
_this.currentModelClass = function () { return (0, diggerize_1.digg)(_this.s.actualCurrentModelClass, "modelClass"); };
|
|
121
|
-
_this.decreaseLoading = function () { return _this.setState(function (prevState) { return ({ loading: prevState.loading - 1 }); }); };
|
|
122
|
-
_this.increaseLoading = function () { return _this.setState(function (prevState) { return ({ loading: prevState.loading + 1 }); }); };
|
|
123
|
-
_this.onAttributeClicked = function (_b) {
|
|
124
|
-
var attribute = _b.attribute;
|
|
125
|
-
_this.setState({
|
|
126
|
-
attribute: attribute,
|
|
127
|
-
scope: undefined
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
_this.onPredicateChanged = function (e) {
|
|
131
|
-
var chosenPredicateName = (0, diggerize_1.digg)(e, "target", "value");
|
|
132
|
-
var predicate = _this.s.predicates.find(function (predicate) { return predicate.name == chosenPredicateName; });
|
|
133
|
-
_this.setState({ predicate: predicate });
|
|
134
|
-
};
|
|
135
|
-
_this.onReflectionClicked = function (_b) {
|
|
136
|
-
var reflection = _b.reflection;
|
|
137
|
-
var newPath = _this.s.path.concat([reflection]);
|
|
138
|
-
_this.setState({
|
|
139
|
-
associations: null,
|
|
140
|
-
attribute: undefined,
|
|
141
|
-
actualCurrentModelClass: { modelClass: (0, diggerize_1.digg)(reflection, "resource") },
|
|
142
|
-
modelClassName: (0, diggerize_1.digg)(reflection, "modelClassName"),
|
|
143
|
-
path: newPath,
|
|
144
|
-
predicate: undefined
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
_this.onScopeClicked = function (_b) {
|
|
148
|
-
var scope = _b.scope;
|
|
149
|
-
_this.setState({
|
|
150
|
-
attribute: undefined,
|
|
151
|
-
predicate: undefined,
|
|
152
|
-
scope: scope
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
_this.onSubmit = function () {
|
|
156
|
-
var _b = _this.p, filter = _b.filter, querySearchName = _b.querySearchName;
|
|
157
|
-
var _c = _this.s, attribute = _c.attribute, path = _c.path, predicate = _c.predicate, scope = _c.scope;
|
|
158
|
-
var filterIndex = (0, diggerize_1.digs)(filter, "filterIndex").filterIndex;
|
|
159
|
-
var searchParams = params_js_1.default.parse()[querySearchName] || {};
|
|
160
|
-
var value = (0, diggerize_1.digg)(_this.tt.valueInputRef, "current", "value");
|
|
161
|
-
var p = path.map(function (reflection) { return inflection.underscore(reflection.reflectionName); });
|
|
162
|
-
var newSearchParams = {
|
|
163
|
-
p: p,
|
|
164
|
-
v: value
|
|
165
|
-
};
|
|
166
|
-
if (attribute) {
|
|
167
|
-
newSearchParams.a = (0, diggerize_1.digg)(attribute, "attributeName");
|
|
168
|
-
newSearchParams.pre = (0, diggerize_1.digg)(predicate, "name");
|
|
169
|
-
}
|
|
170
|
-
else if (scope) {
|
|
171
|
-
newSearchParams.sc = scope;
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
throw new Error("Dont know if should search for attribute or scope?");
|
|
175
|
-
}
|
|
176
|
-
searchParams[filterIndex] = JSON.stringify(newSearchParams);
|
|
177
|
-
var newParams = {};
|
|
178
|
-
newParams[querySearchName] = searchParams;
|
|
179
|
-
params_js_1.default.changeParams(newParams);
|
|
180
|
-
_this.props.onApplyClicked();
|
|
181
|
-
};
|
|
182
|
-
return _this;
|
|
79
|
+
async loadAssociations() {
|
|
80
|
+
this.increaseLoading();
|
|
81
|
+
try {
|
|
82
|
+
if (!this.s.modelClassName)
|
|
83
|
+
throw new Error("'modelClassName' not set in state");
|
|
84
|
+
const result = await Services.current().sendRequest("Models::Associations", { model_class_name: this.s.modelClassName });
|
|
85
|
+
const { associations, ransackableAttributes, ransackableScopes } = this.parseAssociationData(result);
|
|
86
|
+
this.setState({ associations, ransackableAttributes, ransackableScopes });
|
|
183
87
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}, [this.s.modelClassName]);
|
|
215
|
-
};
|
|
216
|
-
ApiMakerTableFiltersFilterForm.prototype.parseAssociationData = function (result) {
|
|
217
|
-
var associations = result.associations.map(function (_b) {
|
|
218
|
-
var human_name = _b.human_name, model_class_name = _b.model_class_name, reflection_name = _b.reflection_name, resource = _b.resource;
|
|
219
|
-
return ({
|
|
220
|
-
humanName: human_name,
|
|
221
|
-
modelClassName: model_class_name,
|
|
222
|
-
reflectionName: inflection.camelize(reflection_name, true),
|
|
223
|
-
resource: resource
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
var ransackableAttributes = (0, diggerize_1.digg)(result, "ransackable_attributes").map(function (_b) {
|
|
227
|
-
var attributeName = _b.attribute_name, humanName = _b.human_name;
|
|
228
|
-
return ({
|
|
229
|
-
attributeName: attributeName,
|
|
230
|
-
humanName: humanName
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
var ransackableScopes = (0, diggerize_1.digg)(result, "ransackable_scopes");
|
|
234
|
-
return { associations: associations, ransackableAttributes: ransackableAttributes, ransackableScopes: ransackableScopes };
|
|
235
|
-
};
|
|
236
|
-
ApiMakerTableFiltersFilterForm.prototype.loadAssociations = function () {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
-
var result, _b, associations, ransackableAttributes, ransackableScopes;
|
|
239
|
-
return __generator(this, function (_c) {
|
|
240
|
-
switch (_c.label) {
|
|
241
|
-
case 0:
|
|
242
|
-
this.increaseLoading();
|
|
243
|
-
_c.label = 1;
|
|
244
|
-
case 1:
|
|
245
|
-
_c.trys.push([1, , 3, 4]);
|
|
246
|
-
if (!this.s.modelClassName)
|
|
247
|
-
throw new Error("'modelClassName' not set in state");
|
|
248
|
-
return [4 /*yield*/, services_js_1.default.current().sendRequest("Models::Associations", { model_class_name: this.s.modelClassName })];
|
|
249
|
-
case 2:
|
|
250
|
-
result = _c.sent();
|
|
251
|
-
_b = this.parseAssociationData(result), associations = _b.associations, ransackableAttributes = _b.ransackableAttributes, ransackableScopes = _b.ransackableScopes;
|
|
252
|
-
this.setState({ associations: associations, ransackableAttributes: ransackableAttributes, ransackableScopes: ransackableScopes });
|
|
253
|
-
return [3 /*break*/, 4];
|
|
254
|
-
case 3:
|
|
255
|
-
this.decreaseLoading();
|
|
256
|
-
return [7 /*endfinally*/];
|
|
257
|
-
case 4: return [2 /*return*/];
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
ApiMakerTableFiltersFilterForm.prototype.loadInitialValuesWithLoadingIndicator = function () {
|
|
263
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
-
return __generator(this, function (_b) {
|
|
265
|
-
switch (_b.label) {
|
|
266
|
-
case 0:
|
|
267
|
-
_b.trys.push([0, , 2, 3]);
|
|
268
|
-
this.increaseLoading();
|
|
269
|
-
return [4 /*yield*/, this.loadInitialValues()];
|
|
270
|
-
case 1:
|
|
271
|
-
_b.sent();
|
|
272
|
-
return [3 /*break*/, 3];
|
|
273
|
-
case 2:
|
|
274
|
-
this.decreaseLoading();
|
|
275
|
-
return [7 /*endfinally*/];
|
|
276
|
-
case 3: return [2 /*return*/];
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
ApiMakerTableFiltersFilterForm.prototype.loadInitialValues = function () {
|
|
282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var result, data, modelClassName, path, _loop_1, this_1, _i, _b, pathPart, ransackableAttributes, attribute, ransackableAttribute;
|
|
284
|
-
return __generator(this, function (_c) {
|
|
285
|
-
switch (_c.label) {
|
|
286
|
-
case 0:
|
|
287
|
-
if (!this.s.modelClassName)
|
|
288
|
-
throw new Error("'modelClassName' not set in state");
|
|
289
|
-
return [4 /*yield*/, services_js_1.default.current().sendRequest("Models::Associations", { model_class_name: this.s.modelClassName })];
|
|
290
|
-
case 1:
|
|
291
|
-
result = _c.sent();
|
|
292
|
-
data = this.parseAssociationData(result);
|
|
293
|
-
modelClassName = this.s.modelClassName;
|
|
294
|
-
path = [];
|
|
295
|
-
_loop_1 = function (pathPart) {
|
|
296
|
-
var reflection, pathNames;
|
|
297
|
-
return __generator(this, function (_d) {
|
|
298
|
-
switch (_d.label) {
|
|
299
|
-
case 0:
|
|
300
|
-
reflection = data.associations.find(function (association) { return (0, diggerize_1.digg)(association, "reflectionName") == inflection.camelize(pathPart, true); });
|
|
301
|
-
if (!reflection)
|
|
302
|
-
throw new Error("Couldn't find association by that name ".concat(this_1.s.modelClassName, "#").concat(pathPart));
|
|
303
|
-
modelClassName = (0, diggerize_1.digg)(reflection, "modelClassName");
|
|
304
|
-
if (!modelClassName) {
|
|
305
|
-
pathNames = path.map(function (pathPart) { return pathPart.name(); }).join(".");
|
|
306
|
-
throw new Error("No model class name from ".concat(pathNames, ".").concat(reflection.name()));
|
|
307
|
-
}
|
|
308
|
-
return [4 /*yield*/, services_js_1.default.current().sendRequest("Models::Associations", { model_class_name: modelClassName })];
|
|
309
|
-
case 1:
|
|
310
|
-
result = _d.sent();
|
|
311
|
-
data = this_1.parseAssociationData(result);
|
|
312
|
-
path.push(reflection);
|
|
313
|
-
return [2 /*return*/];
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
this_1 = this;
|
|
318
|
-
_i = 0, _b = this.props.filter.p;
|
|
319
|
-
_c.label = 2;
|
|
320
|
-
case 2:
|
|
321
|
-
if (!(_i < _b.length)) return [3 /*break*/, 5];
|
|
322
|
-
pathPart = _b[_i];
|
|
323
|
-
return [5 /*yield**/, _loop_1(pathPart)];
|
|
324
|
-
case 3:
|
|
325
|
-
_c.sent();
|
|
326
|
-
_c.label = 4;
|
|
327
|
-
case 4:
|
|
328
|
-
_i++;
|
|
329
|
-
return [3 /*break*/, 2];
|
|
330
|
-
case 5:
|
|
331
|
-
ransackableAttributes = data.ransackableAttributes;
|
|
332
|
-
attribute = this.p.filter.a;
|
|
333
|
-
ransackableAttribute = ransackableAttributes.find(function (ransackableAttribute) { return (0, diggerize_1.digg)(ransackableAttribute, "attributeName") == attribute; });
|
|
334
|
-
this.setState({ attribute: ransackableAttribute, modelClassName: modelClassName, path: path });
|
|
335
|
-
return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
ApiMakerTableFiltersFilterForm.prototype.loadRansackPredicates = function () {
|
|
341
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
-
var response, predicates, currentPredicate;
|
|
343
|
-
var _this = this;
|
|
344
|
-
return __generator(this, function (_b) {
|
|
345
|
-
switch (_b.label) {
|
|
346
|
-
case 0:
|
|
347
|
-
this.increaseLoading();
|
|
348
|
-
_b.label = 1;
|
|
349
|
-
case 1:
|
|
350
|
-
_b.trys.push([1, , 3, 4]);
|
|
351
|
-
return [4 /*yield*/, services_js_1.default.current().sendRequest("Ransack::Predicates")];
|
|
352
|
-
case 2:
|
|
353
|
-
response = _b.sent();
|
|
354
|
-
predicates = (0, diggerize_1.digg)(response, "predicates");
|
|
355
|
-
currentPredicate = void 0;
|
|
356
|
-
if (this.props.filter.pre) {
|
|
357
|
-
currentPredicate = predicates.find(function (predicate) { return predicate.name == _this.props.filter.pre; });
|
|
358
|
-
}
|
|
359
|
-
this.setState({
|
|
360
|
-
predicate: currentPredicate,
|
|
361
|
-
predicates: predicates
|
|
362
|
-
});
|
|
363
|
-
return [3 /*break*/, 4];
|
|
364
|
-
case 3:
|
|
365
|
-
this.decreaseLoading();
|
|
366
|
-
return [7 /*endfinally*/];
|
|
367
|
-
case 4: return [2 /*return*/];
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
ApiMakerTableFiltersFilterForm.prototype.render = function () {
|
|
373
|
-
var _this = this;
|
|
374
|
-
var _b, _c;
|
|
375
|
-
var _d = this.tt, breakpoint = _d.breakpoint, t = _d.t, valueInputRef = _d.valueInputRef;
|
|
376
|
-
var _e = this.s, attribute = _e.attribute, path = _e.path, predicate = _e.predicate, predicates = _e.predicates, scope = _e.scope, value = _e.value;
|
|
377
|
-
var mdUp = breakpoint.mdUp;
|
|
378
|
-
var submitEnabled = false;
|
|
379
|
-
if (attribute && predicate) {
|
|
380
|
-
submitEnabled = true;
|
|
381
|
-
}
|
|
382
|
-
else if (scope) {
|
|
383
|
-
submitEnabled = true;
|
|
88
|
+
finally {
|
|
89
|
+
this.decreaseLoading();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
decreaseLoading = () => this.setState((prevState) => ({ loading: prevState.loading - 1 }));
|
|
93
|
+
increaseLoading = () => this.setState((prevState) => ({ loading: prevState.loading + 1 }));
|
|
94
|
+
async loadInitialValuesWithLoadingIndicator() {
|
|
95
|
+
try {
|
|
96
|
+
this.increaseLoading();
|
|
97
|
+
await this.loadInitialValues();
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
this.decreaseLoading();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async loadInitialValues() {
|
|
104
|
+
if (!this.s.modelClassName)
|
|
105
|
+
throw new Error("'modelClassName' not set in state");
|
|
106
|
+
let result = await Services.current().sendRequest("Models::Associations", { model_class_name: this.s.modelClassName });
|
|
107
|
+
let data = this.parseAssociationData(result);
|
|
108
|
+
let modelClassName = this.s.modelClassName;
|
|
109
|
+
const path = [];
|
|
110
|
+
for (const pathPart of this.props.filter.p) {
|
|
111
|
+
const reflection = data.associations.find((association) => digg(association, "reflectionName") == inflection.camelize(pathPart, true));
|
|
112
|
+
if (!reflection)
|
|
113
|
+
throw new Error(`Couldn't find association by that name ${this.s.modelClassName}#${pathPart}`);
|
|
114
|
+
modelClassName = digg(reflection, "modelClassName");
|
|
115
|
+
if (!modelClassName) {
|
|
116
|
+
const pathNames = path.map((pathPart) => pathPart.name()).join(".");
|
|
117
|
+
throw new Error(`No model class name from ${pathNames}.${reflection.name()}`);
|
|
384
118
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
(0, jsx_runtime_1.jsx)(input_1.default, { className: "value-input", defaultValue: value, inputRef: valueInputRef }) })] })] }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flexDirection: "row", justifyContent: "end", marginTop: 10 }, children: [(0, jsx_runtime_1.jsx)(button_1.default, { danger: true, icon: "remove", label: t(".cancel", { defaultValue: "Cancel" }), onPress: this.p.onRequestClose, pressableProps: this.cancelButtonPressableProps || (this.cancelButtonPressableProps = {
|
|
403
|
-
marginRight: 5
|
|
404
|
-
}) }), (0, jsx_runtime_1.jsx)(button_1.default, { disabled: !submitEnabled, icon: "check", label: t(".apply", { defaultValue: "Apply" }), pressableProps: this.appleButtonPressableProps || (this.appleButtonPressableProps = {
|
|
405
|
-
style: { marginLeft: 5 },
|
|
406
|
-
testID: "apply-filter-button"
|
|
407
|
-
}), submit: true })] })] }), this.s.loading > 0 &&
|
|
408
|
-
(0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
409
|
-
alignItems: "center",
|
|
410
|
-
justifyContent: "center",
|
|
411
|
-
position: "absolute",
|
|
412
|
-
width: "100%",
|
|
413
|
-
height: "100%"
|
|
414
|
-
}, children: (0, jsx_runtime_1.jsx)(react_native_1.ActivityIndicator, { size: "large" }) })] }));
|
|
415
|
-
};
|
|
416
|
-
ApiMakerTableFiltersFilterForm.prototype.currentModelClassFromPath = function (path) {
|
|
417
|
-
var modelClass = this.p.modelClass;
|
|
418
|
-
var currentModelClass = modelClass;
|
|
419
|
-
var _loop_2 = function (pathPart) {
|
|
420
|
-
var camelizedPathPart = inflection.camelize(pathPart, true);
|
|
421
|
-
var association = currentModelClass.ransackableAssociations().find(function (reflection) { return reflection.name() == camelizedPathPart; });
|
|
422
|
-
if (!association) {
|
|
423
|
-
var ransackableAssociationNames = currentModelClass.ransackableAssociations().map(function (reflection) { return reflection.name(); }).join(", ");
|
|
424
|
-
throw new Error("Could not find a Ransackable association by that name: ".concat(camelizedPathPart, " in ").concat(ransackableAssociationNames));
|
|
425
|
-
}
|
|
426
|
-
currentModelClass = association.modelClass();
|
|
427
|
-
};
|
|
428
|
-
for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
|
|
429
|
-
var pathPart = path_1[_i];
|
|
430
|
-
_loop_2(pathPart);
|
|
119
|
+
result = await Services.current().sendRequest("Models::Associations", { model_class_name: modelClassName });
|
|
120
|
+
data = this.parseAssociationData(result);
|
|
121
|
+
path.push(reflection);
|
|
122
|
+
}
|
|
123
|
+
const { ransackableAttributes } = data;
|
|
124
|
+
const attribute = this.p.filter.a;
|
|
125
|
+
const ransackableAttribute = ransackableAttributes.find((ransackableAttribute) => digg(ransackableAttribute, "attributeName") == attribute);
|
|
126
|
+
this.setState({ attribute: ransackableAttribute, modelClassName, path });
|
|
127
|
+
}
|
|
128
|
+
async loadRansackPredicates() {
|
|
129
|
+
this.increaseLoading();
|
|
130
|
+
try {
|
|
131
|
+
const response = await Services.current().sendRequest("Ransack::Predicates");
|
|
132
|
+
const predicates = digg(response, "predicates");
|
|
133
|
+
let currentPredicate;
|
|
134
|
+
if (this.props.filter.pre) {
|
|
135
|
+
currentPredicate = predicates.find((predicate) => predicate.name == this.props.filter.pre);
|
|
431
136
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
var modelClass = this.p.modelClass;
|
|
436
|
-
var path = this.s.path;
|
|
437
|
-
var result = [];
|
|
438
|
-
var currentModelClass = modelClass;
|
|
439
|
-
result.push({
|
|
440
|
-
modelClass: modelClass,
|
|
441
|
-
translation: modelClass.modelName().human({ count: 2 })
|
|
137
|
+
this.setState({
|
|
138
|
+
predicate: currentPredicate,
|
|
139
|
+
predicates
|
|
442
140
|
});
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
this.decreaseLoading();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
const { breakpoint, t, valueInputRef } = this.tt;
|
|
148
|
+
const { attribute, path, predicate, predicates, scope, value } = this.s;
|
|
149
|
+
const { mdUp } = breakpoint;
|
|
150
|
+
let submitEnabled = false;
|
|
151
|
+
if (attribute && predicate) {
|
|
152
|
+
submitEnabled = true;
|
|
153
|
+
}
|
|
154
|
+
else if (scope) {
|
|
155
|
+
submitEnabled = true;
|
|
156
|
+
}
|
|
157
|
+
return (_jsxs(Card, { testID: "api-maker/table/filters/filter-form", style: this.cache("cardStyle", {
|
|
158
|
+
width: mdUp ? undefined : "100%",
|
|
159
|
+
minWidth: 50,
|
|
160
|
+
minHeight: 50
|
|
161
|
+
}, [mdUp]), children: [_jsxs(Form, { onSubmit: this.tt.onSubmit, children: [_jsx(View, { style: { flexDirection: "row" }, children: path.map(({ humanName, reflectionName }, pathPartIndex) => _jsxs(View, { style: { flexDirection: "row" }, children: [pathPartIndex > 0 &&
|
|
162
|
+
_jsx(Text, { style: { marginRight: 5, marginLeft: 5 }, children: "-" }), _jsx(Text, { children: humanName })] }, `${pathPartIndex}-${reflectionName}`)) }), _jsxs(View, { style: { flexDirection: mdUp ? "row" : "column" }, children: [_jsxs(View, { style: { marginTop: mdUp ? undefined : 25 }, children: [_jsx(Header, { children: t(".relationships", { defaultValue: "Relationships" }) }), this.s.associations && this.sortedReflectionsByName(this.s.associations).map((reflection) => _jsx(ReflectionElement, { modelClassName: this.s.modelClassName, onClick: this.tt.onReflectionClicked, reflection: reflection }, reflection.reflectionName))] }), _jsxs(View, { style: { marginTop: mdUp ? undefined : 25 }, children: [_jsx(Header, { children: t(".attributes", { defaultValue: "Attributes" }) }), this.s.ransackableAttributes && this.sortedAttributesByName(this.s.ransackableAttributes)?.map((attribute) => _jsx(AttributeElement, { active: attribute.attributeName == this.s.attribute?.attributeName, attribute: attribute, modelClassName: this.s.modelClassName, onClick: this.tt.onAttributeClicked }, attribute.attributeName)), this.s.ransackableScopes?.map((scope) => _jsx(ScopeElement, { active: scope == this.s.scope, scope: scope, onScopeClicked: this.tt.onScopeClicked }, scope))] }), _jsxs(View, { style: { marginTop: mdUp ? undefined : 25 }, children: [_jsx(Header, { children: t(".search", { defaultValue: "Search" }) }), _jsx(View, { children: predicates && !this.s.scope &&
|
|
163
|
+
_jsx(Select, { className: "predicate-select", defaultValue: predicate?.name, includeBlank: true, onChange: this.tt.onPredicateChanged, options: predicates.map((predicate) => digg(predicate, "name")) }) }), _jsx(View, { style: { marginTop: 10 }, children: ((attribute && predicate) || scope) &&
|
|
164
|
+
_jsx(Input, { className: "value-input", defaultValue: value, inputRef: valueInputRef }) })] })] }), _jsxs(View, { style: { flexDirection: "row", justifyContent: "end", marginTop: 10 }, children: [_jsx(Button, { danger: true, icon: "remove", label: t(".cancel", { defaultValue: "Cancel" }), onPress: this.p.onRequestClose, pressableProps: this.cancelButtonPressableProps ||= {
|
|
165
|
+
marginRight: 5
|
|
166
|
+
} }), _jsx(Button, { disabled: !submitEnabled, icon: "check", label: t(".apply", { defaultValue: "Apply" }), pressableProps: this.appleButtonPressableProps ||= {
|
|
167
|
+
style: { marginLeft: 5 },
|
|
168
|
+
testID: "apply-filter-button"
|
|
169
|
+
}, submit: true })] })] }), this.s.loading > 0 &&
|
|
170
|
+
_jsx(View, { style: {
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
justifyContent: "center",
|
|
173
|
+
position: "absolute",
|
|
174
|
+
width: "100%",
|
|
175
|
+
height: "100%"
|
|
176
|
+
}, children: _jsx(ActivityIndicator, { size: "large" }) })] }));
|
|
177
|
+
}
|
|
178
|
+
currentModelClassFromPath(path) {
|
|
179
|
+
const { modelClass } = this.p;
|
|
180
|
+
let currentModelClass = modelClass;
|
|
181
|
+
for (const pathPart of path) {
|
|
182
|
+
const camelizedPathPart = inflection.camelize(pathPart, true);
|
|
183
|
+
const association = currentModelClass.ransackableAssociations().find((reflection) => reflection.name() == camelizedPathPart);
|
|
184
|
+
if (!association) {
|
|
185
|
+
const ransackableAssociationNames = currentModelClass.ransackableAssociations().map((reflection) => reflection.name()).join(", ");
|
|
186
|
+
throw new Error(`Could not find a Ransackable association by that name: ${camelizedPathPart} in ${ransackableAssociationNames}`);
|
|
455
187
|
}
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
})
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
ApiMakerTableFiltersFilterForm.prototype.sortedReflectionsByName = function (reflections) {
|
|
477
|
-
return reflections.sort(function (a, b) {
|
|
478
|
-
return (0, diggerize_1.digg)(a, "humanName")
|
|
479
|
-
.toLowerCase()
|
|
480
|
-
.localeCompare((0, diggerize_1.digg)(b, "humanName").toLowerCase());
|
|
188
|
+
currentModelClass = association.modelClass();
|
|
189
|
+
}
|
|
190
|
+
return currentModelClass;
|
|
191
|
+
}
|
|
192
|
+
currentPathParts() {
|
|
193
|
+
const { modelClass } = this.p;
|
|
194
|
+
const { path } = this.s;
|
|
195
|
+
const result = [];
|
|
196
|
+
let currentModelClass = modelClass;
|
|
197
|
+
result.push({
|
|
198
|
+
modelClass,
|
|
199
|
+
translation: modelClass.modelName().human({ count: 2 })
|
|
200
|
+
});
|
|
201
|
+
for (const pathPart of path) {
|
|
202
|
+
const camelizedPathPart = inflection.camelize(pathPart, true);
|
|
203
|
+
const pathPartTranslation = currentModelClass.humanAttributeName(camelizedPathPart);
|
|
204
|
+
currentModelClass = currentModelClass.ransackableAssociations().find((reflection) => reflection.name() == camelizedPathPart).modelClass();
|
|
205
|
+
result.push({
|
|
206
|
+
modelClass: currentModelClass,
|
|
207
|
+
translation: pathPartTranslation
|
|
481
208
|
});
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
onAttributeClicked = ({ attribute }) => {
|
|
213
|
+
this.setState({
|
|
214
|
+
attribute,
|
|
215
|
+
scope: undefined
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
onPredicateChanged = (e) => {
|
|
219
|
+
const chosenPredicateName = digg(e, "target", "value");
|
|
220
|
+
const predicate = this.s.predicates.find((predicate) => predicate.name == chosenPredicateName);
|
|
221
|
+
this.setState({ predicate });
|
|
222
|
+
};
|
|
223
|
+
onReflectionClicked = ({ reflection }) => {
|
|
224
|
+
const newPath = this.s.path.concat([reflection]);
|
|
225
|
+
this.setState({
|
|
226
|
+
associations: null,
|
|
227
|
+
attribute: undefined,
|
|
228
|
+
actualCurrentModelClass: { modelClass: digg(reflection, "resource") },
|
|
229
|
+
modelClassName: digg(reflection, "modelClassName"),
|
|
230
|
+
path: newPath,
|
|
231
|
+
predicate: undefined
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
onScopeClicked = ({ scope }) => {
|
|
235
|
+
this.setState({
|
|
236
|
+
attribute: undefined,
|
|
237
|
+
predicate: undefined,
|
|
238
|
+
scope
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
onSubmit = () => {
|
|
242
|
+
const { filter, querySearchName } = this.p;
|
|
243
|
+
const { attribute, path, predicate, scope } = this.s;
|
|
244
|
+
const { filterIndex } = digs(filter, "filterIndex");
|
|
245
|
+
const searchParams = Params.parse()[querySearchName] || {};
|
|
246
|
+
const value = digg(this.tt.valueInputRef, "current", "value");
|
|
247
|
+
const p = path.map((reflection) => inflection.underscore(reflection.reflectionName));
|
|
248
|
+
const newSearchParams = {
|
|
249
|
+
p,
|
|
250
|
+
v: value
|
|
482
251
|
};
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
252
|
+
if (attribute) {
|
|
253
|
+
newSearchParams.a = digg(attribute, "attributeName");
|
|
254
|
+
newSearchParams.pre = digg(predicate, "name");
|
|
255
|
+
}
|
|
256
|
+
else if (scope) {
|
|
257
|
+
newSearchParams.sc = scope;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
throw new Error("Dont know if should search for attribute or scope?");
|
|
261
|
+
}
|
|
262
|
+
searchParams[filterIndex] = JSON.stringify(newSearchParams);
|
|
263
|
+
const newParams = {};
|
|
264
|
+
newParams[querySearchName] = searchParams;
|
|
265
|
+
Params.changeParams(newParams);
|
|
266
|
+
this.props.onApplyClicked();
|
|
267
|
+
};
|
|
268
|
+
reflectionsWithModelClass(reflections) {
|
|
269
|
+
return reflections.filter((reflection) => {
|
|
270
|
+
try {
|
|
271
|
+
reflection.modelClass();
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
sortedAttributesByName(attributes) {
|
|
280
|
+
return attributes.sort((a, b) => digg(a, "humanName")
|
|
281
|
+
.toLowerCase()
|
|
282
|
+
.localeCompare(digg(b, "humanName").toLowerCase()));
|
|
283
|
+
}
|
|
284
|
+
sortedReflectionsByName(reflections) {
|
|
285
|
+
return reflections.sort((a, b) => digg(a, "humanName")
|
|
286
|
+
.toLowerCase()
|
|
287
|
+
.localeCompare(digg(b, "humanName").toLowerCase()));
|
|
288
|
+
}
|
|
289
|
+
}));
|
|
493
290
|
//# sourceMappingURL=filter-form.js.map
|