Skip to content

Commit c3a65b7

Browse files
authored
Fix array datasource delete (#1718)
* fix bug in array data source, doesn't emit resize evt on delete * bump ui library versions to 0.13.36
1 parent e3a2f5d commit c3a65b7

File tree

33 files changed

+467
-455
lines changed

33 files changed

+467
-455
lines changed

vuu-ui/package-lock.json

Lines changed: 218 additions & 228 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vuu-ui/packages/grid-layout/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@heswell/grid-layout",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"description": "VUU Layout Components",
55
"main": "src/index.ts",
66
"author": "heswell",
@@ -12,7 +12,7 @@
1212
},
1313
"types": "src/index.ts",
1414
"dependencies": {
15-
"@vuu-ui/vuu-utils": "0.13.35",
15+
"@vuu-ui/vuu-utils": "0.13.36",
1616
"@salt-ds/core": "1.43.0",
1717
"@salt-ds/lab": "1.0.0-alpha.64",
1818
"@salt-ds/styles": "0.2.1",

vuu-ui/packages/vuu-codemirror/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-codemirror",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"author": "heswell",
55
"main": "src/index.ts",
66
"license": "Apache-2.0",
@@ -11,15 +11,15 @@
1111
"lezer-generate:column": "lezer-generator --output ./src/column-expression-input/column-language-parser/generated/column-parser.js ./src/column-expression-input/column-language-parser/grammar/column.grammar"
1212
},
1313
"devDependencies": {
14-
"@vuu-ui/vuu-table-types": "0.13.35"
14+
"@vuu-ui/vuu-table-types": "0.13.36"
1515
},
1616
"dependencies": {
1717
"@codemirror/autocomplete": "^6.4.2",
1818
"@codemirror/commands": "^6.2.1",
1919
"@codemirror/language": "^6.6.0",
2020
"@codemirror/state": "^6.2.0",
2121
"@codemirror/view": "^6.9.3",
22-
"@vuu-ui/vuu-utils": "0.13.35",
22+
"@vuu-ui/vuu-utils": "0.13.36",
2323
"@lezer/common": "1.2.3",
2424
"@lezer/highlight": "^1.1.3"
2525
},

vuu-ui/packages/vuu-context-menu/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-context-menu",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"author": "heswell",
55
"main": "src/index.ts",
66
"license": "Apache-2.0",
@@ -10,12 +10,12 @@
1010
"type-defs": "node ../../scripts/build-type-defs.mjs"
1111
},
1212
"devDependencies": {
13-
"@vuu-ui/vuu-data-types": "0.13.35",
14-
"@vuu-ui/vuu-protocol-types": "0.13.35",
15-
"@vuu-ui/vuu-table-types": "0.13.35"
13+
"@vuu-ui/vuu-data-types": "0.13.36",
14+
"@vuu-ui/vuu-protocol-types": "0.13.36",
15+
"@vuu-ui/vuu-table-types": "0.13.36"
1616
},
1717
"dependencies": {
18-
"@vuu-ui/vuu-utils": "0.13.35",
18+
"@vuu-ui/vuu-utils": "0.13.36",
1919
"@salt-ds/core": "1.43.0",
2020
"@salt-ds/styles": "0.2.1",
2121
"@salt-ds/window": "0.1.1"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-data-local",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"main": "src/index.ts",
55
"author": "heswell",
66
"license": "Apache-2.0",
@@ -11,14 +11,14 @@
1111
"type-defs": "node ../../scripts/build-type-defs.mjs"
1212
},
1313
"devDependencies": {
14-
"@vuu-ui/vuu-data-types": "0.13.35",
15-
"@vuu-ui/vuu-table-types": "0.13.35",
16-
"@vuu-ui/vuu-filter-types": "0.13.35",
17-
"@vuu-ui/vuu-protocol-types": "0.13.35"
14+
"@vuu-ui/vuu-data-types": "0.13.36",
15+
"@vuu-ui/vuu-table-types": "0.13.36",
16+
"@vuu-ui/vuu-filter-types": "0.13.36",
17+
"@vuu-ui/vuu-protocol-types": "0.13.36"
1818
},
1919
"dependencies": {
20-
"@vuu-ui/vuu-filter-parser": "0.13.35",
21-
"@vuu-ui/vuu-utils": "0.13.35"
20+
"@vuu-ui/vuu-filter-parser": "0.13.36",
21+
"@vuu-ui/vuu-utils": "0.13.36"
2222
},
2323
"sideEffects": false
2424
}

vuu-ui/packages/vuu-data-local/src/array-data-source/array-data-source.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,23 +725,41 @@ export class ArrayDataSource
725725
deleteRow: DataSourceDeleteHandler = async (key) => {
726726
// TODO take sorting, filtering. grouping into account
727727

728+
const start = performance.now();
728729
const dataIndex = this.#data.findIndex((row) => row[KEY] === key);
730+
let doomedIndex: number | undefined = undefined;
731+
729732
if (dataIndex !== -1) {
730733
if (this.processedData) {
731-
// do stuff
734+
for (let i = 0; i < this.processedData.length; i++) {
735+
if (this.processedData[i][KEY] === key) {
736+
doomedIndex = i;
737+
} else if (this.processedData[i][0] > dataIndex) {
738+
this.processedData[i][0] -= 1;
739+
}
740+
}
741+
if (doomedIndex !== undefined) {
742+
this.processedData.splice(doomedIndex, 1);
743+
}
732744
}
733745

734746
this.#data.splice(dataIndex, 1);
735747
for (let i = dataIndex; i < this.#data.length; i++) {
736748
this.#data[i][0] -= 1;
737749
}
738750

751+
const end = performance.now();
752+
console.log(`deleteRow, updating indices took ${end - start}ms`);
739753
this.sendSizeUpdateToClient();
740754

741755
const { from, to } = this.#range;
742-
if (dataIndex >= from && dataIndex < to) {
756+
const deletedIndex = doomedIndex ?? dataIndex;
757+
if (deletedIndex >= from && deletedIndex < to) {
743758
this.sendRowsToClient(true);
744759
}
760+
761+
this.emit("resize", this.size);
762+
745763
return true;
746764
} else {
747765
return "row not found";

vuu-ui/packages/vuu-data-react/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-data-react",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"main": "src/index.ts",
55
"author": "heswell",
66
"license": "Apache-2.0",
@@ -11,21 +11,21 @@
1111
"type-defs": "node ../../scripts/build-type-defs.mjs"
1212
},
1313
"devDependencies": {
14-
"@vuu-ui/vuu-data-types": "0.13.35",
15-
"@vuu-ui/vuu-filter-types": "0.13.35",
16-
"@vuu-ui/vuu-popups": "0.13.35",
17-
"@vuu-ui/vuu-protocol-types": "0.13.35",
18-
"@vuu-ui/vuu-table-types": "0.13.35"
14+
"@vuu-ui/vuu-data-types": "0.13.36",
15+
"@vuu-ui/vuu-filter-types": "0.13.36",
16+
"@vuu-ui/vuu-popups": "0.13.36",
17+
"@vuu-ui/vuu-protocol-types": "0.13.36",
18+
"@vuu-ui/vuu-table-types": "0.13.36"
1919
},
2020
"dependencies": {
21-
"@vuu-ui/vuu-context-menu": "0.13.35",
22-
"@vuu-ui/vuu-data-remote": "0.13.35",
23-
"@vuu-ui/vuu-filter-parser": "0.13.35",
24-
"@vuu-ui/vuu-layout": "0.13.35",
25-
"@vuu-ui/vuu-popups": "0.13.35",
26-
"@vuu-ui/vuu-ui-controls": "0.13.35",
27-
"@vuu-ui/vuu-utils": "0.13.35",
28-
"@vuu-ui/vuu-table": "0.13.35",
21+
"@vuu-ui/vuu-context-menu": "0.13.36",
22+
"@vuu-ui/vuu-data-remote": "0.13.36",
23+
"@vuu-ui/vuu-filter-parser": "0.13.36",
24+
"@vuu-ui/vuu-layout": "0.13.36",
25+
"@vuu-ui/vuu-popups": "0.13.36",
26+
"@vuu-ui/vuu-ui-controls": "0.13.36",
27+
"@vuu-ui/vuu-utils": "0.13.36",
28+
"@vuu-ui/vuu-table": "0.13.36",
2929
"@salt-ds/core": "1.43.0",
3030
"@salt-ds/styles": "0.2.1",
3131
"@salt-ds/window": "0.1.1"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-data-remote",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"main": "src/index.ts",
55
"author": "heswell",
66
"license": "Apache-2.0",
@@ -12,13 +12,13 @@
1212
"type-defs": "node ../../scripts/build-type-defs.mjs"
1313
},
1414
"devDependencies": {
15-
"@vuu-ui/vuu-data-types": "0.13.35",
16-
"@vuu-ui/vuu-table-types": "0.13.35",
17-
"@vuu-ui/vuu-filter-types": "0.13.35",
18-
"@vuu-ui/vuu-protocol-types": "0.13.35"
15+
"@vuu-ui/vuu-data-types": "0.13.36",
16+
"@vuu-ui/vuu-table-types": "0.13.36",
17+
"@vuu-ui/vuu-filter-types": "0.13.36",
18+
"@vuu-ui/vuu-protocol-types": "0.13.36"
1919
},
2020
"dependencies": {
21-
"@vuu-ui/vuu-filter-parser": "0.13.35",
22-
"@vuu-ui/vuu-utils": "0.13.35"
21+
"@vuu-ui/vuu-filter-parser": "0.13.36",
22+
"@vuu-ui/vuu-utils": "0.13.36"
2323
}
2424
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vuu-ui/vuu-data-test",
3-
"version": "0.13.35",
3+
"version": "0.13.36",
44
"main": "src/index.ts",
55
"author": "heswell",
66
"license": "Apache-2.0",
@@ -10,13 +10,13 @@
1010
"type-defs": "node ../../scripts/build-type-defs.mjs"
1111
},
1212
"dependencies": {
13-
"@vuu-ui/vuu-data-local": "0.13.35",
14-
"@vuu-ui/vuu-utils": "0.13.35"
13+
"@vuu-ui/vuu-data-local": "0.13.36",
14+
"@vuu-ui/vuu-utils": "0.13.36"
1515
},
1616
"devDependencies": {
17-
"@vuu-ui/vuu-protocol-types": "0.13.35",
18-
"@vuu-ui/vuu-data-types": "0.13.35",
19-
"@vuu-ui/vuu-table-types": "0.13.35"
17+
"@vuu-ui/vuu-protocol-types": "0.13.36",
18+
"@vuu-ui/vuu-data-types": "0.13.36",
19+
"@vuu-ui/vuu-table-types": "0.13.36"
2020
},
2121
"sideEffects": false
2222
}

vuu-ui/packages/vuu-data-test/src/Table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class Table extends EventEmitter<TableEvents> {
5656
}
5757

5858
delete(key: string, emitEvent = true) {
59+
console.log(`[Table] delete key ${key}`);
5960
const index = this.#index.get(key) ?? -1;
6061
if (index !== -1) {
6162
this.#index.delete(key);

0 commit comments

Comments
 (0)