@kaspernj/api-maker 1.0.2011 → 1.0.2012
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/{.eslintrc.cjs → .eslintrc.js} +10 -1
- package/README.md +35 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/api_maker/ApiMakerModule.kt +50 -0
- package/android/src/main/java/expo/modules/api_maker/ApiMakerView.kt +30 -0
- package/build/api.js +120 -0
- package/build/attribute-not-loaded-error.js +2 -0
- package/build/base-component.js +5 -0
- package/build/base-error.js +33 -0
- package/build/base-model/attribute.js +25 -0
- package/build/base-model/column.js +11 -0
- package/build/base-model/reflection.js +14 -0
- package/build/base-model/scope.js +11 -0
- package/build/base-model.js +828 -0
- package/build/bootstrap/attribute-row.js +135 -0
- package/build/bootstrap/attribute-rows.js +31 -0
- package/build/bootstrap/card.js +138 -0
- package/build/bootstrap/checkbox.js +97 -0
- package/build/bootstrap/checkboxes.js +183 -0
- package/build/bootstrap/index.js +2 -0
- package/build/bootstrap/input.js +129 -0
- package/build/bootstrap/invalid-feedback.js +27 -0
- package/build/bootstrap/paginate.js +150 -0
- package/build/bootstrap/radio-buttons.js +72 -0
- package/build/bootstrap/select.js +88 -0
- package/build/bootstrap/sort-link.js +131 -0
- package/build/cable-connection-pool.js +128 -0
- package/build/cable-subscription-pool.js +207 -0
- package/build/cable-subscription.js +21 -0
- package/build/cache-key-generator.js +81 -0
- package/build/can-can.js +134 -0
- package/build/channels-consumer.js +9 -0
- package/build/collection-loader.js +48 -0
- package/build/collection.js +280 -0
- package/build/command-submit-data.js +81 -0
- package/build/commands-pool.js +195 -0
- package/build/compose.js +9 -0
- package/build/config.js +62 -0
- package/build/custom-error.js +5 -0
- package/build/data-set-to-attributes.js +10 -0
- package/build/deserializer.js +56 -0
- package/build/destroy-error.js +5 -0
- package/build/devise.js +112 -0
- package/build/draggable-sort/controller.js +136 -0
- package/build/draggable-sort/index.js +114 -0
- package/build/draggable-sort/item.js +188 -0
- package/build/error-logger.js +101 -0
- package/build/error-messages.js +13 -0
- package/build/event-connection.js +32 -0
- package/build/event-emitter-listener.js +15 -0
- package/build/event-model-class.js +24 -0
- package/build/events.js +5 -0
- package/build/flash-message.js +79 -0
- package/build/form.js +83 -0
- package/build/history-expo.js +20 -0
- package/build/history-react-native.js +20 -0
- package/build/history.js +3 -0
- package/build/index.js +3 -0
- package/build/inputs/attachment.js +133 -0
- package/build/inputs/auto-submit.js +36 -0
- package/build/inputs/checkbox.js +138 -0
- package/build/inputs/checkboxes.js +112 -0
- package/build/inputs/id-for-component.js +15 -0
- package/build/inputs/input-wrapper.js +19 -0
- package/build/inputs/input.js +243 -0
- package/build/inputs/money.js +179 -0
- package/build/inputs/name-for-component.js +13 -0
- package/build/inputs/select.js +93 -0
- package/build/instance-of-class-name.js +23 -0
- package/build/key-value-store.js +53 -0
- package/build/link.js +73 -0
- package/build/logger.js +30 -0
- package/build/modal.js +38 -0
- package/build/model-class-require.js +13 -0
- package/build/model-events.js +30 -0
- package/build/model-name.js +28 -0
- package/build/model-prop-type.js +101 -0
- package/build/model-recipes-loader.js +32 -0
- package/build/model-recipes-model-loader.js +357 -0
- package/build/models-response-reader.js +40 -0
- package/build/models.js +8 -0
- package/build/money-formatter.js +78 -0
- package/build/not-loaded-error.js +2 -0
- package/build/params.js +61 -0
- package/build/preloaded.js +38 -0
- package/build/resize-observer.js +11 -0
- package/build/result.js +13 -0
- package/build/router/route.js +270 -0
- package/build/router/switch.js +72 -0
- package/build/router.js +59 -0
- package/build/routes-native.js +202 -0
- package/build/routes.js +50 -0
- package/build/run-last.js +35 -0
- package/build/serializer.js +63 -0
- package/build/services.js +20 -0
- package/build/session-status-updater.js +134 -0
- package/build/source-maps-loader.js +184 -0
- package/build/super-admin/config-reader.js +85 -0
- package/build/super-admin/edit-page/edit-attribute-checkbox.js +85 -0
- package/build/super-admin/edit-page/edit-attribute-content.js +55 -0
- package/build/super-admin/edit-page/edit-attribute-input.js +79 -0
- package/build/super-admin/edit-page/edit-attribute.js +77 -0
- package/build/super-admin/edit-page.js +123 -0
- package/build/super-admin/has-edit-config.js +12 -0
- package/build/super-admin/index-page.js +25 -0
- package/build/super-admin/index.js +181 -0
- package/build/super-admin/layout/header/index.js +161 -0
- package/build/super-admin/layout/index.js +164 -0
- package/build/super-admin/layout/menu/index.js +206 -0
- package/build/super-admin/layout/menu/menu-content.js +46 -0
- package/build/super-admin/layout/menu/menu-item.js +84 -0
- package/build/super-admin/layout/no-access.js +27 -0
- package/build/super-admin/model-class-table.js +61 -0
- package/build/super-admin/models.js +8 -0
- package/build/super-admin/show-nav.js +51 -0
- package/build/super-admin/show-page/belongs-to-attribute-row.js +29 -0
- package/build/super-admin/show-page/index.js +141 -0
- package/build/super-admin/show-reflection-actions.js +47 -0
- package/build/super-admin/show-reflection-link.js +48 -0
- package/build/super-admin/show-reflection-page.js +48 -0
- package/build/table/column-content.js +117 -0
- package/build/table/column-identifier.js +18 -0
- package/build/table/column-visible.js +7 -0
- package/build/table/components/column.js +21 -0
- package/build/table/components/flat-list.js +21 -0
- package/build/table/components/header.js +26 -0
- package/build/table/components/row.js +26 -0
- package/build/table/filters/attribute-element.js +44 -0
- package/build/table/filters/filter-form.js +402 -0
- package/build/table/filters/filter.js +90 -0
- package/build/table/filters/index.js +184 -0
- package/build/table/filters/load-search-modal.js +175 -0
- package/build/table/filters/reflection-element.js +37 -0
- package/build/table/filters/save-search-modal.js +88 -0
- package/build/table/filters/scope-element.js +42 -0
- package/build/table/header-column-content.js +68 -0
- package/build/table/header-column.js +144 -0
- package/build/table/header-select.js +105 -0
- package/build/table/model-callback-args.js +10 -0
- package/build/table/model-column.js +97 -0
- package/build/table/model-row.js +193 -0
- package/build/table/select-calculator.js +63 -0
- package/build/table/settings/column-row.js +97 -0
- package/build/table/settings/download-action.js +79 -0
- package/build/table/settings/index.js +92 -0
- package/build/table/table-settings.js +219 -0
- package/build/table/table.js +972 -0
- package/build/table/use-sorting.js +34 -0
- package/build/table/widths.js +75 -0
- package/build/table/worker-plugins-check-all-checkbox.js +125 -0
- package/build/table/worker-plugins-checkbox.js +115 -0
- package/build/translated-attributes.js +10 -0
- package/build/translated-collections.js +12 -0
- package/build/updated-attribute.js +76 -0
- package/build/url-encode.js +15 -0
- package/build/use-breakpoint.js +62 -0
- package/build/use-can-can.js +55 -0
- package/build/use-collection.js +225 -0
- package/build/use-created-event.js +52 -0
- package/build/use-current-user.js +76 -0
- package/build/use-destroyed-event.js +60 -0
- package/build/use-event-emitter.js +13 -0
- package/build/use-event-listener.js +16 -0
- package/build/use-input.js +137 -0
- package/build/use-model-event.js +60 -0
- package/build/use-model.js +169 -0
- package/build/use-resize-observer.js +23 -0
- package/build/use-router.js +104 -0
- package/build/use-screen-layout.js +39 -0
- package/build/use-updated-event.js +60 -0
- package/build/use-validation-errors.js +30 -0
- package/build/utils/card.js +51 -0
- package/build/utils/checkbox.js +78 -0
- package/build/utils/checkboxes.js +163 -0
- package/build/utils/default-style.js +18 -0
- package/build/utils/icon.js +23 -0
- package/build/utils/invalid-feedback.js +19 -0
- package/build/utils/modal.js +62 -0
- package/build/utils/text.js +19 -0
- package/build/validation-error.js +28 -0
- package/build/validation-errors.js +98 -0
- package/build/with-api-maker.js +29 -0
- package/build/with-collection.js +14 -0
- package/build/with-current-user.js +10 -0
- package/build/with-model.js +15 -0
- package/build/with-router.js +22 -0
- package/expo-module.config.json +17 -0
- package/ios/ApiMaker.podspec +29 -0
- package/ios/ApiMakerModule.swift +48 -0
- package/ios/ApiMakerView.swift +38 -0
- package/link.sh +8 -0
- package/package.json +49 -46
- package/src/{api.mjs → api.js} +38 -37
- package/src/base-component.jsx +5 -0
- package/src/{base-error.mjs → base-error.js} +4 -6
- package/src/base-model/attribute.js +33 -0
- package/src/base-model/column.js +13 -0
- package/src/base-model/reflection.js +15 -0
- package/src/base-model/scope.js +12 -0
- package/src/{base-model.mjs → base-model.js} +302 -144
- package/src/bootstrap/attribute-row.jsx +135 -0
- package/src/bootstrap/attribute-rows.jsx +27 -0
- package/src/bootstrap/card.jsx +149 -0
- package/src/bootstrap/checkbox.jsx +86 -0
- package/src/bootstrap/checkboxes.jsx +185 -0
- package/src/bootstrap/index.js +0 -0
- package/src/bootstrap/input.jsx +173 -0
- package/src/bootstrap/invalid-feedback.jsx +31 -0
- package/src/bootstrap/paginate.jsx +187 -0
- package/src/bootstrap/radio-buttons.jsx +87 -0
- package/src/bootstrap/select.jsx +110 -0
- package/src/bootstrap/sort-link.jsx +106 -0
- package/src/{cable-connection-pool.mjs → cable-connection-pool.js} +16 -36
- package/src/{cable-subscription-pool.mjs → cable-subscription-pool.js} +26 -21
- package/src/{cable-subscription.mjs → cable-subscription.js} +6 -4
- package/src/cache-key-generator.js +100 -0
- package/src/{can-can.mjs → can-can.js} +13 -12
- package/src/channels-consumer.js +10 -0
- package/src/collection-loader.jsx +58 -224
- package/src/{collection.mjs → collection.js} +98 -44
- package/src/{command-submit-data.mjs → command-submit-data.js} +2 -7
- package/src/{commands-pool.mjs → commands-pool.js} +57 -41
- package/src/compose.js +11 -0
- package/src/{config.mjs → config.js} +6 -2
- package/src/{custom-error.mjs → custom-error.js} +1 -1
- package/src/data-set-to-attributes.js +13 -0
- package/src/{deserializer.mjs → deserializer.js} +3 -3
- package/src/destroy-error.js +7 -0
- package/src/devise.js +129 -0
- package/src/draggable-sort/controller.js +137 -0
- package/src/draggable-sort/index.jsx +108 -0
- package/src/draggable-sort/item.jsx +174 -0
- package/src/{error-logger.mjs → error-logger.js} +12 -7
- package/src/{error-messages.mjs → error-messages.js} +1 -0
- package/src/event-connection.jsx +1 -1
- package/src/event-emitter-listener.jsx +8 -27
- package/src/event-model-class.jsx +2 -4
- package/src/events.js +7 -0
- package/src/flash-message.js +70 -0
- package/src/form.jsx +91 -0
- package/src/history-expo.js +23 -0
- package/src/history-react-native.js +25 -0
- package/src/history.js +3 -0
- package/src/index.js +3 -0
- package/src/inputs/attachment.jsx +108 -0
- package/src/inputs/auto-submit.js +37 -0
- package/src/inputs/checkbox.jsx +125 -0
- package/src/inputs/checkboxes.jsx +116 -0
- package/src/inputs/id-for-component.js +15 -0
- package/src/inputs/input-wrapper.jsx +16 -0
- package/src/inputs/input.jsx +260 -0
- package/src/inputs/money.jsx +187 -0
- package/src/inputs/name-for-component.js +15 -0
- package/src/inputs/select.jsx +104 -0
- package/src/{key-value-store.mjs → key-value-store.js} +1 -1
- package/src/link.jsx +54 -9
- package/src/logger.js +38 -0
- package/src/modal.jsx +37 -0
- package/src/model-class-require.js +17 -0
- package/src/{model-events.mjs → model-events.js} +1 -1
- package/src/{model-name.mjs → model-name.js} +8 -8
- package/src/{model-recipes-loader.mjs → model-recipes-loader.js} +1 -1
- package/src/{model-recipes-model-loader.mjs → model-recipes-model-loader.js} +5 -5
- package/src/{models-response-reader.mjs → models-response-reader.js} +3 -4
- package/src/models.js +7 -0
- package/src/{models.mjs.erb → models.js.erb} +6 -3
- package/src/{money-formatter.mjs → money-formatter.js} +5 -4
- package/src/{params.mjs → params.js} +17 -7
- package/src/{preloaded.mjs → preloaded.js} +2 -2
- package/src/resize-observer.jsx +10 -0
- package/src/result.js +13 -0
- package/src/router/route.jsx +246 -0
- package/src/router/switch.jsx +76 -0
- package/src/router.jsx +23 -21
- package/src/{routes-native.mjs → routes-native.js} +12 -6
- package/src/{routes.mjs → routes.js} +1 -1
- package/src/run-last.js +39 -0
- package/src/{serializer.mjs → serializer.js} +2 -2
- package/src/{services.mjs → services.js} +1 -1
- package/src/session-status-updater.js +172 -0
- package/src/{source-maps-loader.mjs → source-maps-loader.js} +54 -28
- package/src/super-admin/config-reader.jsx +93 -0
- package/src/super-admin/edit-page/edit-attribute-checkbox.jsx +81 -0
- package/src/super-admin/edit-page/edit-attribute-content.jsx +57 -0
- package/src/super-admin/edit-page/edit-attribute-input.jsx +71 -0
- package/src/super-admin/edit-page/edit-attribute.jsx +81 -0
- package/src/super-admin/edit-page.jsx +117 -0
- package/src/super-admin/has-edit-config.js +15 -0
- package/src/super-admin/index-page.jsx +23 -0
- package/src/super-admin/index.jsx +197 -0
- package/src/super-admin/layout/header/index.jsx +144 -0
- package/src/super-admin/layout/header/style.scss +45 -0
- package/src/super-admin/layout/index.jsx +154 -0
- package/src/super-admin/layout/menu/index.jsx +171 -0
- package/src/super-admin/layout/menu/menu-content.jsx +43 -0
- package/src/super-admin/layout/menu/menu-item.jsx +70 -0
- package/src/super-admin/layout/menu/style.scss +11 -0
- package/src/super-admin/layout/no-access.jsx +26 -0
- package/src/super-admin/model-class-table.jsx +66 -0
- package/src/super-admin/models.js +11 -0
- package/src/super-admin/show-nav.jsx +44 -0
- package/src/super-admin/show-page/belongs-to-attribute-row.jsx +30 -0
- package/src/super-admin/show-page/index.jsx +141 -0
- package/src/super-admin/show-reflection-actions.jsx +49 -0
- package/src/super-admin/show-reflection-link.jsx +40 -0
- package/src/super-admin/show-reflection-page.jsx +47 -0
- package/src/super-admin/stylesheets/variables.scss +11 -0
- package/src/table/column-content.jsx +122 -0
- package/src/table/column-identifier.js +23 -0
- package/src/table/column-visible.js +7 -0
- package/src/table/components/column.jsx +19 -0
- package/src/table/components/flat-list.jsx +19 -0
- package/src/table/components/header.jsx +21 -0
- package/src/table/components/row.jsx +23 -0
- package/src/table/filters/attribute-element.jsx +47 -0
- package/src/table/filters/filter-form.jsx +407 -0
- package/src/table/filters/filter.jsx +70 -0
- package/src/table/filters/index.jsx +170 -0
- package/src/table/filters/load-search-modal.jsx +146 -0
- package/src/table/filters/reflection-element.jsx +38 -0
- package/src/table/filters/save-search-modal.jsx +74 -0
- package/src/table/filters/scope-element.jsx +44 -0
- package/src/table/header-column-content.jsx +55 -0
- package/src/table/header-column.jsx +129 -0
- package/src/table/header-select.jsx +73 -0
- package/src/table/model-callback-args.js +10 -0
- package/src/table/model-column.jsx +82 -0
- package/src/table/model-row.jsx +136 -0
- package/src/table/select-calculator.js +65 -0
- package/src/table/settings/column-row.jsx +93 -0
- package/src/table/settings/download-action.jsx +68 -0
- package/src/table/settings/index.jsx +65 -0
- package/src/table/table-settings.js +263 -0
- package/src/table/table.jsx +950 -0
- package/src/table/use-sorting.js +35 -0
- package/src/table/variables.scss +11 -0
- package/src/table/widths.jsx +87 -0
- package/src/table/worker-plugins-check-all-checkbox.jsx +112 -0
- package/src/table/worker-plugins-checkbox.jsx +104 -0
- package/src/translated-attributes.js +11 -0
- package/src/{translated-collections.mjs → translated-collections.js} +3 -2
- package/src/updated-attribute.jsx +1 -1
- package/src/url-encode.js +18 -0
- package/src/use-breakpoint.js +76 -0
- package/src/use-can-can.js +55 -0
- package/src/use-collection.js +280 -0
- package/src/use-created-event.js +55 -0
- package/src/use-current-user.js +88 -0
- package/src/use-destroyed-event.js +60 -0
- package/src/use-event-emitter.js +15 -0
- package/src/use-event-listener.js +19 -0
- package/src/use-input.js +157 -0
- package/src/use-model-event.js +60 -0
- package/src/use-model.js +189 -0
- package/src/use-resize-observer.js +24 -0
- package/src/use-router.jsx +128 -0
- package/src/use-screen-layout.js +49 -0
- package/src/use-updated-event.js +60 -0
- package/src/use-validation-errors.js +33 -0
- package/src/utils/card.jsx +49 -0
- package/src/utils/checkbox.jsx +80 -0
- package/src/utils/checkboxes.jsx +158 -0
- package/src/utils/default-style.jsx +25 -0
- package/src/utils/icon.jsx +21 -0
- package/src/utils/invalid-feedback.jsx +20 -0
- package/src/utils/modal.jsx +60 -0
- package/src/utils/text.jsx +16 -0
- package/src/{validation-error.mjs → validation-error.js} +9 -5
- package/src/{validation-errors.mjs → validation-errors.js} +15 -27
- package/src/with-api-maker.jsx +31 -0
- package/src/with-collection.jsx +17 -0
- package/src/with-current-user.jsx +7 -25
- package/src/with-model.jsx +16 -0
- package/src/with-router.jsx +7 -129
- package/__tests__/base-model.test.js +0 -71
- package/__tests__/cable-connection-pool.test.js +0 -227
- package/__tests__/cable-subscription-pool.test.js +0 -26
- package/__tests__/can-can.test.js +0 -34
- package/__tests__/collection.test.js +0 -51
- package/__tests__/custom-error.test.js +0 -13
- package/__tests__/model-name.test.js +0 -34
- package/__tests__/model-prop-type.test.js +0 -113
- package/__tests__/params.test.js +0 -40
- package/__tests__/routes-native.test.js +0 -103
- package/__tests__/routes.test.js +0 -46
- package/__tests__/serializer.test.js +0 -30
- package/__tests__/support/task.js +0 -27
- package/__tests__/support/user.js +0 -32
- package/index.js +0 -1
- package/jest.config.js +0 -4
- package/src/can-can-loader.jsx +0 -54
- package/src/channels-consumer.mjs +0 -3
- package/src/destroy-error.mjs +0 -7
- package/src/devise.mjs +0 -122
- package/src/event-created.jsx +0 -65
- package/src/event-destroyed.jsx +0 -29
- package/src/event-listener.jsx +0 -38
- package/src/event-updated.jsx +0 -74
- package/src/logger.mjs +0 -25
- package/src/model-class-require.mjs +0 -10
- package/src/model-load-wrapper.jsx +0 -116
- package/src/result.mjs +0 -29
- package/src/session-status-updater.mjs +0 -116
- package/webpack.config.js +0 -15
- /package/src/{attribute-not-loaded-error.mjs → attribute-not-loaded-error.js} +0 -0
- /package/src/{instance-of-class-name.mjs → instance-of-class-name.js} +0 -0
- /package/src/{model-prop-type.mjs → model-prop-type.js} +0 -0
- /package/src/{not-loaded-error.mjs → not-loaded-error.js} +0 -0
- /package/src/{translated-collections-data.mjs.erb → translated-collections-data.js.erb} +0 -0
package/src/router.jsx
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
+
import BaseComponent from "./base-component"
|
|
1
2
|
import PropTypes from "prop-types"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import propTypesExact from "prop-types-exact"
|
|
4
|
+
import React, {memo, Suspense} from "react"
|
|
5
|
+
import {shapeComponent} from "set-state-compare/src/shape-component"
|
|
6
|
+
import usePath from "on-location-changed/build/use-path"
|
|
7
|
+
import useRouter from "./use-router"
|
|
8
|
+
|
|
9
|
+
export default memo(shapeComponent(class ApiMakerRouter extends BaseComponent {
|
|
10
|
+
static propTypes = propTypesExact({
|
|
11
|
+
history: PropTypes.object,
|
|
12
|
+
locales: PropTypes.array.isRequired,
|
|
9
13
|
notFoundComponent: PropTypes.elementType,
|
|
10
|
-
requireComponent: PropTypes.func.isRequired
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return shouldComponentUpdate(this, nextProps, nextState)
|
|
15
|
-
}
|
|
14
|
+
requireComponent: PropTypes.func.isRequired,
|
|
15
|
+
routeDefinitions: PropTypes.object,
|
|
16
|
+
routes: PropTypes.object
|
|
17
|
+
})
|
|
16
18
|
|
|
17
19
|
render() {
|
|
18
|
-
const
|
|
20
|
+
const path = usePath()
|
|
21
|
+
const {locales, notFoundComponent, requireComponent, routeDefinitions, routes} = this.props
|
|
22
|
+
const {match} = useRouter({locales, path, routes, routeDefinitions})
|
|
19
23
|
const {matchingRoute} = match
|
|
20
24
|
|
|
21
25
|
if (!matchingRoute) {
|
|
22
|
-
if (
|
|
23
|
-
const NotFoundComponent =
|
|
26
|
+
if (notFoundComponent) {
|
|
27
|
+
const NotFoundComponent = notFoundComponent
|
|
24
28
|
|
|
25
29
|
return (
|
|
26
30
|
<Suspense fallback={<div />}>
|
|
@@ -32,14 +36,12 @@ class ApiMakerRouter extends React.Component {
|
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
const Component =
|
|
39
|
+
const Component = requireComponent({routeDefinition: matchingRoute.parsedRouteDefinition.routeDefinition})
|
|
36
40
|
|
|
37
41
|
return (
|
|
38
42
|
<Suspense fallback={<div />}>
|
|
39
|
-
<Component match={match}
|
|
43
|
+
<Component match={match} />
|
|
40
44
|
</Suspense>
|
|
41
45
|
)
|
|
42
46
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default withRouter(ApiMakerRouter)
|
|
47
|
+
}))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {dig, digg, digs} from "diggerize"
|
|
2
|
-
import inflection from "inflection"
|
|
2
|
+
import * as inflection from "inflection"
|
|
3
3
|
import qs from "qs"
|
|
4
|
+
import urlEncode from "./url-encode"
|
|
4
5
|
|
|
5
6
|
export default class ApiMakerRoutesNative {
|
|
6
7
|
constructor ({getLocale}) {
|
|
@@ -33,8 +34,10 @@ export default class ApiMakerRoutesNative {
|
|
|
33
34
|
|
|
34
35
|
if (variableMatch) {
|
|
35
36
|
localizedPathParts.push({type: "variable", count: variableCount++})
|
|
36
|
-
} else {
|
|
37
|
-
|
|
37
|
+
} else if (pathPart) {
|
|
38
|
+
const name = this.i18n.t(`routes.${pathPart}`, null, {default: pathPart, locale})
|
|
39
|
+
|
|
40
|
+
localizedPathParts.push({type: "pathPart", name})
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -63,6 +66,7 @@ export default class ApiMakerRoutesNative {
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
loadRouteTranslations (i18n) {
|
|
69
|
+
this.i18n = i18n
|
|
66
70
|
const locales = digg(i18n, "locales")
|
|
67
71
|
|
|
68
72
|
for (const locale in locales) {
|
|
@@ -81,7 +85,9 @@ export default class ApiMakerRoutesNative {
|
|
|
81
85
|
let options
|
|
82
86
|
|
|
83
87
|
// Extract options from args if any
|
|
84
|
-
|
|
88
|
+
const lastArg = args[args.length - 1]
|
|
89
|
+
|
|
90
|
+
if (lastArg && typeof lastArg == "object") {
|
|
85
91
|
options = args.pop()
|
|
86
92
|
} else {
|
|
87
93
|
options = {}
|
|
@@ -106,7 +112,7 @@ export default class ApiMakerRoutesNative {
|
|
|
106
112
|
.join("/")
|
|
107
113
|
|
|
108
114
|
if (restOptions && Object.keys(restOptions).length > 0) {
|
|
109
|
-
translatedRoute += `?${qs.stringify(restOptions)}`
|
|
115
|
+
translatedRoute += `?${qs.stringify(restOptions, {encoder: urlEncode})}`
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
if (url) return this.addHostToRoute({host, port, protocol, translatedRoute})
|
|
@@ -127,7 +133,7 @@ export default class ApiMakerRoutesNative {
|
|
|
127
133
|
.join("/")
|
|
128
134
|
|
|
129
135
|
if (restOptions && Object.keys(restOptions).length > 0) {
|
|
130
|
-
translatedRoute += `?${qs.stringify(restOptions)}`
|
|
136
|
+
translatedRoute += `?${qs.stringify(restOptions, {encoder: urlEncode})}`
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
if (url) return this.addHostToRoute({host, port, protocol, translatedRoute})
|
package/src/run-last.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class RunLast {
|
|
2
|
+
constructor(callback) {
|
|
3
|
+
if (!callback) throw new Error("Empty callback given")
|
|
4
|
+
|
|
5
|
+
this.callback = callback
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Try to batch calls to backend while waiting for the event-queue-call to clear any other jobs before the request and reset on every flush call
|
|
9
|
+
// If only waiting a single time, then other event-queue-jobs might be before us and queue other jobs that might queue calls to the backend
|
|
10
|
+
queue() {
|
|
11
|
+
this.flushTriggerCount = 0
|
|
12
|
+
this.clearTimeout()
|
|
13
|
+
this.flushTrigger()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
flushTrigger = () => {
|
|
17
|
+
if (this.flushTriggerCount >= 10) {
|
|
18
|
+
this.run()
|
|
19
|
+
} else {
|
|
20
|
+
this.flushTriggerCount++
|
|
21
|
+
this.flushTriggerQueue()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
flushTriggerQueue() {
|
|
26
|
+
this.flushTimeout = setTimeout(this.flushTrigger, 0)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
clearTimeout() {
|
|
30
|
+
if (this.flushTimeout) {
|
|
31
|
+
clearTimeout(this.flushTimeout)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
run() {
|
|
36
|
+
this.clearTimeout()
|
|
37
|
+
this.callback()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -16,7 +16,7 @@ export default class Serializer {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
serializeArgument (arg) {
|
|
19
|
-
if (typeof arg == "object" && arg.constructor.apiMakerType == "BaseModel") {
|
|
19
|
+
if (typeof arg == "object" && arg && arg.constructor.apiMakerType == "BaseModel") {
|
|
20
20
|
return {
|
|
21
21
|
api_maker_type: "model",
|
|
22
22
|
model_class_name: digg(arg.modelClassData(), "name"),
|
|
@@ -44,7 +44,7 @@ export default class Serializer {
|
|
|
44
44
|
}
|
|
45
45
|
} else if (Array.isArray(arg)) {
|
|
46
46
|
return this.serializeArray(arg)
|
|
47
|
-
} else if (typeof arg == "object" && arg.constructor && arg.constructor.apiMakerType == "Collection") {
|
|
47
|
+
} else if (typeof arg == "object" && arg && arg.constructor && arg.constructor.apiMakerType == "Collection") {
|
|
48
48
|
return {
|
|
49
49
|
api_maker_type: "collection",
|
|
50
50
|
value: this.serializeObject(arg)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import config from "./config"
|
|
2
|
+
import Devise from "./devise"
|
|
3
|
+
import * as inflection from "inflection"
|
|
4
|
+
import Logger from "./logger"
|
|
5
|
+
import wakeEvent from "wake-event"
|
|
6
|
+
|
|
7
|
+
const logger = new Logger({name: "ApiMaker / SessionStatusUpdater"})
|
|
8
|
+
const shared = {}
|
|
9
|
+
|
|
10
|
+
// logger.setDebug(true)
|
|
11
|
+
|
|
12
|
+
export default class ApiMakerSessionStatusUpdater {
|
|
13
|
+
static current(args) {
|
|
14
|
+
if (!shared.apiMakerSessionStatusUpdater) {
|
|
15
|
+
shared.apiMakerSessionStatusUpdater = new ApiMakerSessionStatusUpdater(args)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return shared.apiMakerSessionStatusUpdater
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor(args = {}) {
|
|
22
|
+
this.events = {}
|
|
23
|
+
this.timeout = args.timeout || 600000
|
|
24
|
+
|
|
25
|
+
if ("useMetaElement" in args) {
|
|
26
|
+
this.useMetaElement = args.useMetaElement
|
|
27
|
+
} else if (typeof document != "undefined") {
|
|
28
|
+
this.useMetaElement = true
|
|
29
|
+
} else {
|
|
30
|
+
this.useMetaElement = false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (typeof window != "undefined") {
|
|
34
|
+
this.connectOnlineEvent()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.connectWakeEvent()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
connectOnlineEvent() {
|
|
41
|
+
window.addEventListener("online", this.updateSessionStatus, false)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
connectWakeEvent() {
|
|
45
|
+
wakeEvent(this.updateSessionStatus)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async getCsrfToken() {
|
|
49
|
+
if (this.csrfToken) {
|
|
50
|
+
logger.debug(`Get CSRF token from set variable: ${this.csrfToken}`)
|
|
51
|
+
|
|
52
|
+
return this.csrfToken
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.useMetaElement) {
|
|
56
|
+
const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
|
|
57
|
+
|
|
58
|
+
if (csrfTokenElement) {
|
|
59
|
+
logger.debug(() => `Get CSRF token from meta element: ${csrfTokenElement.getAttribute("content")}`)
|
|
60
|
+
|
|
61
|
+
this.csrfToken = csrfTokenElement.getAttribute("content")
|
|
62
|
+
|
|
63
|
+
return this.csrfToken
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
logger.debug("Updating session status because no CSRF token set yet")
|
|
68
|
+
await this.updateSessionStatus()
|
|
69
|
+
|
|
70
|
+
if (this.csrfToken) {
|
|
71
|
+
logger.debug(() => `Returning CSRF token after updating session status: ${this.csrfToken}`)
|
|
72
|
+
|
|
73
|
+
return this.csrfToken
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new Error("CSRF token hasn't been set")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
sessionStatus() {
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
const host = config.getHost()
|
|
82
|
+
let requestPath = ""
|
|
83
|
+
|
|
84
|
+
if (host) requestPath += host
|
|
85
|
+
|
|
86
|
+
requestPath += "/api_maker/session_statuses"
|
|
87
|
+
|
|
88
|
+
const xhr = new XMLHttpRequest()
|
|
89
|
+
xhr.open("POST", requestPath, true)
|
|
90
|
+
xhr.onload = () => {
|
|
91
|
+
const response = JSON.parse(xhr.responseText)
|
|
92
|
+
resolve(response)
|
|
93
|
+
}
|
|
94
|
+
xhr.send()
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onSignedOut(callback) {
|
|
99
|
+
this.addEvent("onSignedOut", callback)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
startTimeout() {
|
|
103
|
+
logger.debug("startTimeout")
|
|
104
|
+
|
|
105
|
+
if (this.updateTimeout)
|
|
106
|
+
clearTimeout(this.updateTimeout)
|
|
107
|
+
|
|
108
|
+
this.updateTimeout = setTimeout(
|
|
109
|
+
() => {
|
|
110
|
+
this.startTimeout()
|
|
111
|
+
this.updateSessionStatus()
|
|
112
|
+
},
|
|
113
|
+
this.timeout
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
stopTimeout() {
|
|
118
|
+
if (this.updateTimeout)
|
|
119
|
+
clearTimeout(this.updateTimeout)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
updateSessionStatus = async () => {
|
|
123
|
+
logger.debug("updateSessionStatus")
|
|
124
|
+
|
|
125
|
+
const result = await this.sessionStatus()
|
|
126
|
+
|
|
127
|
+
logger.debug(() => `Result: ${JSON.stringify(result, null, 2)}`)
|
|
128
|
+
this.updateMetaElementsFromResult(result)
|
|
129
|
+
this.updateUserSessionsFromResult(result)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
updateMetaElementsFromResult(result) {
|
|
133
|
+
logger.debug("updateMetaElementsFromResult")
|
|
134
|
+
|
|
135
|
+
this.csrfToken = result.csrf_token
|
|
136
|
+
|
|
137
|
+
if (this.useMetaElement) {
|
|
138
|
+
const csrfTokenElement = document.querySelector("meta[name='csrf-token']")
|
|
139
|
+
|
|
140
|
+
if (csrfTokenElement) {
|
|
141
|
+
logger.debug(() => `Changing token from "${csrfTokenElement.getAttribute("content")}" to "${result.csrf_token}"`)
|
|
142
|
+
csrfTokenElement.setAttribute("content", result.csrf_token)
|
|
143
|
+
} else {
|
|
144
|
+
logger.debug("csrf token element couldn't be found")
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
updateUserSessionsFromResult(result) {
|
|
150
|
+
for (const scopeName in result.scopes) {
|
|
151
|
+
this.updateUserSessionScopeFromResult(scopeName, result.scopes[scopeName])
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
updateUserSessionScopeFromResult(scopeName, scope) {
|
|
156
|
+
const deviseIsSignedInMethodName = `is${inflection.camelize(scopeName)}SignedIn`
|
|
157
|
+
|
|
158
|
+
if (!(deviseIsSignedInMethodName in Devise)) {
|
|
159
|
+
throw new Error(`No such method in Devise: ${deviseIsSignedInMethodName}`)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const currentlySignedIn = Devise[deviseIsSignedInMethodName]()
|
|
163
|
+
const signedInOnBackend = scope.signed_in
|
|
164
|
+
|
|
165
|
+
if (currentlySignedIn && !signedInOnBackend) {
|
|
166
|
+
logger.debug(() => `${inflection.camelize(scopeName)} signed in on frontend but not in backend!`)
|
|
167
|
+
|
|
168
|
+
Devise.setSignedOut({scope: scopeName})
|
|
169
|
+
Devise.callSignOutEvent({scope: scopeName})
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
import * as stackTraceParser from "stacktrace-parser"
|
|
2
|
+
import Logger from "./logger"
|
|
2
3
|
import {SourceMapConsumer} from "source-map"
|
|
3
4
|
import uniqunize from "uniqunize"
|
|
4
5
|
|
|
5
6
|
// Sometimes this needs to be called and sometimes not
|
|
6
7
|
if (SourceMapConsumer.initialize) {
|
|
7
8
|
SourceMapConsumer.initialize({
|
|
8
|
-
"lib/mappings.wasm": "https://unpkg.com/source-map@0.7.
|
|
9
|
+
"lib/mappings.wasm": "https://unpkg.com/source-map@0.7.4/lib/mappings.wasm"
|
|
9
10
|
})
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
const logger = new Logger({name: "ApiMaker / SourceMapsLoader"})
|
|
14
|
+
|
|
12
15
|
export default class SourceMapsLoader {
|
|
13
|
-
constructor
|
|
14
|
-
this.debug = false
|
|
16
|
+
constructor() {
|
|
15
17
|
this.isLoadingSourceMaps = false
|
|
16
18
|
this.sourceMaps = []
|
|
17
19
|
this.srcLoaded = {}
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
loadSourceMapsForScriptTags
|
|
22
|
+
loadSourceMapsForScriptTags(callback) {
|
|
21
23
|
this.loadSourceMapsForScriptTagsCallback = callback
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
sourceMapForSource
|
|
26
|
+
sourceMapForSource(callback) {
|
|
25
27
|
this.sourceMapForSourceCallback = callback
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (error) sources = sources.concat(this.getSourcesFromError(error))
|
|
32
|
-
|
|
33
|
-
return uniqunize(sources, (source) => source.originalUrl)
|
|
34
|
-
}
|
|
30
|
+
async loadSourceMaps(error) {
|
|
31
|
+
if (!error) throw new Error("No error was given to SourceMapsLoader#loadSourceMaps")
|
|
35
32
|
|
|
36
|
-
async loadSourceMaps (error) {
|
|
37
33
|
this.isLoadingSourceMaps = true
|
|
38
34
|
|
|
39
35
|
try {
|
|
@@ -55,6 +51,14 @@ export default class SourceMapsLoader {
|
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
|
|
54
|
+
getSources(error) {
|
|
55
|
+
let sources = this.getSourcesFromScripts()
|
|
56
|
+
|
|
57
|
+
if (error) sources = sources.concat(this.getSourcesFromError(error))
|
|
58
|
+
|
|
59
|
+
return uniqunize(sources, (source) => source.originalUrl)
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
getSourcesFromError(error) {
|
|
59
63
|
const stack = stackTraceParser.parse(error.stack)
|
|
60
64
|
const sources = []
|
|
@@ -65,7 +69,13 @@ export default class SourceMapsLoader {
|
|
|
65
69
|
if (file != "\u003Canonymous>") {
|
|
66
70
|
const sourceMapUrl = this.getMapURL({src: file})
|
|
67
71
|
|
|
68
|
-
if (sourceMapUrl)
|
|
72
|
+
if (sourceMapUrl) {
|
|
73
|
+
logger.debug(() => `Found source map from error: ${sourceMapUrl}`)
|
|
74
|
+
|
|
75
|
+
sources.push({originalUrl: file, sourceMapUrl})
|
|
76
|
+
} else {
|
|
77
|
+
logger.debug(() => `Coudn't get source map from: ${file}`)
|
|
78
|
+
}
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
|
|
@@ -79,7 +89,10 @@ export default class SourceMapsLoader {
|
|
|
79
89
|
for (const script of scripts) {
|
|
80
90
|
const sourceMapUrl = this.getMapURL({script, src: script.src})
|
|
81
91
|
|
|
82
|
-
if (sourceMapUrl)
|
|
92
|
+
if (sourceMapUrl) {
|
|
93
|
+
logger.debug(() => `Found source map from script: ${sourceMapUrl}`)
|
|
94
|
+
sources.push({originalUrl: script.src, sourceMapUrl})
|
|
95
|
+
}
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
return sources
|
|
@@ -98,42 +111,55 @@ export default class SourceMapsLoader {
|
|
|
98
111
|
}
|
|
99
112
|
}
|
|
100
113
|
|
|
101
|
-
includeMapURL(src)
|
|
102
|
-
return src.includes("/packs/")
|
|
103
|
-
}
|
|
114
|
+
includeMapURL = (src) => src.includes("/packs/")
|
|
104
115
|
|
|
105
|
-
async loadSourceMapForSource
|
|
116
|
+
async loadSourceMapForSource({originalUrl, sourceMapUrl}) {
|
|
106
117
|
const xhr = new XMLHttpRequest()
|
|
107
118
|
|
|
108
119
|
xhr.open("GET", sourceMapUrl, true)
|
|
109
120
|
|
|
110
|
-
|
|
121
|
+
try {
|
|
122
|
+
await this.loadXhr(xhr, sourceMapUrl)
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.log(`Couldn't load source map from: ${sourceMapUrl}: ${xhr.responseText}`)
|
|
125
|
+
|
|
126
|
+
return
|
|
127
|
+
}
|
|
111
128
|
|
|
112
129
|
const consumer = await new SourceMapConsumer(xhr.responseText)
|
|
113
130
|
|
|
114
|
-
|
|
131
|
+
if (consumer) {
|
|
132
|
+
this.sourceMaps.push({consumer, originalUrl})
|
|
133
|
+
}
|
|
115
134
|
}
|
|
116
135
|
|
|
117
|
-
loadUrl
|
|
136
|
+
loadUrl(url) {
|
|
118
137
|
const parser = document.createElement("a")
|
|
138
|
+
|
|
119
139
|
parser.href = url
|
|
120
140
|
|
|
121
141
|
return parser
|
|
122
142
|
}
|
|
123
143
|
|
|
124
|
-
loadXhr
|
|
125
|
-
return new Promise((resolve) => {
|
|
126
|
-
xhr.onload = () =>
|
|
127
|
-
|
|
144
|
+
loadXhr(xhr, url) {
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
xhr.onload = () => {
|
|
147
|
+
if (xhr.status == 200) {
|
|
148
|
+
resolve()
|
|
149
|
+
} else {
|
|
150
|
+
reject(new Error(`HTTP request failed with ${xhr.status} for ${url}`))
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
xhr.send()
|
|
128
154
|
})
|
|
129
155
|
}
|
|
130
156
|
|
|
131
|
-
parseStackTrace
|
|
157
|
+
parseStackTrace(stackTrace) {
|
|
132
158
|
return this.getStackTraceData(stackTrace)
|
|
133
159
|
.map((traceData) => `at ${traceData.methodName} (${traceData.fileString})`)
|
|
134
160
|
}
|
|
135
161
|
|
|
136
|
-
getStackTraceData
|
|
162
|
+
getStackTraceData(stackTrace) {
|
|
137
163
|
const stack = stackTraceParser.parse(stackTrace)
|
|
138
164
|
const newSourceMap = []
|
|
139
165
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {digg, digs} from "diggerize"
|
|
2
|
+
import * as inflection from "inflection"
|
|
3
|
+
|
|
4
|
+
const modelConfigRequireContext = require.context("super-admin/model-configs", true, /.jsx$/)
|
|
5
|
+
|
|
6
|
+
export default class ApiMakerSuperAdminConfigReader {
|
|
7
|
+
static forModel(modelClass) {
|
|
8
|
+
const modelNameCamelized = digg(modelClass.modelClassData(), "nameDasherized")
|
|
9
|
+
let modelConfig
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
modelConfig = modelConfigRequireContext(`./${modelNameCamelized}.jsx`).default
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error.message.includes("Cannot find module")) {
|
|
15
|
+
console.debug(`No model-config for ${modelClass.modelClassData().name}`)
|
|
16
|
+
} else {
|
|
17
|
+
throw error
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return new ApiMakerSuperAdminConfigReader(modelClass, modelConfig)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor(modelClass, modelConfig) {
|
|
25
|
+
this.modelClass = modelClass
|
|
26
|
+
this.modelConfig = modelConfig
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
attributesToShow() {
|
|
30
|
+
const {modelConfig} = digs(this, "modelConfig")
|
|
31
|
+
|
|
32
|
+
if (modelConfig?.show?.attributesToShow) {
|
|
33
|
+
return modelConfig.show.attributesToShow()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return this.defaultAttributesToShow()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
defaultAttributesToShow() {
|
|
40
|
+
const attributesToShow = []
|
|
41
|
+
const {columns} = this.defaultTableColumns()
|
|
42
|
+
|
|
43
|
+
for (const column of columns) {
|
|
44
|
+
attributesToShow.push(digg(column, "attribute"))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return attributesToShow
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
tableColumns() {
|
|
51
|
+
const {modelConfig} = digs(this, "modelConfig")
|
|
52
|
+
|
|
53
|
+
if (modelConfig?.table?.columns) {
|
|
54
|
+
return {
|
|
55
|
+
columns: modelConfig.table.columns()
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
return this.defaultTableColumns()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
defaultTableColumns() {
|
|
63
|
+
const {modelClass} = digs(this, "modelClass")
|
|
64
|
+
const attributes = modelClass.attributes()
|
|
65
|
+
const columns = []
|
|
66
|
+
const select = {}
|
|
67
|
+
const modelClassSelect = []
|
|
68
|
+
|
|
69
|
+
select[modelClass.modelClassData().name] = modelClassSelect
|
|
70
|
+
|
|
71
|
+
for (const attribute of attributes) {
|
|
72
|
+
if (!attribute.isSelectedByDefault() && attribute.name() != "name") {
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const camelizedName = inflection.camelize(attribute.name(), true)
|
|
77
|
+
const column = {
|
|
78
|
+
attribute: camelizedName
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (attribute.isColumn()) {
|
|
82
|
+
column.sortKey = camelizedName
|
|
83
|
+
} else if (attribute.isTranslated()) {
|
|
84
|
+
column.sortKey = `currentTranslation${camelizedName}`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
modelClassSelect.push(camelizedName)
|
|
88
|
+
columns.push(column)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {columns, select}
|
|
92
|
+
}
|
|
93
|
+
}
|