From d90b0c409ceac9585bfa8fe10704c1e531a3bdc1 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 7 Jan 2021 16:40:48 +0100
Subject: [PATCH] Implement remove operation for CorpusFileLists
---
web/app/static/js/nopaque/RessorceLists.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/web/app/static/js/nopaque/RessorceLists.js b/web/app/static/js/nopaque/RessorceLists.js
index 47c0edb8..236c97e8 100644
--- a/web/app/static/js/nopaque/RessorceLists.js
+++ b/web/app/static/js/nopaque/RessorceLists.js
@@ -225,7 +225,7 @@ class CorpusFileList extends RessourceList {
}
patch(patch) {
- let re;
+ let id, match, re;
for (let operation of patch) {
switch(operation.op) {
case 'add':
@@ -233,6 +233,14 @@ class CorpusFileList extends RessourceList {
re = new RegExp('^/corpora/' + this.corpus.id + '/files/(\\d+)$');
if (re.test(operation.path)) {this.add(operation.value);}
break;
+ case 'remove':
+ // See case add ;)
+ re = new RegExp('^/corpora/' + this.corpus.id + '/files/(\\d+)$');
+ if (re.test(operation.path)) {
+ [match, id] = operation.path.match(re);
+ this.remove(id);
+ }
+ break;
default:
break;
}