bugfixes: delete entries in larger docgroups, fix vcdemo
Change-Id: I76a09faafe79d0fd85efc32a8bcdec37878ba486
(cherry picked from commit 6885f6e34dd6ae2614713f86e5d28aea2ed832d8)
diff --git a/dev/demo/vcdemo.js b/dev/demo/vcdemo.js
index 4e0eaed..b9a7b1a 100644
--- a/dev/demo/vcdemo.js
+++ b/dev/demo/vcdemo.js
@@ -129,6 +129,10 @@
['author', 'text']
]).fromJson(json);
+ document.addEventListener('vcChange', function (e) {
+ KorAP.vc.checkStatActive(e.detail);
+ }, false);
+
document.getElementById('vc-view').appendChild(KorAP.vc.element());
KorAP.vc.open();
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index 864a8ca..25e55a2 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -100,6 +100,43 @@
return vc;
}
+ /**
+ * Generate corpus doc group with more entries
+ */
+ generateBCorpusDocGr = function(){
+ let vc = vcClass.create().fromJson({
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [{
+ "@type" : 'koral:docGroup',
+ 'operation' : 'operation:or',
+ 'operands' : [
+ {
+ '@type' : 'koral:doc',
+ 'key' : 'title',
+ 'match': 'match:eq',
+ 'value' : 'Hello World!'
+ },
+ {
+ '@type' : 'koral:doc',
+ 'match': 'match:eq',
+ 'key' : 'foo',
+ 'value' : 'bar'
+ }
+ ]
+ },
+ {
+ '@type' : 'koral:doc',
+ 'match': 'match:eq',
+ 'key' : 'author',
+ 'value' : 'Goethe'
+ }
+ ]
+ });
+
+ return vc;
+ }
+
generateCorpusDoc = function(){
let vc= vcClass.create().fromJson({
'@type' : 'koral:doc',
@@ -318,11 +355,13 @@
* in vc builder through user-interaction
*/
describe ('KorAP.CorpusStat.Disable', function(){
-
+
document.addEventListener('vcChange', function (e) {
+ if(KorAP.vc){
KorAP.vc.checkStatActive(e.detail);
+ }
}, false);
-
+
/**
* If the user defines a new vc, the statistic should be disabled,
* because it is out-of-date.
@@ -380,7 +419,20 @@
KorAP._delete.apply(KorAP.vc.root());
view = panel.firstChild.firstChild;
expect(checkStatDisabled(view, show)).toBe(true);
-
+
+ KorAP.vc = generateBCorpusDocGr();
+ // create corpus builder and corpus statistic;
+ show = document.createElement('div');
+ show.appendChild(KorAP.vc.element());
+ panel = show.firstChild.lastChild.firstChild;
+ panel.lastChild.children[0].click();
+ view = panel.firstChild.firstChild;
+
+ expect(checkStatActive(view, show)).toBe(true);
+ KorAP._delete.apply(KorAP.vc.root().getOperand(1));
+ view = panel.firstChild.firstChild;
+ expect(checkStatDisabled(view, show)).toBe(true);
+
});
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 10a6495..858e847 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -210,6 +210,9 @@
group.appendChild(op.element());
+ var vcchevent = new CustomEvent('vcChange', {'detail':this});
+ document.dispatchEvent(vcchevent);
+
return this;
},
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
index 3b7bd6d..f72e27a 100644
--- a/dev/js/src/vc/docgroupref.js
+++ b/dev/js/src/vc/docgroupref.js
@@ -109,7 +109,7 @@
// Append new operators
e.appendChild(op.element());
};
-
+
var vcchevent = new CustomEvent('vcChange', {'detail':this});
document.dispatchEvent(vcchevent);
diff --git a/dev/js/src/view/corpstatv.js b/dev/js/src/view/corpstatv.js
index ee65c03..fa9a135 100644
--- a/dev/js/src/view/corpstatv.js
+++ b/dev/js/src/view/corpstatv.js
@@ -122,6 +122,7 @@
if(newString.startsWith('(')){
newString = newString.slice(1, newString.length-1);
}
+
if(newString != oldString) {
this.disableStat();
}