@teselagen/ui 0.7.33-beta.2 → 0.7.33-beta.4
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/package.json +1 -1
- package/src/AdvancedOptions.spec.js +26 -0
- package/src/AsyncValidateFieldSpinner/index.js +12 -0
- package/src/BlueprintError/index.js +14 -0
- package/src/BounceLoader/index.js +16 -0
- package/src/BounceLoader/style.css +45 -0
- package/src/CollapsibleCard/index.js +68 -0
- package/src/CollapsibleCard/style.css +23 -0
- package/src/DNALoader/index.js +20 -0
- package/src/DNALoader/style.css +251 -0
- package/src/DataTable/index.js +3209 -0
- package/src/DataTable/style.css +608 -0
- package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +515 -0
- package/src/DataTable/utils/index.js +55 -0
- package/src/DataTable/utils/simplifyHasuraWhere.test.js +73 -0
- package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +219 -0
- package/src/DialogFooter/index.js +86 -0
- package/src/DialogFooter/style.css +9 -0
- package/src/FormComponents/index.js +1266 -0
- package/src/FormComponents/style.css +275 -0
- package/src/FormComponents/utils.js +6 -0
- package/src/HotkeysDialog/index.js +79 -0
- package/src/HotkeysDialog/style.css +54 -0
- package/src/InfoHelper/index.js +78 -0
- package/src/InfoHelper/style.css +7 -0
- package/src/IntentText/index.js +18 -0
- package/src/Loading/index.js +70 -0
- package/src/Loading/style.css +4 -0
- package/src/MenuBar/index.js +423 -0
- package/src/MenuBar/style.css +45 -0
- package/src/PromptUnsavedChanges/index.js +38 -0
- package/src/ResizableDraggableDialog/index.js +141 -0
- package/src/ResizableDraggableDialog/style.css +42 -0
- package/src/ScrollToTop/index.js +72 -0
- package/src/TagSelect/index.js +69 -0
- package/src/TagSelect/style.css +13 -0
- package/src/TgHtmlSelect/index.js +20 -0
- package/src/TgSelect/index.js +537 -0
- package/src/TgSelect/style.css +61 -0
- package/src/TgSuggest/index.js +124 -0
- package/src/Timeline/index.js +15 -0
- package/src/enhancers/withDialog/index.js +196 -0
- package/src/index.js +88 -1
- package/src/showConfirmationDialog/index.js +148 -0
- package/src/style.css +260 -24
- package/AdvancedOptions.js +0 -33
- package/AssignDefaultsModeContext.js +0 -22
- package/DropdownButton.js +0 -36
- package/FillWindow.css +0 -6
- package/FillWindow.js +0 -69
- package/MatchHeaders.js +0 -234
- package/SimpleStepViz.js +0 -22
- package/Tag.js +0 -112
- package/UploadCsvWizard.css +0 -4
- package/UploadCsvWizard.js +0 -719
- package/autoTooltip.js +0 -201
- package/constants.js +0 -1
- package/customIcons.js +0 -361
- package/rerenderOnWindowResize.js +0 -26
- package/showAppSpinner.js +0 -12
- package/showDialogOnDocBody.js +0 -33
- package/src/CellDragHandle.js +0 -132
- package/src/ColumnFilterMenu.js +0 -62
- package/src/Columns.js +0 -979
- package/src/DisabledLoadingComponent.js +0 -15
- package/src/DisplayOptions.js +0 -199
- package/src/DropdownCell.js +0 -61
- package/src/EditableCell.js +0 -44
- package/src/FilterAndSortMenu.js +0 -388
- package/src/FormSeparator.js +0 -9
- package/src/LoadingDots.js +0 -14
- package/src/PagingTool.js +0 -225
- package/src/RenderCell.js +0 -191
- package/src/SearchBar.js +0 -69
- package/src/SortableColumns.js +0 -100
- package/src/TableFormTrackerContext.js +0 -10
- package/src/ThComponent.js +0 -44
- package/src/TimelineEvent.js +0 -31
- package/src/Uploader.js +0 -1278
- package/src/adHoc.js +0 -10
- package/src/basicHandleActionsWithFullState.js +0 -14
- package/src/browserUtils.js +0 -3
- package/src/combineReducersWithFullState.js +0 -14
- package/src/commandControls.js +0 -82
- package/src/commandUtils.js +0 -112
- package/src/convertSchema.js +0 -69
- package/src/dataTableEnhancer.js +0 -41
- package/src/defaultFormatters.js +0 -32
- package/src/defaultValidators.js +0 -40
- package/src/determineBlackOrWhiteTextColor.js +0 -4
- package/src/editCellHelper.js +0 -44
- package/src/filterLocalEntitiesToHasura.js +0 -216
- package/src/formatPasteData.js +0 -16
- package/src/getAllRows.js +0 -11
- package/src/getCellCopyText.js +0 -7
- package/src/getCellInfo.js +0 -36
- package/src/getCellVal.js +0 -20
- package/src/getDayjsFormatter.js +0 -35
- package/src/getFieldPathToField.js +0 -7
- package/src/getIdOrCodeOrIndex.js +0 -9
- package/src/getLastSelectedEntity.js +0 -11
- package/src/getNewEntToSelect.js +0 -25
- package/src/getNewName.js +0 -31
- package/src/getRowCopyText.js +0 -28
- package/src/getTableConfigFromStorage.js +0 -5
- package/src/getTextFromEl.js +0 -28
- package/src/getVals.js +0 -8
- package/src/handleCopyColumn.js +0 -21
- package/src/handleCopyHelper.js +0 -15
- package/src/handleCopyRows.js +0 -23
- package/src/handleCopyTable.js +0 -16
- package/src/handlerHelpers.js +0 -24
- package/src/hotkeyUtils.js +0 -131
- package/src/initializeHasuraWhereAndFilter.js +0 -27
- package/src/isBeingCalledExcessively.js +0 -24
- package/src/isBottomRightCornerOfRectangle.js +0 -20
- package/src/isEntityClean.js +0 -15
- package/src/isTruthy.js +0 -12
- package/src/isValueEmpty.js +0 -3
- package/src/itemUpload.js +0 -84
- package/src/menuUtils.js +0 -433
- package/src/popoverOverflowModifiers.js +0 -11
- package/src/primarySelectedValue.js +0 -1
- package/src/pureNoFunc.js +0 -31
- package/src/queryParams.js +0 -336
- package/src/removeCleanRows.js +0 -22
- package/src/renderOnDoc.js +0 -32
- package/src/rowClick.js +0 -181
- package/src/selection.js +0 -8
- package/src/showProgressToast.js +0 -22
- package/src/simplifyHasuraWhere.js +0 -80
- package/src/sortify.js +0 -73
- package/tableQueryParamsToHasuraClauses.js +0 -113
- package/tagUtils.js +0 -45
- package/tgFormValues.js +0 -35
- package/tg_modalState.js +0 -47
- package/throwFormError.js +0 -16
- package/toastr.js +0 -148
- package/tryToMatchSchemas.js +0 -264
- package/typeToCommonType.js +0 -6
- package/useDeepEqualMemo.js +0 -15
- package/useDialog.js +0 -63
- package/useStableReference.js +0 -9
- package/useTableEntities.js +0 -38
- package/useTraceUpdate.js +0 -19
- package/utils.js +0 -37
- package/validateTableWideErrors.js +0 -160
- package/viewColumn.js +0 -97
- package/withField.js +0 -20
- package/withFields.js +0 -11
- package/withLocalStorage.js +0 -11
- package/withSelectTableRecords.js +0 -43
- package/withSelectedEntities.js +0 -65
- package/withStore.js +0 -10
- package/withTableParams.js +0 -288
- package/wrapDialog.js +0 -116
- /package/{CellDragHandle.js → src/DataTable/CellDragHandle.js} +0 -0
- /package/{ColumnFilterMenu.js → src/DataTable/ColumnFilterMenu.js} +0 -0
- /package/{Columns.js → src/DataTable/Columns.js} +0 -0
- /package/{DisabledLoadingComponent.js → src/DataTable/DisabledLoadingComponent.js} +0 -0
- /package/{DisplayOptions.js → src/DataTable/DisplayOptions.js} +0 -0
- /package/{DropdownCell.js → src/DataTable/DropdownCell.js} +0 -0
- /package/{EditableCell.js → src/DataTable/EditableCell.js} +0 -0
- /package/{FilterAndSortMenu.js → src/DataTable/FilterAndSortMenu.js} +0 -0
- /package/{PagingTool.js → src/DataTable/PagingTool.js} +0 -0
- /package/{RenderCell.js → src/DataTable/RenderCell.js} +0 -0
- /package/{SearchBar.js → src/DataTable/SearchBar.js} +0 -0
- /package/{SortableColumns.js → src/DataTable/SortableColumns.js} +0 -0
- /package/{TableFormTrackerContext.js → src/DataTable/TableFormTrackerContext.js} +0 -0
- /package/{ThComponent.js → src/DataTable/ThComponent.js} +0 -0
- /package/{dataTableEnhancer.js → src/DataTable/dataTableEnhancer.js} +0 -0
- /package/{defaultFormatters.js → src/DataTable/defaultFormatters.js} +0 -0
- /package/{defaultValidators.js → src/DataTable/defaultValidators.js} +0 -0
- /package/{editCellHelper.js → src/DataTable/editCellHelper.js} +0 -0
- /package/{getCellVal.js → src/DataTable/getCellVal.js} +0 -0
- /package/{getVals.js → src/DataTable/getVals.js} +0 -0
- /package/{isTruthy.js → src/DataTable/isTruthy.js} +0 -0
- /package/{isValueEmpty.js → src/DataTable/isValueEmpty.js} +0 -0
- /package/{convertSchema.js → src/DataTable/utils/convertSchema.js} +0 -0
- /package/{filterLocalEntitiesToHasura.js → src/DataTable/utils/filterLocalEntitiesToHasura.js} +0 -0
- /package/{formatPasteData.js → src/DataTable/utils/formatPasteData.js} +0 -0
- /package/{getAllRows.js → src/DataTable/utils/getAllRows.js} +0 -0
- /package/{getCellCopyText.js → src/DataTable/utils/getCellCopyText.js} +0 -0
- /package/{getCellInfo.js → src/DataTable/utils/getCellInfo.js} +0 -0
- /package/{getFieldPathToField.js → src/DataTable/utils/getFieldPathToField.js} +0 -0
- /package/{getIdOrCodeOrIndex.js → src/DataTable/utils/getIdOrCodeOrIndex.js} +0 -0
- /package/{getLastSelectedEntity.js → src/DataTable/utils/getLastSelectedEntity.js} +0 -0
- /package/{getNewEntToSelect.js → src/DataTable/utils/getNewEntToSelect.js} +0 -0
- /package/{getRowCopyText.js → src/DataTable/utils/getRowCopyText.js} +0 -0
- /package/{getTableConfigFromStorage.js → src/DataTable/utils/getTableConfigFromStorage.js} +0 -0
- /package/{handleCopyColumn.js → src/DataTable/utils/handleCopyColumn.js} +0 -0
- /package/{handleCopyHelper.js → src/DataTable/utils/handleCopyHelper.js} +0 -0
- /package/{handleCopyRows.js → src/DataTable/utils/handleCopyRows.js} +0 -0
- /package/{handleCopyTable.js → src/DataTable/utils/handleCopyTable.js} +0 -0
- /package/{initializeHasuraWhereAndFilter.js → src/DataTable/utils/initializeHasuraWhereAndFilter.js} +0 -0
- /package/{isBottomRightCornerOfRectangle.js → src/DataTable/utils/isBottomRightCornerOfRectangle.js} +0 -0
- /package/{isEntityClean.js → src/DataTable/utils/isEntityClean.js} +0 -0
- /package/{primarySelectedValue.js → src/DataTable/utils/primarySelectedValue.js} +0 -0
- /package/{queryParams.js → src/DataTable/utils/queryParams.js} +0 -0
- /package/{removeCleanRows.js → src/DataTable/utils/removeCleanRows.js} +0 -0
- /package/{rowClick.js → src/DataTable/utils/rowClick.js} +0 -0
- /package/{selection.js → src/DataTable/utils/selection.js} +0 -0
- /package/{simplifyHasuraWhere.js → src/DataTable/utils/simplifyHasuraWhere.js} +0 -0
- /package/src/{tableQueryParamsToHasuraClauses.js → DataTable/utils/tableQueryParamsToHasuraClauses.js} +0 -0
- /package/src/{useTableEntities.js → DataTable/utils/useTableEntities.js} +0 -0
- /package/src/{utils.js → DataTable/utils/utils.js} +0 -0
- /package/src/{withSelectedEntities.js → DataTable/utils/withSelectedEntities.js} +0 -0
- /package/src/{withTableParams.js → DataTable/utils/withTableParams.js} +0 -0
- /package/src/{validateTableWideErrors.js → DataTable/validateTableWideErrors.js} +0 -0
- /package/src/{viewColumn.js → DataTable/viewColumn.js} +0 -0
- /package/{FormSeparator.js → src/FormComponents/FormSeparator.js} +0 -0
- /package/{LoadingDots.js → src/FormComponents/LoadingDots.js} +0 -0
- /package/{Uploader.js → src/FormComponents/Uploader.js} +0 -0
- /package/{getNewName.js → src/FormComponents/getNewName.js} +0 -0
- /package/{itemUpload.js → src/FormComponents/itemUpload.js} +0 -0
- /package/{sortify.js → src/FormComponents/sortify.js} +0 -0
- /package/src/{tryToMatchSchemas.js → FormComponents/tryToMatchSchemas.js} +0 -0
- /package/{TimelineEvent.js → src/Timeline/TimelineEvent.js} +0 -0
- /package/{style.css → src/Timeline/style.css} +0 -0
- /package/src/{tg_modalState.js → enhancers/withDialog/tg_modalState.js} +0 -0
- /package/src/{withField.js → enhancers/withField.js} +0 -0
- /package/src/{withFields.js → enhancers/withFields.js} +0 -0
- /package/src/{withLocalStorage.js → enhancers/withLocalStorage.js} +0 -0
- /package/{adHoc.js → src/utils/adHoc.js} +0 -0
- /package/{basicHandleActionsWithFullState.js → src/utils/basicHandleActionsWithFullState.js} +0 -0
- /package/{browserUtils.js → src/utils/browserUtils.js} +0 -0
- /package/{combineReducersWithFullState.js → src/utils/combineReducersWithFullState.js} +0 -0
- /package/{commandControls.js → src/utils/commandControls.js} +0 -0
- /package/{commandUtils.js → src/utils/commandUtils.js} +0 -0
- /package/{determineBlackOrWhiteTextColor.js → src/utils/determineBlackOrWhiteTextColor.js} +0 -0
- /package/{getDayjsFormatter.js → src/utils/getDayjsFormatter.js} +0 -0
- /package/{getTextFromEl.js → src/utils/getTextFromEl.js} +0 -0
- /package/{handlerHelpers.js → src/utils/handlerHelpers.js} +0 -0
- /package/{index.js → src/utils/hooks/index.js} +0 -0
- /package/src/{useDeepEqualMemo.js → utils/hooks/useDeepEqualMemo.js} +0 -0
- /package/src/{useStableReference.js → utils/hooks/useStableReference.js} +0 -0
- /package/{hotkeyUtils.js → src/utils/hotkeyUtils.js} +0 -0
- /package/{isBeingCalledExcessively.js → src/utils/isBeingCalledExcessively.js} +0 -0
- /package/{menuUtils.js → src/utils/menuUtils.js} +0 -0
- /package/{popoverOverflowModifiers.js → src/utils/popoverOverflowModifiers.js} +0 -0
- /package/{pureNoFunc.js → src/utils/pureNoFunc.js} +0 -0
- /package/{renderOnDoc.js → src/utils/renderOnDoc.js} +0 -0
- /package/{showProgressToast.js → src/utils/showProgressToast.js} +0 -0
- /package/src/{tagUtils.js → utils/tagUtils.js} +0 -0
- /package/src/{tgFormValues.js → utils/tgFormValues.js} +0 -0
- /package/src/{useTraceUpdate.js → utils/useTraceUpdate.js} +0 -0
- /package/src/{withSelectTableRecords.js → utils/withSelectTableRecords.js} +0 -0
- /package/src/{withStore.js → utils/withStore.js} +0 -0
package/src/adHoc.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { compose } from "recompose";
|
|
3
|
-
|
|
4
|
-
//adHoc allows you to add dynamic HOCs to a component
|
|
5
|
-
export default func => WrappedComponent => props => {
|
|
6
|
-
const calledFunc = func(props);
|
|
7
|
-
const composeArgs = Array.isArray(calledFunc) ? calledFunc : [calledFunc];
|
|
8
|
-
const ComposedAndWrapped = compose(...composeArgs)(WrappedComponent);
|
|
9
|
-
return <ComposedAndWrapped {...props} />;
|
|
10
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default function basicHandleActionsWithFullState(
|
|
2
|
-
handlers,
|
|
3
|
-
defaultState
|
|
4
|
-
) {
|
|
5
|
-
return (state = defaultState, action, fullState) => {
|
|
6
|
-
const { type } = action;
|
|
7
|
-
const handler = handlers[type];
|
|
8
|
-
if (handler) {
|
|
9
|
-
return handler(state, action, fullState);
|
|
10
|
-
} else {
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
package/src/browserUtils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default function combineReducers(reducers = {}) {
|
|
2
|
-
const reducerKeys = Object.keys(reducers);
|
|
3
|
-
return function combination(state = {}, action, fullState) {
|
|
4
|
-
let hasChanged = false;
|
|
5
|
-
const nextState = {};
|
|
6
|
-
fullState = fullState || state;
|
|
7
|
-
for (let i = 0; i < reducerKeys.length; i++) {
|
|
8
|
-
const key = reducerKeys[i];
|
|
9
|
-
nextState[key] = reducers[key](state[key], action, fullState);
|
|
10
|
-
hasChanged = hasChanged || nextState[key] !== state[key];
|
|
11
|
-
}
|
|
12
|
-
return hasChanged ? nextState : state;
|
|
13
|
-
};
|
|
14
|
-
}
|
package/src/commandControls.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Tooltip, Checkbox, Button, Switch } from "@blueprintjs/core";
|
|
3
|
-
|
|
4
|
-
export const withCommand =
|
|
5
|
-
mappings =>
|
|
6
|
-
WrappedComponent =>
|
|
7
|
-
({ cmd, cmdOptions = {}, ...props }) => {
|
|
8
|
-
const mappedProps = {};
|
|
9
|
-
Object.keys(mappings).forEach(k => {
|
|
10
|
-
mappedProps[k] =
|
|
11
|
-
mappings[k] === "execute"
|
|
12
|
-
? event => cmd.execute({ event })
|
|
13
|
-
: typeof mappings[k] === "function"
|
|
14
|
-
? mappings[k](cmd, props)
|
|
15
|
-
: cmd[mappings[k]];
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
let out = <WrappedComponent {...mappedProps} {...props} />;
|
|
19
|
-
const tooltip =
|
|
20
|
-
cmd.tooltip || (typeof cmd.isDisabled === "string" && cmd.isDisabled);
|
|
21
|
-
if (tooltip && !cmdOptions.ignoreTooltip) {
|
|
22
|
-
out = <Tooltip content={tooltip}>{out}</Tooltip>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return cmd.isHidden && !cmdOptions.ignoreHidden ? null : out;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const CmdCheckbox = withCommand({
|
|
29
|
-
onChange: "execute",
|
|
30
|
-
label: (cmd, props) =>
|
|
31
|
-
props.name ||
|
|
32
|
-
(props.prefix && (
|
|
33
|
-
<React.Fragment>
|
|
34
|
-
{props.prefix}
|
|
35
|
-
{cmd.name}
|
|
36
|
-
</React.Fragment>
|
|
37
|
-
)) ||
|
|
38
|
-
cmd.name,
|
|
39
|
-
disabled: "isDisabled",
|
|
40
|
-
checked: "isActive"
|
|
41
|
-
})(Checkbox);
|
|
42
|
-
|
|
43
|
-
export const CmdSwitch = withCommand({
|
|
44
|
-
onChange: "execute",
|
|
45
|
-
label: (cmd, props) =>
|
|
46
|
-
props.name ||
|
|
47
|
-
(props.prefix && (
|
|
48
|
-
<React.Fragment>
|
|
49
|
-
{props.prefix}
|
|
50
|
-
{cmd.name}
|
|
51
|
-
</React.Fragment>
|
|
52
|
-
)) ||
|
|
53
|
-
cmd.name,
|
|
54
|
-
disabled: "isDisabled",
|
|
55
|
-
checked: "isActive"
|
|
56
|
-
})(Switch);
|
|
57
|
-
|
|
58
|
-
const Div = ({ onChange, children }) => {
|
|
59
|
-
return <div onClick={onChange}>{children}</div>;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const CmdDiv = withCommand({
|
|
63
|
-
onChange: "execute",
|
|
64
|
-
children: (cmd, props) =>
|
|
65
|
-
props.name ||
|
|
66
|
-
(props.prefix && (
|
|
67
|
-
<React.Fragment>
|
|
68
|
-
{props.prefix}
|
|
69
|
-
{cmd.name}
|
|
70
|
-
</React.Fragment>
|
|
71
|
-
)) ||
|
|
72
|
-
cmd.name,
|
|
73
|
-
disabled: "isDisabled",
|
|
74
|
-
checked: "isActive"
|
|
75
|
-
})(Div);
|
|
76
|
-
|
|
77
|
-
export const CmdButton = withCommand({
|
|
78
|
-
onClick: "execute",
|
|
79
|
-
text: cmd => (cmd.isActive === false && cmd.inactiveName) || cmd.name,
|
|
80
|
-
icon: "icon",
|
|
81
|
-
disabled: "isDisabled"
|
|
82
|
-
})(Button);
|
package/src/commandUtils.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { startCase } from "lodash-es";
|
|
2
|
-
|
|
3
|
-
// Generic factory function to create command objects.
|
|
4
|
-
// TODO add documentation
|
|
5
|
-
export function genericCommandFactory(config) {
|
|
6
|
-
const out = {};
|
|
7
|
-
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
for (const cmdId in config.commandDefs) {
|
|
9
|
-
const def = config.commandDefs[cmdId];
|
|
10
|
-
const command = { id: cmdId };
|
|
11
|
-
command.execute = (...execArgs) => {
|
|
12
|
-
config.handleReturn(
|
|
13
|
-
cmdId,
|
|
14
|
-
def.handler &&
|
|
15
|
-
def.handler.apply(command, config.getArguments(cmdId, execArgs))
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const properties = [
|
|
20
|
-
"icon",
|
|
21
|
-
"name",
|
|
22
|
-
"component",
|
|
23
|
-
"shortName",
|
|
24
|
-
"description",
|
|
25
|
-
"hotkey",
|
|
26
|
-
"hotkeyProps",
|
|
27
|
-
"isDisabled",
|
|
28
|
-
"submenu",
|
|
29
|
-
"isActive",
|
|
30
|
-
"isHidden",
|
|
31
|
-
"tooltip",
|
|
32
|
-
"inactiveIcon",
|
|
33
|
-
"inactiveName"
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
properties.forEach(prop => {
|
|
37
|
-
if (def[prop] !== undefined) {
|
|
38
|
-
if (typeof def[prop] === "function") {
|
|
39
|
-
Object.defineProperty(command, prop, {
|
|
40
|
-
get: () => {
|
|
41
|
-
return def[prop].apply(command, config.getArguments(cmdId, []));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
command[prop] = def[prop];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// If no name was specified in the definition, let's try to give some
|
|
51
|
-
// auto-generated names
|
|
52
|
-
if (!def.name) {
|
|
53
|
-
command.name = startCase(cmdId);
|
|
54
|
-
if (def.toggle && cmdId.startsWith("toggle")) {
|
|
55
|
-
command.name = startCase(cmdId.replace("toggle", def.toggle[0] || ""));
|
|
56
|
-
command.inactiveName = startCase(
|
|
57
|
-
cmdId.replace("toggle", def.toggle[1] || "")
|
|
58
|
-
);
|
|
59
|
-
command.shortName = startCase(cmdId.replace("toggle", ""));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
out[cmdId] = command;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return out;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Extract hotkey props from the given commands or command defs, returning
|
|
70
|
-
// a mapping of command ids to hotkey prop objects
|
|
71
|
-
export function getCommandHotkeys(commandsOrDefs) {
|
|
72
|
-
const hotkeyDefs = {};
|
|
73
|
-
Object.keys(commandsOrDefs).forEach(cmdId => {
|
|
74
|
-
if (commandsOrDefs[cmdId].hotkey) {
|
|
75
|
-
hotkeyDefs[cmdId] = {
|
|
76
|
-
combo: commandsOrDefs[cmdId].hotkey,
|
|
77
|
-
label: commandsOrDefs[cmdId].name || startCase(cmdId),
|
|
78
|
-
...commandsOrDefs[cmdId].hotkeyProps
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
return hotkeyDefs;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Extract handler functions from the given commands, returning a mapping of
|
|
87
|
-
// command ids to handlers (directly - no checks added).
|
|
88
|
-
export function getCommandHandlers(commands) {
|
|
89
|
-
const handlers = {};
|
|
90
|
-
Object.keys(commands).forEach(cmdId => {
|
|
91
|
-
handlers[cmdId] = commands[cmdId].execute;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return handlers;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Get hotkey handler functions for the given commands, returning a mapping of
|
|
98
|
-
// command ids to hotkey handlers.
|
|
99
|
-
export function getCommandHotkeyHandlers(commands) {
|
|
100
|
-
const handlers = {};
|
|
101
|
-
Object.keys(commands).forEach(cmdId => {
|
|
102
|
-
if (commands[cmdId].hotkey) {
|
|
103
|
-
handlers[cmdId] = event => {
|
|
104
|
-
if (!commands[cmdId].isDisabled && !commands[cmdId].isHidden) {
|
|
105
|
-
commands[cmdId].execute({ event, viaHotkey: true });
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return handlers;
|
|
112
|
-
}
|
package/src/convertSchema.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { camelCase } from "lodash-es";
|
|
2
|
-
import { startCase, keyBy, map } from "lodash-es";
|
|
3
|
-
|
|
4
|
-
function convertSchema(schema) {
|
|
5
|
-
let schemaToUse = schema;
|
|
6
|
-
if (!schemaToUse.fields && Array.isArray(schema)) {
|
|
7
|
-
schemaToUse = {
|
|
8
|
-
fields: schema
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
schemaToUse = {
|
|
12
|
-
...schemaToUse
|
|
13
|
-
};
|
|
14
|
-
schemaToUse.fields = schemaToUse.fields.map((field, i) => {
|
|
15
|
-
let fieldToUse = field;
|
|
16
|
-
if (typeof field === "string") {
|
|
17
|
-
fieldToUse = {
|
|
18
|
-
displayName: startCase(camelCase(field)),
|
|
19
|
-
path: field,
|
|
20
|
-
type: "string"
|
|
21
|
-
};
|
|
22
|
-
} else if (!field.type) {
|
|
23
|
-
fieldToUse = {
|
|
24
|
-
...field,
|
|
25
|
-
type: "string"
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (!fieldToUse.displayName) {
|
|
29
|
-
fieldToUse = {
|
|
30
|
-
...fieldToUse,
|
|
31
|
-
displayName: startCase(camelCase(fieldToUse.path))
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
// paths are needed for column resizing
|
|
35
|
-
if (!fieldToUse.path) {
|
|
36
|
-
fieldToUse = {
|
|
37
|
-
...fieldToUse,
|
|
38
|
-
filterDisabled: true,
|
|
39
|
-
sortDisabled: true,
|
|
40
|
-
path: "fake-path" + i
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return fieldToUse;
|
|
44
|
-
});
|
|
45
|
-
return schemaToUse;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function mergeSchemas(_originalSchema, _overrideSchema) {
|
|
49
|
-
const originalSchema = convertSchema(_originalSchema);
|
|
50
|
-
const overrideSchema = convertSchema(_overrideSchema);
|
|
51
|
-
|
|
52
|
-
const overridesByKey = keyBy(overrideSchema.fields, "path");
|
|
53
|
-
return {
|
|
54
|
-
...originalSchema,
|
|
55
|
-
...overrideSchema,
|
|
56
|
-
fields: originalSchema.fields
|
|
57
|
-
.map(f => {
|
|
58
|
-
const override = overridesByKey[f.path];
|
|
59
|
-
if (override) {
|
|
60
|
-
delete overridesByKey[f.path];
|
|
61
|
-
return override;
|
|
62
|
-
}
|
|
63
|
-
return f;
|
|
64
|
-
})
|
|
65
|
-
.concat(map(overridesByKey))
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default convertSchema;
|
package/src/dataTableEnhancer.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {options} options
|
|
3
|
-
* @typedef {object} options
|
|
4
|
-
* @property {boolean} isPlural Are we searching for 1 thing or many?
|
|
5
|
-
* @property {string} queryName What the props come back on ( by default = modelName + 'Query')
|
|
6
|
-
*/
|
|
7
|
-
import { reduxForm } from "redux-form";
|
|
8
|
-
import { branch, compose, withProps } from "recompose";
|
|
9
|
-
import { withRouter } from "react-router-dom";
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
Right now DataTable is doing the same as withTableParams, so the logic is being
|
|
13
|
-
run twice. We need to refactor this to make it more DRY.
|
|
14
|
-
We could do two possible refactorings:
|
|
15
|
-
- remove withTableParams and just give all the appropiate props to DataTable. This would
|
|
16
|
-
make the component simpler.
|
|
17
|
-
- remove the logic from DataTable and just use withTableParams and a new hook called
|
|
18
|
-
useTableParams. This would be more flexible in the case we want to be able to use
|
|
19
|
-
pagination in a different component.
|
|
20
|
-
We should avoid having the component handle all the different
|
|
21
|
-
cases of input because of the next reasons:
|
|
22
|
-
1. It makes the component more complex and harder to understand.
|
|
23
|
-
2. It makes the component harder to test.
|
|
24
|
-
3. It makes the component harder to reuse.
|
|
25
|
-
4. Maintaining the the logic in the component is harder.
|
|
26
|
-
Keeping the logic and uses simple makes maintaining easier.
|
|
27
|
-
|
|
28
|
-
In my opinion, reduxForm could be replaced here with regular redux or even just be taken down.
|
|
29
|
-
Could be a major simplification, but this needs to be analized with lims for better
|
|
30
|
-
understanding if it's possible.
|
|
31
|
-
*/
|
|
32
|
-
export default compose(
|
|
33
|
-
// form prop is needed for redux-form, but we are giving this prop as
|
|
34
|
-
// formName, so we need to rename it. Previously it was done in the withTableParams, but now
|
|
35
|
-
// it doesn't have it by default.
|
|
36
|
-
withProps(({ formName }) => ({ form: formName })),
|
|
37
|
-
// the formName is passed via withTableParams and is often user overridden
|
|
38
|
-
branch(props => !props.noForm, reduxForm({})),
|
|
39
|
-
// don't use withRouter if noRouter is passed!
|
|
40
|
-
branch(props => !props.noRouter, withRouter)
|
|
41
|
-
);
|
package/src/defaultFormatters.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { toNumber } from "lodash-es";
|
|
2
|
-
import { getVals } from "./getVals";
|
|
3
|
-
import { isValueEmpty } from "./isValueEmpty";
|
|
4
|
-
import { isTruthy } from "./isTruthy";
|
|
5
|
-
|
|
6
|
-
export const defaultFormatters = {
|
|
7
|
-
boolean: newVal => {
|
|
8
|
-
return isTruthy(newVal);
|
|
9
|
-
},
|
|
10
|
-
dropdown: (newVal, field) => {
|
|
11
|
-
const valsMap = {};
|
|
12
|
-
getVals(field.values).forEach(v => {
|
|
13
|
-
valsMap[v.toLowerCase().trim()] = v;
|
|
14
|
-
});
|
|
15
|
-
return valsMap[newVal?.toLowerCase().trim()] || newVal;
|
|
16
|
-
},
|
|
17
|
-
dropdownMulti: (newVal, field) => {
|
|
18
|
-
const valsMap = {};
|
|
19
|
-
getVals(field.values).forEach(v => {
|
|
20
|
-
valsMap[v.toLowerCase().trim()] = v;
|
|
21
|
-
});
|
|
22
|
-
if (!newVal) return;
|
|
23
|
-
return newVal
|
|
24
|
-
.split(",")
|
|
25
|
-
.map(v => valsMap[v.toLowerCase().trim()] || v)
|
|
26
|
-
.join(",");
|
|
27
|
-
},
|
|
28
|
-
number: newVal => {
|
|
29
|
-
if (isValueEmpty(newVal)) return newVal;
|
|
30
|
-
return toNumber(newVal);
|
|
31
|
-
}
|
|
32
|
-
};
|
package/src/defaultValidators.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { isNumber } from "lodash-es";
|
|
2
|
-
import { getVals } from "./getVals";
|
|
3
|
-
import { isValueEmpty } from "./isValueEmpty";
|
|
4
|
-
|
|
5
|
-
export const defaultValidators = {
|
|
6
|
-
dropdown: (newVal, field) => {
|
|
7
|
-
const err = "Please choose one of the accepted values";
|
|
8
|
-
if (!newVal) {
|
|
9
|
-
if (field.isRequired) return err;
|
|
10
|
-
} else if (!getVals(field.values).includes(newVal)) {
|
|
11
|
-
return err;
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
dropdownMulti: (newVal, field) => {
|
|
15
|
-
const err = "Please choose one of the accepted values";
|
|
16
|
-
if (!newVal) {
|
|
17
|
-
if (field.isRequired) return err;
|
|
18
|
-
} else {
|
|
19
|
-
let err;
|
|
20
|
-
newVal.split(",").some(v => {
|
|
21
|
-
if (!getVals(field.values).includes(v)) {
|
|
22
|
-
err = `${v} is not an accepted value`;
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
});
|
|
27
|
-
return err;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
number: (newVal, field) => {
|
|
31
|
-
if (isValueEmpty(newVal) && !field.isRequired) return;
|
|
32
|
-
if (isNaN(newVal) || !isNumber(newVal)) {
|
|
33
|
-
return "Must be a number";
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
string: (newVal, field) => {
|
|
37
|
-
if (!field.isRequired) return false;
|
|
38
|
-
if (!newVal) return "Please enter a value here";
|
|
39
|
-
}
|
|
40
|
-
};
|
package/src/editCellHelper.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { set } from "lodash-es";
|
|
2
|
-
import { defaultValidators } from "./defaultValidators";
|
|
3
|
-
import { defaultFormatters } from "./defaultFormatters";
|
|
4
|
-
|
|
5
|
-
//(mutative) responsible for formatting and then validating the
|
|
6
|
-
|
|
7
|
-
export const editCellHelper = ({
|
|
8
|
-
entity,
|
|
9
|
-
path,
|
|
10
|
-
schema,
|
|
11
|
-
columnSchema,
|
|
12
|
-
newVal
|
|
13
|
-
}) => {
|
|
14
|
-
let nv = newVal;
|
|
15
|
-
|
|
16
|
-
const colSchema =
|
|
17
|
-
columnSchema || schema?.fields?.find(({ path: p }) => p === path) || {};
|
|
18
|
-
path = path || colSchema.path;
|
|
19
|
-
const { format, validate, type } = colSchema;
|
|
20
|
-
let error;
|
|
21
|
-
if (nv === undefined && colSchema.defaultValue !== undefined)
|
|
22
|
-
nv = colSchema.defaultValue;
|
|
23
|
-
|
|
24
|
-
if (format) {
|
|
25
|
-
nv = format(nv, colSchema);
|
|
26
|
-
}
|
|
27
|
-
if (defaultFormatters[type]) {
|
|
28
|
-
nv = defaultFormatters[type](nv, colSchema);
|
|
29
|
-
}
|
|
30
|
-
if (validate) {
|
|
31
|
-
error = validate(nv, colSchema, entity);
|
|
32
|
-
}
|
|
33
|
-
if (!error) {
|
|
34
|
-
const validator =
|
|
35
|
-
defaultValidators[type] ||
|
|
36
|
-
type === "string" ||
|
|
37
|
-
(type === undefined && defaultValidators.string);
|
|
38
|
-
if (validator) {
|
|
39
|
-
error = validator(nv, colSchema);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
set(entity, path, nv);
|
|
43
|
-
return { entity, error };
|
|
44
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isEmpty,
|
|
3
|
-
every,
|
|
4
|
-
some,
|
|
5
|
-
isEqual,
|
|
6
|
-
isString,
|
|
7
|
-
isNull,
|
|
8
|
-
isArray,
|
|
9
|
-
includes,
|
|
10
|
-
isObject,
|
|
11
|
-
has,
|
|
12
|
-
orderBy
|
|
13
|
-
} from "lodash-es";
|
|
14
|
-
|
|
15
|
-
export function filterLocalEntitiesToHasura(
|
|
16
|
-
records,
|
|
17
|
-
{ where, order_by, limit, offset, isInfinite } = {}
|
|
18
|
-
) {
|
|
19
|
-
let filteredRecords = [...records];
|
|
20
|
-
|
|
21
|
-
// Apply where clause if it exists
|
|
22
|
-
if (where) {
|
|
23
|
-
filteredRecords = applyWhereClause(filteredRecords, where);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Apply order_by if it exists
|
|
27
|
-
if (order_by) {
|
|
28
|
-
filteredRecords = applyOrderBy(filteredRecords, order_by);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Store the complete filtered and ordered records for pagination info
|
|
32
|
-
const allFilteredRecords = [...filteredRecords];
|
|
33
|
-
|
|
34
|
-
// Apply limit and offset
|
|
35
|
-
if (!isInfinite && offset !== undefined) {
|
|
36
|
-
filteredRecords = filteredRecords.slice(offset);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!isInfinite && limit !== undefined) {
|
|
40
|
-
filteredRecords = filteredRecords.slice(0, limit);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// For consistency, always return an object with entities, entitiesAcrossPages, and entityCount
|
|
44
|
-
return {
|
|
45
|
-
entities: filteredRecords,
|
|
46
|
-
entitiesAcrossPages: allFilteredRecords,
|
|
47
|
-
entityCount: allFilteredRecords.length
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function applyWhereClause(records, where) {
|
|
52
|
-
function applyFilter(record, filter) {
|
|
53
|
-
if (isEmpty(filter)) {
|
|
54
|
-
return true; // No filter, all records pass
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
for (const key in filter) {
|
|
58
|
-
if (key === "_and") {
|
|
59
|
-
if (!every(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
} else if (key === "_or") {
|
|
63
|
-
if (!some(filter[key], subFilter => applyFilter(record, subFilter))) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
} else if (key === "_not") {
|
|
67
|
-
if (applyFilter(record, filter[key])) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
const value = record[key];
|
|
72
|
-
const conditions = filter[key];
|
|
73
|
-
|
|
74
|
-
for (const operator in conditions) {
|
|
75
|
-
const conditionValue = conditions[operator];
|
|
76
|
-
|
|
77
|
-
// Handle range conditions (_gt/_lt or _gte/_lte combinations)
|
|
78
|
-
if (operator === "_gt" && conditions._lt) {
|
|
79
|
-
if (!(value > conditionValue && value < conditions._lt))
|
|
80
|
-
return false;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (operator === "_gte" && conditions._lte) {
|
|
84
|
-
if (!(value >= conditionValue && value <= conditions._lte))
|
|
85
|
-
return false;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
switch (operator) {
|
|
90
|
-
case "_eq":
|
|
91
|
-
if (!isEqual(value, conditionValue)) return false;
|
|
92
|
-
break;
|
|
93
|
-
case "_neq":
|
|
94
|
-
if (isEqual(value, conditionValue)) return false;
|
|
95
|
-
break;
|
|
96
|
-
case "_gt":
|
|
97
|
-
if (!(value > conditionValue)) return false;
|
|
98
|
-
break;
|
|
99
|
-
case "_gte":
|
|
100
|
-
if (!(value >= conditionValue)) return false;
|
|
101
|
-
break;
|
|
102
|
-
case "_lt":
|
|
103
|
-
if (!(value < conditionValue)) return false;
|
|
104
|
-
break;
|
|
105
|
-
case "_lte":
|
|
106
|
-
if (!(value <= conditionValue)) return false;
|
|
107
|
-
break;
|
|
108
|
-
case "_like":
|
|
109
|
-
if (
|
|
110
|
-
!isString(value) ||
|
|
111
|
-
!new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
112
|
-
)
|
|
113
|
-
return false;
|
|
114
|
-
break;
|
|
115
|
-
case "_ilike":
|
|
116
|
-
if (
|
|
117
|
-
!isString(value) ||
|
|
118
|
-
!new RegExp(conditionValue.replace(/%/g, ".*"), "i").test(value)
|
|
119
|
-
)
|
|
120
|
-
return false;
|
|
121
|
-
break;
|
|
122
|
-
case "_nlike":
|
|
123
|
-
if (
|
|
124
|
-
!isString(value) ||
|
|
125
|
-
new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
126
|
-
)
|
|
127
|
-
return false;
|
|
128
|
-
break;
|
|
129
|
-
case "_nilike":
|
|
130
|
-
if (
|
|
131
|
-
!isString(value) ||
|
|
132
|
-
new RegExp(conditionValue.replace(/%/g, ".*"), "i").test(value)
|
|
133
|
-
)
|
|
134
|
-
return false;
|
|
135
|
-
break;
|
|
136
|
-
case "_starts_with":
|
|
137
|
-
if (!isString(value) || !value.startsWith(conditionValue))
|
|
138
|
-
return false;
|
|
139
|
-
break;
|
|
140
|
-
case "_ends_with":
|
|
141
|
-
if (!isString(value) || !value.endsWith(conditionValue))
|
|
142
|
-
return false;
|
|
143
|
-
break;
|
|
144
|
-
case "_is_null":
|
|
145
|
-
if (
|
|
146
|
-
(conditionValue && !isNull(value)) ||
|
|
147
|
-
(!conditionValue && isNull(value))
|
|
148
|
-
)
|
|
149
|
-
return false;
|
|
150
|
-
break;
|
|
151
|
-
case "_contains":
|
|
152
|
-
if (
|
|
153
|
-
!isArray(value) ||
|
|
154
|
-
!every(conditionValue, item => includes(value, item))
|
|
155
|
-
)
|
|
156
|
-
return false;
|
|
157
|
-
break;
|
|
158
|
-
case "_contained_in":
|
|
159
|
-
if (
|
|
160
|
-
!isArray(value) ||
|
|
161
|
-
!every(value, item => includes(conditionValue, item))
|
|
162
|
-
)
|
|
163
|
-
return false;
|
|
164
|
-
break;
|
|
165
|
-
case "_has_key":
|
|
166
|
-
if (!isObject(value) || !has(value, conditionValue)) return false;
|
|
167
|
-
break;
|
|
168
|
-
case "_has_keys_any":
|
|
169
|
-
if (
|
|
170
|
-
!isObject(value) ||
|
|
171
|
-
!some(conditionValue, item => has(value, item))
|
|
172
|
-
)
|
|
173
|
-
return false;
|
|
174
|
-
break;
|
|
175
|
-
case "_has_keys_all":
|
|
176
|
-
if (
|
|
177
|
-
!isObject(value) ||
|
|
178
|
-
!every(conditionValue, item => has(value, item))
|
|
179
|
-
)
|
|
180
|
-
return false;
|
|
181
|
-
break;
|
|
182
|
-
case "_similar":
|
|
183
|
-
if (
|
|
184
|
-
!isString(value) ||
|
|
185
|
-
!new RegExp(conditionValue.replace(/%/g, ".*")).test(value)
|
|
186
|
-
)
|
|
187
|
-
return false;
|
|
188
|
-
break;
|
|
189
|
-
default:
|
|
190
|
-
if (operator.startsWith("_")) {
|
|
191
|
-
console.warn(`Unsupported operator: ${operator}`);
|
|
192
|
-
return false;
|
|
193
|
-
} else {
|
|
194
|
-
console.warn(`Unsupported operator: ${operator}`);
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return records.filter(record => applyFilter(record, where));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function applyOrderBy(records, order_by) {
|
|
209
|
-
const keys = Object.keys(order_by);
|
|
210
|
-
if (keys.length > 0) {
|
|
211
|
-
const field = keys[0];
|
|
212
|
-
const direction = order_by[field] === "asc" ? "asc" : "desc";
|
|
213
|
-
return orderBy(records, [field], [direction]);
|
|
214
|
-
}
|
|
215
|
-
return records;
|
|
216
|
-
}
|