Skip to content

Commit 6b4f660

Browse files
committed
Index bug corrected
Rows id were used instead of array index to browse data that create a shift when table contains some deleted rows.
1 parent cd6152a commit 6b4f660

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

simplefilter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@
8686
</tr>
8787

8888
</table>
89-
<script src="script.js"></script>
89+
<script src="script.min.js"></script>
9090
</body>
9191
</html>

simplefilter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@varamil/widget-simplefilter",
33
"description": "Simple table filtering to display any row that matches the search.",
44
"homePage": "https://github.com/Varamil/grist-widget",
5-
"version": "3.0.0",
5+
"version": "3.1.0",
66
"grist": {
77
"name": "Simple table filter",
88
"url": "https://varamil.github.io/grist-widget/simplefilter/index.html",

simplefilter/script.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ var sessionID = "";
1010
var sessionUUID = "";
1111
var defval = "";
1212
const searchtypes = ["+", "&", "&&"];
13-
//const searchtypesnames = ["OU", "ET", "ET col"];
13+
// const searchtypesnames = ["OU", "ET", "ET col"];
1414
const searchtypesnames = ["OR", "AND", "AND col"];
1515

1616
const defplaceholder = "Search (? + Enter to get help)" ;
17-
//const defplaceholder = "Recherche (? + Entrer pour obtenir de l'aide)" ;
17+
// const defplaceholder = "Recherche (? + Entrer pour obtenir de l'aide)" ;
1818

1919

2020
// const defhelp = `Aide
@@ -264,18 +264,18 @@ function ApplyFilter() {
264264
//let searches = parseinput(search, 2); //search.substring(2).split(" ");
265265

266266
let ok;
267-
let match = records['id'].filter((id) => {
267+
let match = records['id'].filter((idgrist, id) => {
268268
for (c of columns) {
269269
ok = true;
270270
for (s of searches) {
271271
[s, re, neg, tp, _] = parsesearch(s, columns);
272272
if (neg) {
273-
if (matchtxt(records[c][id-1], s, re, tp)){ //(records[c][id-1]?.toString().toLowerCase().includes(s))
273+
if (matchtxt(records[c][id], s, re, tp)){ //(records[c][id-1]?.toString().toLowerCase().includes(s))
274274
ok = false;
275275
break;
276276
}
277277
} else {
278-
if (!matchtxt(records[c][id-1], s, re, tp)){
278+
if (!matchtxt(records[c][id], s, re, tp)){
279279
ok = false;
280280
break;
281281
}
@@ -292,7 +292,7 @@ function ApplyFilter() {
292292
//AND search with matches in any column **************************************************************
293293
//let searches = parseinput(search, 1); //search.substring(1).split(" ");
294294

295-
let match = records['id'].filter((id) => {
295+
let match = records['id'].filter((idgrist, id) => {
296296
let matches = [];
297297

298298
for (si in searches) {
@@ -302,15 +302,15 @@ function ApplyFilter() {
302302
matches.push(true)
303303

304304
for (c of scol) {
305-
if (matchtxt(records[c][id-1], s, re, tp)) {
305+
if (matchtxt(records[c][id], s, re, tp)) {
306306
matches[si] = false;
307307
break;
308308
}
309309
}
310310
} else {
311311
matches.push(false)
312312
for (c of scol) {
313-
if (matchtxt(records[c][id-1], s, re, tp)) {
313+
if (matchtxt(records[c][id], s, re, tp)) {
314314
matches[si] = true;
315315
break;
316316
}
@@ -325,22 +325,22 @@ function ApplyFilter() {
325325
} else {
326326
//OR **************************************************************
327327
//let searches = parseinput(search); //search.split(" ");
328-
329-
let match = records['id'].filter((id) => {
328+
329+
let match = records['id'].filter((idgrist, id) => {
330330
for (s of searches) {
331331
[s, re, neg, tp, scol] = parsesearch(s, columns);
332332
if (neg) {
333333
let ok = true;
334334
for (c of scol) {
335-
if (matchtxt(records[c][id-1], s, re, tp)) {
335+
if (matchtxt(records[c][id], s, re, tp)) {
336336
ok = false
337337
break;
338338
};
339339
}
340340
if (ok) return true; //the word is no where, so this part is true
341341
} else {
342342
for (c of scol) {
343-
if (matchtxt(records[c][id-1], s, re, tp)) return true;
343+
if (matchtxt(records[c][id], s, re, tp)) return true;
344344
}
345345
}
346346
}

0 commit comments

Comments
 (0)