@macrostrat/data-sheet 4.1.0 → 4.2.0
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/CHANGELOG.md +40 -0
- package/dist/actions/builtin.cjs +1 -1
- package/dist/actions/builtin.cjs.map +1 -1
- package/dist/actions/builtin.d.ts +0 -2
- package/dist/actions/builtin.js +1 -1
- package/dist/actions/builtin.js.map +1 -1
- package/dist/actions/clipboard.cjs +1 -1
- package/dist/actions/clipboard.cjs.map +1 -1
- package/dist/actions/clipboard.d.ts +3 -2
- package/dist/actions/clipboard.js +1 -1
- package/dist/actions/clipboard.js.map +1 -1
- package/dist/actions/column-controls.cjs +7 -184
- package/dist/actions/column-controls.cjs.map +1 -1
- package/dist/actions/column-controls.d.ts +1 -1
- package/dist/actions/column-controls.js +5 -182
- package/dist/actions/column-controls.js.map +1 -1
- package/dist/actions/column-filter.cjs +24 -50
- package/dist/actions/column-filter.cjs.map +1 -1
- package/dist/actions/column-filter.d.ts +6 -4
- package/dist/actions/column-filter.js +25 -51
- package/dist/actions/column-filter.js.map +1 -1
- package/dist/actions/context.cjs +147 -0
- package/dist/actions/context.cjs.map +1 -0
- package/dist/actions/context.d.ts +93 -0
- package/dist/actions/context.js +145 -0
- package/dist/actions/context.js.map +1 -0
- package/dist/actions/edit-actions.cjs.map +1 -1
- package/dist/actions/edit-actions.d.ts +3 -1
- package/dist/actions/edit-actions.js.map +1 -1
- package/dist/actions/index.d.ts +2 -3
- package/dist/actions/selection.cjs +70 -115
- package/dist/actions/selection.cjs.map +1 -1
- package/dist/actions/selection.d.ts +22 -12
- package/dist/actions/selection.js +71 -114
- package/dist/actions/selection.js.map +1 -1
- package/dist/actions/{table-controls.cjs → table-actions.cjs} +7 -24
- package/dist/actions/table-actions.cjs.map +1 -0
- package/dist/actions/{table-controls.d.ts → table-actions.d.ts} +0 -4
- package/dist/actions/{table-controls.js → table-actions.js} +2 -19
- package/dist/actions/table-actions.js.map +1 -0
- package/dist/actions/types.d.ts +11 -89
- package/dist/components/cell-detail.cjs +6 -6
- package/dist/components/cell-detail.cjs.map +1 -1
- package/dist/components/cell-detail.js +1 -1
- package/dist/components/colors.cjs.map +1 -1
- package/dist/components/colors.js.map +1 -1
- package/dist/components/editor-popup.cjs +7 -7
- package/dist/components/editor-popup.cjs.map +1 -1
- package/dist/components/editor-popup.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/indicators/filter-and-sort.cjs +378 -0
- package/dist/components/indicators/filter-and-sort.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.d.ts +59 -0
- package/dist/components/indicators/filter-and-sort.js +376 -0
- package/dist/components/indicators/filter-and-sort.js.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs +16 -0
- package/dist/components/indicators/filter-and-sort.module.sass.cjs.map +1 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js +14 -0
- package/dist/components/indicators/filter-and-sort.module.sass.js.map +1 -0
- package/dist/components/indicators/index.d.ts +4 -0
- package/dist/components/indicators/selection.cjs +113 -0
- package/dist/components/indicators/selection.cjs.map +1 -0
- package/dist/components/indicators/selection.d.ts +3 -0
- package/dist/components/indicators/selection.js +111 -0
- package/dist/components/indicators/selection.js.map +1 -0
- package/dist/components/indicators/selection.module.sass.cjs +19 -0
- package/dist/components/indicators/selection.module.sass.cjs.map +1 -0
- package/dist/components/indicators/selection.module.sass.js +17 -0
- package/dist/components/indicators/selection.module.sass.js.map +1 -0
- package/dist/components/indicators/unified-filters.cjs +130 -0
- package/dist/components/indicators/unified-filters.cjs.map +1 -0
- package/dist/components/indicators/unified-filters.d.ts +10 -0
- package/dist/components/indicators/unified-filters.js +130 -0
- package/dist/components/indicators/unified-filters.js.map +1 -0
- package/dist/components/indicators/view-info.cjs +59 -0
- package/dist/components/indicators/view-info.cjs.map +1 -0
- package/dist/components/{view-info.d.ts → indicators/view-info.d.ts} +1 -0
- package/dist/components/{view-info.js → indicators/view-info.js} +17 -13
- package/dist/components/indicators/view-info.js.map +1 -0
- package/dist/components/text-areas.cjs +5 -5
- package/dist/components/text-areas.cjs.map +1 -1
- package/dist/components/text-areas.js +1 -1
- package/dist/components/toolbars/actions-toolbar.cjs +185 -0
- package/dist/components/toolbars/actions-toolbar.cjs.map +1 -0
- package/dist/{actions/toolbar.d.ts → components/toolbars/actions-toolbar.d.ts} +9 -5
- package/dist/{actions/toolbar.js → components/toolbars/actions-toolbar.js} +36 -97
- package/dist/components/toolbars/actions-toolbar.js.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs +29 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.cjs.map +1 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js +27 -0
- package/dist/components/toolbars/actions-toolbar.module.sass.js.map +1 -0
- package/dist/components/toolbars/active-filters.cjs +120 -0
- package/dist/components/toolbars/active-filters.cjs.map +1 -0
- package/dist/{actions/filters.d.ts → components/toolbars/active-filters.d.ts} +3 -3
- package/dist/components/toolbars/active-filters.js +120 -0
- package/dist/components/toolbars/active-filters.js.map +1 -0
- package/dist/components/toolbars/index.d.ts +2 -0
- package/dist/data-panel.cjs +291 -0
- package/dist/data-panel.cjs.map +1 -0
- package/dist/data-panel.d.ts +110 -0
- package/dist/data-panel.js +289 -0
- package/dist/data-panel.js.map +1 -0
- package/dist/data-panel.module.sass.cjs +40 -0
- package/dist/data-panel.module.sass.cjs.map +1 -0
- package/dist/data-panel.module.sass.js +38 -0
- package/dist/data-panel.module.sass.js.map +1 -0
- package/dist/{core.cjs → data-sheet.cjs} +123 -181
- package/dist/data-sheet.cjs.map +1 -0
- package/dist/data-sheet.css +241 -13
- package/dist/data-sheet.d.ts +16 -0
- package/dist/{core.js → data-sheet.js} +92 -150
- package/dist/data-sheet.js.map +1 -0
- package/dist/data-view.cjs +47 -0
- package/dist/data-view.cjs.map +1 -0
- package/dist/data-view.d.ts +15 -0
- package/dist/data-view.js +45 -0
- package/dist/data-view.js.map +1 -0
- package/dist/filters/operators.cjs +21 -4
- package/dist/filters/operators.cjs.map +1 -1
- package/dist/filters/operators.d.ts +5 -4
- package/dist/filters/operators.js +21 -4
- package/dist/filters/operators.js.map +1 -1
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -17
- package/dist/index.js.map +1 -1
- package/dist/notifications.cjs +4 -4
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.js +1 -1
- package/dist/postgrest-table/data-loaders.cjs +129 -103
- package/dist/postgrest-table/data-loaders.cjs.map +1 -1
- package/dist/postgrest-table/data-loaders.d.ts +52 -82
- package/dist/postgrest-table/data-loaders.js +110 -84
- package/dist/postgrest-table/data-loaders.js.map +1 -1
- package/dist/postgrest-table/index.cjs +18 -17
- package/dist/postgrest-table/index.cjs.map +1 -1
- package/dist/postgrest-table/index.d.ts +4 -3
- package/dist/postgrest-table/index.js +9 -8
- package/dist/postgrest-table/index.js.map +1 -1
- package/dist/{utils → provider}/column-spec.cjs +23 -9
- package/dist/provider/column-spec.cjs.map +1 -0
- package/dist/{utils → provider}/column-spec.d.ts +77 -2
- package/dist/{utils → provider}/column-spec.js +24 -10
- package/dist/provider/column-spec.js.map +1 -0
- package/dist/provider/core.cjs +382 -0
- package/dist/provider/core.cjs.map +1 -0
- package/dist/provider/core.d.ts +74 -0
- package/dist/provider/core.js +380 -0
- package/dist/provider/core.js.map +1 -0
- package/dist/provider/index.d.ts +7 -0
- package/dist/provider/interactions.cjs +128 -0
- package/dist/provider/interactions.cjs.map +1 -0
- package/dist/provider/interactions.d.ts +39 -0
- package/dist/provider/interactions.js +128 -0
- package/dist/provider/interactions.js.map +1 -0
- package/dist/provider/selection.cjs +29 -0
- package/dist/provider/selection.cjs.map +1 -0
- package/dist/provider/selection.d.ts +9 -0
- package/dist/provider/selection.js +29 -0
- package/dist/provider/selection.js.map +1 -0
- package/dist/provider/table-data.cjs +92 -0
- package/dist/provider/table-data.cjs.map +1 -0
- package/dist/provider/table-data.d.ts +81 -0
- package/dist/provider/table-data.js +92 -0
- package/dist/provider/table-data.js.map +1 -0
- package/dist/provider/types.cjs +22 -0
- package/dist/provider/types.cjs.map +1 -0
- package/dist/provider/types.d.ts +256 -0
- package/dist/provider/types.js +22 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/{zustand-store.cjs → provider/zustand-store.cjs} +37 -23
- package/dist/provider/zustand-store.cjs.map +1 -0
- package/dist/{zustand-store.js → provider/zustand-store.js} +22 -8
- package/dist/provider/zustand-store.js.map +1 -0
- package/dist/{cell-renderer.cjs → renderers/cell-renderer.cjs} +68 -35
- package/dist/renderers/cell-renderer.cjs.map +1 -0
- package/dist/{cell-renderer.d.ts → renderers/cell-renderer.d.ts} +1 -2
- package/dist/{cell-renderer.js → renderers/cell-renderer.js} +66 -33
- package/dist/renderers/cell-renderer.js.map +1 -0
- package/dist/renderers/column-header-cell.cjs +40 -17
- package/dist/renderers/column-header-cell.cjs.map +1 -1
- package/dist/renderers/column-header-cell.d.ts +2 -2
- package/dist/renderers/column-header-cell.js +40 -17
- package/dist/renderers/column-header-cell.js.map +1 -1
- package/dist/renderers/index.d.ts +1 -0
- package/dist/types.cjs +7 -19
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +123 -226
- package/dist/types.js +7 -19
- package/dist/types.js.map +1 -1
- package/dist/utils/atoms.cjs +24 -0
- package/dist/utils/atoms.cjs.map +1 -0
- package/dist/utils/atoms.d.ts +4 -0
- package/dist/utils/atoms.js +24 -0
- package/dist/utils/atoms.js.map +1 -0
- package/dist/utils/debug-overlay.cjs.map +1 -1
- package/dist/utils/debug-overlay.js.map +1 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/key-handling.cjs +140 -139
- package/dist/utils/key-handling.cjs.map +1 -1
- package/dist/utils/key-handling.d.ts +4 -2
- package/dist/utils/key-handling.js +136 -135
- package/dist/utils/key-handling.js.map +1 -1
- package/dist/utils/validation.cjs +6 -1
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +6 -1
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -3
- package/src/actions/builtin.ts +1 -4
- package/src/actions/clipboard.ts +4 -3
- package/src/actions/column-controls.ts +12 -228
- package/src/actions/column-filter.ts +28 -63
- package/src/actions/context.ts +299 -0
- package/src/actions/edit-actions.ts +3 -1
- package/src/actions/index.ts +2 -3
- package/src/actions/selection.ts +109 -156
- package/src/actions/{table-controls.ts → table-actions.ts} +0 -20
- package/src/actions/types.ts +17 -101
- package/src/components/colors.ts +1 -1
- package/src/components/index.ts +2 -1
- package/src/components/indicators/filter-and-sort.module.sass +13 -0
- package/src/components/indicators/filter-and-sort.ts +478 -0
- package/src/components/indicators/index.ts +4 -0
- package/src/components/indicators/selection.module.sass +22 -0
- package/src/components/indicators/selection.ts +141 -0
- package/src/components/indicators/unified-filters.ts +161 -0
- package/src/components/{view-info.ts → indicators/view-info.ts} +16 -27
- package/src/{actions/toolbar.module.sass → components/toolbars/actions-toolbar.module.sass} +17 -4
- package/src/{actions/toolbar.ts → components/toolbars/actions-toolbar.ts} +53 -126
- package/src/components/toolbars/active-filters.ts +150 -0
- package/src/components/toolbars/index.ts +2 -0
- package/src/data-panel.module.sass +185 -0
- package/src/data-panel.ts +556 -0
- package/src/{core.ts → data-sheet.ts} +144 -306
- package/src/data-view.ts +70 -0
- package/src/filters/operators.ts +38 -6
- package/src/index.ts +4 -3
- package/src/postgrest-table/data-loaders.ts +250 -181
- package/src/postgrest-table/index.ts +10 -9
- package/src/{utils → provider}/column-spec.ts +34 -15
- package/src/provider/core.ts +585 -0
- package/src/provider/index.ts +7 -0
- package/src/provider/interactions.ts +161 -0
- package/src/provider/selection.ts +31 -0
- package/src/provider/table-data.ts +178 -0
- package/src/provider/types.ts +273 -0
- package/src/{zustand-store.ts → provider/zustand-store.ts} +36 -14
- package/src/{cell-renderer.ts → renderers/cell-renderer.ts} +146 -58
- package/src/renderers/column-header-cell.ts +51 -17
- package/src/renderers/index.ts +1 -0
- package/src/types.ts +143 -236
- package/src/utils/atoms.ts +28 -0
- package/src/utils/debug-overlay.ts +1 -1
- package/src/utils/index.ts +2 -8
- package/src/utils/key-handling.ts +170 -164
- package/src/utils/validation.ts +7 -2
- package/dist/actions/filters.cjs +0 -139
- package/dist/actions/filters.cjs.map +0 -1
- package/dist/actions/filters.js +0 -139
- package/dist/actions/filters.js.map +0 -1
- package/dist/actions/table-controls.cjs.map +0 -1
- package/dist/actions/table-controls.js.map +0 -1
- package/dist/actions/toolbar.cjs +0 -246
- package/dist/actions/toolbar.cjs.map +0 -1
- package/dist/actions/toolbar.js.map +0 -1
- package/dist/actions/toolbar.module.sass.cjs +0 -27
- package/dist/actions/toolbar.module.sass.cjs.map +0 -1
- package/dist/actions/toolbar.module.sass.js +0 -25
- package/dist/actions/toolbar.module.sass.js.map +0 -1
- package/dist/cell-renderer.cjs.map +0 -1
- package/dist/cell-renderer.js.map +0 -1
- package/dist/components/view-info.cjs +0 -55
- package/dist/components/view-info.cjs.map +0 -1
- package/dist/components/view-info.js.map +0 -1
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -113
- package/dist/core.js.map +0 -1
- package/dist/provider.cjs +0 -191
- package/dist/provider.cjs.map +0 -1
- package/dist/provider.d.ts +0 -25
- package/dist/provider.js +0 -189
- package/dist/provider.js.map +0 -1
- package/dist/table-updates/data-parameter.d.ts +0 -14
- package/dist/table-updates/filter.d.ts +0 -16
- package/dist/table-updates/index.d.ts +0 -19
- package/dist/utils/column-spec.cjs.map +0 -1
- package/dist/utils/column-spec.js.map +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/zustand-store.cjs.map +0 -1
- package/dist/zustand-store.js.map +0 -1
- package/src/actions/filters.ts +0 -176
- package/src/components/actions.module.sass +0 -8
- package/src/provider.ts +0 -250
- package/src/table-updates/data-parameter.ts +0 -44
- package/src/table-updates/filter.ts +0 -124
- package/src/table-updates/index.ts +0 -239
- /package/dist/{zustand-store.d.ts → provider/zustand-store.d.ts} +0 -0
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Filter,
|
|
3
|
-
createFiltersKey,
|
|
4
|
-
addFilterToURL,
|
|
5
|
-
rowPassesFilters,
|
|
6
|
-
} from "./filter";
|
|
7
|
-
import { DataParameters, cloneDataParameters } from "./data-parameter";
|
|
8
|
-
import {
|
|
9
|
-
ProgressPopoverProps,
|
|
10
|
-
submitColumnCopy,
|
|
11
|
-
} from "#/maps/ingestion/@id/components";
|
|
12
|
-
|
|
13
|
-
export interface TableUpdate {
|
|
14
|
-
// Used to merge updates
|
|
15
|
-
key?: string;
|
|
16
|
-
// Column
|
|
17
|
-
column: string;
|
|
18
|
-
// Helpful for debugging
|
|
19
|
-
description?: string;
|
|
20
|
-
// Function to execute this update
|
|
21
|
-
execute: () => Promise<void>;
|
|
22
|
-
// Function to lyTablely this update to a cell
|
|
23
|
-
applyToCell: (
|
|
24
|
-
currentValue: boolean | string | number | null,
|
|
25
|
-
row: Record<string, boolean | string | number | null>,
|
|
26
|
-
cellColumnName: string,
|
|
27
|
-
) => string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const applyTableUpdate = (
|
|
31
|
-
data: Record<string, boolean | string | number | null>[],
|
|
32
|
-
tableUpdate: TableUpdate,
|
|
33
|
-
) => {
|
|
34
|
-
for (const [rowIndex, row] of data.entries()) {
|
|
35
|
-
data[rowIndex][tableUpdate.column] = tableUpdate.applyToCell(
|
|
36
|
-
data[rowIndex][tableUpdate.column],
|
|
37
|
-
row,
|
|
38
|
-
tableUpdate.column,
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return data;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const applyTableUpdates = (
|
|
46
|
-
data: Record<string, boolean | string | number | null>[],
|
|
47
|
-
tableUpdates: TableUpdate[],
|
|
48
|
-
) => {
|
|
49
|
-
for (const tableUpdate of tableUpdates) {
|
|
50
|
-
data = applyTableUpdate(data, tableUpdate);
|
|
51
|
-
}
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const createTableUpdateCopyColumn = (
|
|
56
|
-
url: string,
|
|
57
|
-
selectedColumn: string,
|
|
58
|
-
copiedColumn: string,
|
|
59
|
-
dataParameters: DataParameters,
|
|
60
|
-
): TableUpdate => {
|
|
61
|
-
dataParameters = cloneDataParameters(dataParameters);
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
column: selectedColumn,
|
|
65
|
-
description: `Copy column ${copiedColumn} to ${selectedColumn}`,
|
|
66
|
-
applyToCell: (value, row, cellColumnName) => {
|
|
67
|
-
if (!rowPassesFilters(row, Object.values(dataParameters.filter))) {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (cellColumnName == selectedColumn) {
|
|
72
|
-
return row[copiedColumn];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return value;
|
|
76
|
-
},
|
|
77
|
-
execute: async () => {
|
|
78
|
-
await submitColumnCopy(url, copiedColumn, selectedColumn, dataParameters);
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const createTableUpdate = (
|
|
84
|
-
url: string,
|
|
85
|
-
value: string,
|
|
86
|
-
columnName: string,
|
|
87
|
-
row: Record<string, boolean | string | number | null>,
|
|
88
|
-
dataParameters: DataParameters,
|
|
89
|
-
): TableUpdate => {
|
|
90
|
-
/** Create an update operation that is queued for application to the
|
|
91
|
-
* table
|
|
92
|
-
*/
|
|
93
|
-
console.log(url, value, columnName, row, dataParameters);
|
|
94
|
-
let newDataParameters = cloneDataParameters(dataParameters);
|
|
95
|
-
|
|
96
|
-
// If we are grouped by a column, set the filter based on that.
|
|
97
|
-
|
|
98
|
-
const group = newDataParameters.group;
|
|
99
|
-
|
|
100
|
-
if (group != undefined) {
|
|
101
|
-
if (group != null) {
|
|
102
|
-
newDataParameters.filter[group] = new Filter(group, "eq", row[group]);
|
|
103
|
-
} else {
|
|
104
|
-
// special case for remaining elements not in a group
|
|
105
|
-
newDataParameters.filter[group] = new Filter(group, "is", "null");
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
newDataParameters.filter["_pkid"] = new Filter("_pkid", "eq", row["_pkid"]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log(newDataParameters.filter);
|
|
112
|
-
|
|
113
|
-
const execute = async () =>
|
|
114
|
-
submitChange(url, value, [columnName], newDataParameters.filter);
|
|
115
|
-
|
|
116
|
-
const apply = (
|
|
117
|
-
currentValue: string,
|
|
118
|
-
row: { [key: string]: string },
|
|
119
|
-
cellColumnName: string,
|
|
120
|
-
) => {
|
|
121
|
-
// If this row doesn't pass all the filters skip it
|
|
122
|
-
if (!rowPassesFilters(row, Object.values(newDataParameters.filter))) {
|
|
123
|
-
return currentValue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Return the new value
|
|
127
|
-
return value;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const filterKey = createFiltersKey(Object.values(newDataParameters.filter));
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
column: columnName,
|
|
134
|
-
key: filterKey,
|
|
135
|
-
description: `Update ${columnName} to ${value} for ${filterKey}`,
|
|
136
|
-
execute: execute,
|
|
137
|
-
applyToCell: apply,
|
|
138
|
-
} as TableUpdate;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const submitChange = async (
|
|
142
|
-
url: string,
|
|
143
|
-
value: string,
|
|
144
|
-
columns: string[],
|
|
145
|
-
filters: { [key: string]: Filter },
|
|
146
|
-
) => {
|
|
147
|
-
for (const column of columns) {
|
|
148
|
-
let updateURL = new URL(url);
|
|
149
|
-
|
|
150
|
-
// Add the filters to the query parameters
|
|
151
|
-
Object.values(filters).forEach((filter) => {
|
|
152
|
-
addFilterToURL(updateURL, filter);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Create the request body
|
|
156
|
-
let patch = { [column]: value };
|
|
157
|
-
|
|
158
|
-
// Send the request
|
|
159
|
-
let response = await fetch(updateURL, {
|
|
160
|
-
method: "PATCH",
|
|
161
|
-
headers: {
|
|
162
|
-
"Content-Type": "application/json",
|
|
163
|
-
},
|
|
164
|
-
body: JSON.stringify(patch),
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
if (response.status != 204) {
|
|
168
|
-
// Stop execution if the request failed
|
|
169
|
-
throw Error("Failed to update");
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/*
|
|
175
|
-
* Squash adjacent updates with the same key
|
|
176
|
-
*
|
|
177
|
-
* If one update is followed by another update to the same set of cells
|
|
178
|
-
* remove the first update
|
|
179
|
-
*/
|
|
180
|
-
export const squashTableUpdates = (
|
|
181
|
-
tableUpdates: TableUpdate[],
|
|
182
|
-
): TableUpdate[] => {
|
|
183
|
-
let squashedTableUpdates = [];
|
|
184
|
-
let lastTableUpdate = null;
|
|
185
|
-
for (const tableUpdate of tableUpdates) {
|
|
186
|
-
if (
|
|
187
|
-
tableUpdate.key == lastTableUpdate?.key &&
|
|
188
|
-
tableUpdate.column == lastTableUpdate?.column
|
|
189
|
-
) {
|
|
190
|
-
squashedTableUpdates.pop();
|
|
191
|
-
}
|
|
192
|
-
squashedTableUpdates.push(tableUpdate);
|
|
193
|
-
lastTableUpdate = tableUpdate;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return squashedTableUpdates;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/*
|
|
200
|
-
* Submit table updates, returning any updates that were not submitted
|
|
201
|
-
*/
|
|
202
|
-
export const submitTableUpdates = async (
|
|
203
|
-
tableUpdates: TableUpdate[],
|
|
204
|
-
setProgress: (p: ProgressPopoverProps) => void,
|
|
205
|
-
): Promise<TableUpdate[]> => {
|
|
206
|
-
let index = 0;
|
|
207
|
-
for (const tableUpdate of tableUpdates) {
|
|
208
|
-
setProgress({
|
|
209
|
-
text: tableUpdate?.description ?? "Submitting changes",
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
try {
|
|
213
|
-
await tableUpdate.execute();
|
|
214
|
-
} catch (e) {
|
|
215
|
-
// If there is an error, set the progress to an error state and stop submitting
|
|
216
|
-
setProgress({
|
|
217
|
-
progressBarProps: { intent: "danger" },
|
|
218
|
-
value: 1,
|
|
219
|
-
text: "Error submitting changes",
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
setTimeout(() => {
|
|
223
|
-
setProgress(undefined);
|
|
224
|
-
}, 5000);
|
|
225
|
-
|
|
226
|
-
// Return remaining table updates
|
|
227
|
-
return tableUpdates.slice(index);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
index += 1;
|
|
231
|
-
setProgress({
|
|
232
|
-
value: index / tableUpdates.length,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
setProgress(undefined);
|
|
237
|
-
|
|
238
|
-
return [];
|
|
239
|
-
};
|
|
File without changes
|