Remove hack to prevent vanishing statistics button when modifying the builder object on root
Change-Id: I89d7df6d303983918e16b8b04b34895df5466897
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index 94be3f2..cb9d713 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -164,7 +164,7 @@
expect(show.querySelector(".statistic").tagName).toEqual("SPAN");
- var and = vc.element().firstChild.lastChild.firstChild;
+ var and = vc.builder().lastChild.firstChild;
// Click on and() in VC
and.click();
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index b60dc5d..3edfdf8 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -424,6 +424,10 @@
});
it('should be deserializable', function () {
+
+ // Reset list
+ KorAP._vcKeyMenu = menuClass.create([['referTo','ref']]);
+
var docGroup = docGroupFactory.create();
expect(docGroup.operation()).toEqual("and");
expect(docGroup.operands().length).toEqual(2);
@@ -471,7 +475,7 @@
var op3 = docGroup.getOperand(2);
expect(op3.ldType()).toEqual("docGroup");
expect(op3.operation()).toEqual("or");
-
+
var op4 = op3.getOperand(0);
expect(op4.ldType()).toEqual("doc");
expect(op4.type()).toEqual("string");
@@ -750,14 +754,13 @@
["pubDate", "date"]
]);
expect(vc.toQuery()).toEqual("");
- expect(vc.element().firstChild.textContent).toEqual("⋯");
- vc.element().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.textContent).toEqual("⋯");
+ vc.builder().firstChild.firstChild.click();
// Click on pubDate
vc.element().firstChild.getElementsByTagName("LI")[1].click();
-
- expect(vc.element().firstChild.firstChild.textContent).toEqual("pubDate");
- expect(vc.element().firstChild.children[1].getAttribute("data-type")).toEqual("date");
+ expect(vc.builder().firstChild.firstChild.textContent).toEqual("pubDate");
+ expect(vc.builder().firstChild.children[1].getAttribute("data-type")).toEqual("date");
});
});
@@ -800,7 +803,7 @@
});
expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
- var vcE = vc.element();
+ var vcE = vc.builder();
expect(vcE.firstChild.children.length).toEqual(4);
// Click to delete
@@ -831,7 +834,7 @@
expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
- var vcE = vc.element();
+ var vcE = vc.builder();
expect(vcE.firstChild.children.length).toEqual(4);
// Click to delete
@@ -1149,9 +1152,9 @@
"ref":"myCorpus"
});
- // iv class="doc groupref"><span class="key fixed">referTo</span><span data-type="string" class="value">myCorpus</span>
- var vcE = vc.element();
- expect(vcE.getAttribute('class')).toEqual('vc');
+ // iv class="doc groupref"><span class="key fixed">@referTo</span><span data-type="string" class="value">myCorpus</span>
+ var vcE = vc.builder();
+ expect(vcE.getAttribute('class')).toEqual('builder');
expect(vcE.firstChild.tagName).toEqual('DIV');
expect(vcE.firstChild.classList.contains('groupref')).toBeTruthy();
@@ -1170,15 +1173,15 @@
it('should be based on a nested docGroup', function () {
var vc = nestedGroupFactory.create();
- expect(vc.element().getAttribute('class')).toEqual('vc');
- expect(vc.element().firstChild.getAttribute('class')).toEqual('docGroup');
- expect(vc.element().firstChild.children[0].getAttribute('class')).toEqual('doc');
- var dg = vc.element().firstChild.children[1];
+ expect(vc.builder().getAttribute('class')).toEqual('builder');
+ expect(vc.builder().firstChild.getAttribute('class')).toEqual('docGroup');
+ expect(vc.builder().firstChild.children[0].getAttribute('class')).toEqual('doc');
+ var dg = vc.builder().firstChild.children[1];
expect(dg.getAttribute('class')).toEqual('docGroup');
expect(dg.children[0].getAttribute('class')).toEqual('doc');
expect(dg.children[1].getAttribute('class')).toEqual('doc');
expect(dg.children[2].getAttribute('class')).toEqual('operators button-group');
- expect(vc.element().firstChild.children[2].getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children[2].getAttribute('class')).toEqual('operators button-group');
});
it('should be based on a nested docGroupRef', function () {
@@ -1904,8 +1907,8 @@
expect(vc.root().operation()).toEqual('or');
// Operands and operators
- expect(vc.element().firstChild.children.length).toEqual(4);
- expect(vc.element().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children.length).toEqual(4);
+ expect(vc.builder().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
// Remove inner group and flatten
_delOn(vc.root().getOperand(2).getOperand(0));
@@ -1917,8 +1920,8 @@
expect(vc.root().operation()).toEqual('or');
// Operands and operators
- expect(vc.element().firstChild.children.length).toEqual(5);
- expect(vc.element().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
+ expect(vc.builder().firstChild.children.length).toEqual(5);
+ expect(vc.builder().firstChild.lastChild.getAttribute('class')).toEqual('operators button-group');
});
});
@@ -1981,7 +1984,7 @@
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(4);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
@@ -1993,7 +1996,7 @@
_andOn(vc.root().getOperand(0));
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(5);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
@@ -2045,7 +2048,7 @@
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.children.length).toEqual(4);
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
expect(fc.children[0].getAttribute('class')).toEqual('doc');
@@ -2055,7 +2058,7 @@
// add with 'or' in the middle
_orOn(vc.root().getOperand(0));
expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.getAttribute('data-operation')).toEqual('and');
expect(fc.children.length).toEqual(4);
@@ -2066,7 +2069,7 @@
expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
- fc = vc.element().firstChild.firstChild;
+ fc = vc.builder().firstChild.firstChild;
expect(fc.children.length).toEqual(3);
expect(fc.children[0].getAttribute('class')).toEqual('doc');
expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
@@ -2074,7 +2077,7 @@
expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
_orOn(vc.root().getOperand(2));
- fc = vc.element().firstChild;
+ fc = vc.builder().firstChild;
expect(fc.children.length).toEqual(4);
expect(fc.children[0].getAttribute('class')).toEqual('docGroup');
@@ -2082,7 +2085,7 @@
expect(fc.children[2].getAttribute('class')).toEqual('docGroup');
expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
- fc = vc.element().firstChild.children[2];
+ fc = vc.builder().firstChild.children[2];
expect(fc.children[0].getAttribute('class')).toEqual('doc groupref');
expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
expect(fc.children[2].getAttribute('class')).toEqual('operators button-group');
@@ -2584,14 +2587,14 @@
['b', 'string'],
['c', 'date']
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
// Click on unspecified
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
- var list = vc.element().firstChild.firstChild;
+ var list = vc.builder().firstChild.firstChild;
expect(list.getElementsByTagName("LI")[0].innerText).toEqual('referTo');
expect(list.getElementsByTagName("LI")[1].innerText).toEqual('a');
expect(list.getElementsByTagName("LI")[2].innerText).toEqual('b');
@@ -2602,14 +2605,14 @@
['e', 'string'],
['f', 'date']
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
// Click on unspecified
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
- list = vc.element().firstChild.firstChild;
+ list = vc.builder().firstChild.firstChild;
expect(list.getElementsByTagName("LI")[0].innerText).toEqual('referTo');
expect(list.getElementsByTagName("LI")[1].innerText).toEqual('d');
expect(list.getElementsByTagName("LI")[2].innerText).toEqual('e');
@@ -2627,30 +2630,30 @@
it('should be clickable on key', function () {
// Click on unspecified
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Click on "d"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('SPAN');
- expect(vc.element().firstChild.firstChild.innerText).toEqual('d');
- expect(vc.element().firstChild.children[1].innerText).toEqual('eq');
- expect(vc.element().firstChild.children[1].getAttribute('data-type')).toEqual('text');
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('SPAN');
+ expect(vc.builder().firstChild.firstChild.innerText).toEqual('d');
+ expect(vc.builder().firstChild.children[1].innerText).toEqual('eq');
+ expect(vc.builder().firstChild.children[1].getAttribute('data-type')).toEqual('text');
// blur
document.body.click();
});
it('should be clickable on operation for text', function () {
// Click on "d" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "d"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
// Click on matchop
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual('UL');
+ expect(vc.builder().firstChild.children[1].tagName).toEqual('UL');
- var ul = vc.element().firstChild.children[1];
+ var ul = vc.builder().firstChild.children[1];
expect(ul.getElementsByTagName('li')[0].innerText).toEqual("eq");
expect(ul.getElementsByTagName('li')[1].innerText).toEqual("ne");
expect(ul.getElementsByTagName('li')[2].innerText).toEqual("contains");
@@ -2659,48 +2662,47 @@
// Choose "contains"
ul.getElementsByTagName('li')[2].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual("SPAN");
- expect(vc.element().firstChild.children[1].innerText).toEqual("contains");
+ expect(vc.builder().firstChild.children[1].tagName).toEqual("SPAN");
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("contains");
// blur
document.body.click();
})
it('should be clickable on operation for string', function () {
// Click on "d" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "e"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[2].click();
-
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[2].click();
+
// As a consequence the matchoperator may no longer
// be valid and needs to be re-evaluated
- var fc = vc.element().firstChild;
-
+ var fc = vc.builder().firstChild;
expect(fc.firstChild.tagName).toEqual('SPAN');
expect(fc.firstChild.innerText).toEqual('e');
expect(fc.children[1].innerText).toEqual('eq');
expect(fc.children[1].getAttribute('data-type')).toEqual('string');
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual('UL');
+ expect(vc.builder().firstChild.children[1].tagName).toEqual('UL');
- var ul = vc.element().firstChild.children[1];
+ var ul = vc.builder().firstChild.children[1];
expect(ul.getElementsByTagName('li')[0].innerText).toEqual("eq");
expect(ul.getElementsByTagName('li')[1].innerText).toEqual("ne");
expect(ul.getElementsByTagName('li')[2]).toBeUndefined();
// Choose "ne"
ul.getElementsByTagName('li')[1].click();
- expect(vc.element().firstChild.children[1].tagName).toEqual("SPAN");
- expect(vc.element().firstChild.children[1].innerText).toEqual("ne");
+ expect(vc.builder().firstChild.children[1].tagName).toEqual("SPAN");
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("ne");
// Click on text
- expect(vc.element().firstChild.children[2].innerText).toEqual("⋯");
- vc.element().firstChild.children[2].click();
+ expect(vc.builder().firstChild.children[2].innerText).toEqual("⋯");
+ vc.builder().firstChild.children[2].click();
// Blur text element
- expect(vc.element().firstChild.children[2].firstChild.value).toEqual('');
+ expect(vc.builder().firstChild.children[2].firstChild.value).toEqual('');
// blur
document.body.click();
@@ -2710,22 +2712,22 @@
// Replay matchop check - so it's guaranteed that "ne" is chosen
// Click on "e" (or unspecified)
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Rechoose "e"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[1].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[1].click();
// Click on matchop
- vc.element().firstChild.children[1].click();
+ vc.builder().firstChild.children[1].click();
// Choose "ne"
- vc.element().firstChild.children[1].getElementsByTagName('li')[1].click();
- expect(vc.element().firstChild.children[1].innerText).toEqual("ne");
+ vc.builder().firstChild.children[1].getElementsByTagName('li')[1].click();
+ expect(vc.builder().firstChild.children[1].innerText).toEqual("ne");
// Click on "e"
- vc.element().firstChild.firstChild.click();
+ vc.builder().firstChild.firstChild.click();
// Choose "f"
- vc.element().firstChild.firstChild.getElementsByTagName("LI")[3].click();
+ vc.builder().firstChild.firstChild.getElementsByTagName("LI")[3].click();
// The matchoperator should still be "ne" as this is valid for dates as well (now)
- var fc = vc.element().firstChild;
+ var fc = vc.builder().firstChild;
expect(fc.firstChild.tagName).toEqual('SPAN');
expect(fc.firstChild.innerText).toEqual('f');
expect(fc.children[1].innerText).toEqual('ne');
@@ -2746,7 +2748,7 @@
"value":"Baum"
});
- expect(vc.element().firstChild.children[1].getAttribute('data-type')).toEqual('text');
+ expect(vc.builder().firstChild.children[1].getAttribute('data-type')).toEqual('text');
});
});
@@ -2767,24 +2769,24 @@
['b', null],
['c', null]
]).fromJson();
- expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
+ expect(vc.builder().firstChild.classList.contains('unspecified')).toBeTruthy();
// This should open up the menu
- vc.element().firstChild.firstChild.click();
- expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+ vc.builder().firstChild.firstChild.click();
+ expect(vc.builder().firstChild.firstChild.tagName).toEqual('UL');
KorAP._vcKeyMenu._prefix.clear();
KorAP._vcKeyMenu._prefix.add('x');
- var prefElement = vc.element().querySelector('span.pref');
+ var prefElement = vc.builder().querySelector('span.pref');
expect(prefElement.innerText).toEqual('x');
// This should add key 'x' to VC
prefElement.click();
- expect(vc.element().firstChild.classList.contains('doc')).toBeTruthy();
- expect(vc.element().firstChild.firstChild.className).toEqual('key');
- expect(vc.element().firstChild.firstChild.innerText).toEqual('x');
+ expect(vc.builder().firstChild.classList.contains('doc')).toBeTruthy();
+ expect(vc.builder().firstChild.firstChild.className).toEqual('key');
+ expect(vc.builder().firstChild.firstChild.innerText).toEqual('x');
});
});
});
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 985b64b..35734ad 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -146,13 +146,13 @@
var l;
if (keyList) {
- l = keyList.slice();
+ l = keyList.slice();
l.unshift(['referTo', 'ref']);
}
else {
l = [['referTo', 'ref']];
}
-
+
// Create key menu
KorAP._vcKeyMenu = menuClass.create(l);
KorAP._vcKeyMenu.limit(6);
@@ -254,9 +254,11 @@
*/
root : function(obj) {
if (arguments.length === 1) {
- var e = this.element();
+ var e = this.builder();
if (e.firstChild !== null) {
+
+ // Object not yet set
if (e.firstChild !== obj.element()) {
e.replaceChild(obj.element(), e.firstChild);
};
@@ -276,12 +278,24 @@
return this._root;
},
+
+ /**
+ * Get the wrapper element associated with the vc
+ */
+ builder : function () {
+
+ // Initialize if necessary
+ if (this._builder !== undefined)
+ return this._builder;
+
+ this.element();
+ return this._builder;
+ },
+
/**
* Get the element associated with the virtual collection
*/
element : function() {
-
-
if (this._element !== undefined) {
return this._element;
};
@@ -289,17 +303,11 @@
this._element = document.createElement('div');
this._element.setAttribute('class', 'vc');
+ this._builder = this._element.addE('div');
+ this._builder.setAttribute('class', 'builder');
+
// Initialize root
- this._element.appendChild(this._root.element());
-
- /*
- * TODO by Helge Hack! additional div, because statistic button is
- * removed after choosing and/or/x in vc builder. REMOVE this lines
- * after solving the problem!!!!
- */
- this._element.addE('div');
- this._element.addE('div');
- this._element.addE('div');
+ this._builder.appendChild(this._root.element());
// Add panel to display corpus statistic, ...
this.addVcInfPanel();
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index d3097e9..7ce2fed 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -13,12 +13,10 @@
], function (jsonldClass,
unspecClass,
docClass,
- docGroupRefClass) {
+ docGroupRefClass) {
const _validGroupOpRE = new RegExp("^(?:and|or)$");
- const loc = KorAP.Locale;
-
const docGroupClass = {
_ldType : "docGroup",
diff --git a/dev/scss/header/statistics.scss b/dev/scss/header/statistics.scss
index 44d8930..a4d3f1e 100644
--- a/dev/scss/header/statistics.scss
+++ b/dev/scss/header/statistics.scss
@@ -1,41 +1,10 @@
@charset "utf-8";
@import "../util";
-/*
-div.view.vcstatistic {
- position: relative;
- display: inline-flex;
- width: auto;
-}
-*/
-
div.stattable {
display: flex;
flex-direction: row;
}
-/*
-div.stattable ul.action.image {
- display: block;
- li {
- cursor: pointer;
- color: $nearly-white;
- text-decoration: none;
- > span {
- @include blind;
- }
- border-width: 0;
- // z-index: 8;
- text-decoration:none;
- text-align: center;
- font-style: normal;
-
- &.close::after {
- font-family: 'FontAwesome';
- content: $fa-close;
- }
- }
-}
-*/
div.stattable > dl {
display: flex;
@@ -45,21 +14,9 @@
margin-bottom:4px;
padding-bottom: 1px;
> div {
- /*
- display: flex;
- margin-right: 5px;
- margin-left: 5px;
- > * {
- @include cell-info;
- }
- */
border-color: $dark-green;
> dt {
background-color: $middle-green;
- /*
- text-align: right;
- // padding: 1px;
- */
width: 15em;
margin: 0;
&:after {
@@ -67,15 +24,6 @@
}
}
> dd {
- /*
- text-align: left;
- // padding: 1px;
- margin: 0;
- width: 100%;
- max-width: none;
- max-height: 6em;
- margin-left: $border-size;
- */
background-color: $lightest-green;
color: $dark-grey;
}
diff --git a/dev/scss/header/vc.scss b/dev/scss/header/vc.scss
index 1d0cd0e..eeea883 100644
--- a/dev/scss/header/vc.scss
+++ b/dev/scss/header/vc.scss
@@ -9,7 +9,7 @@
* Virtual Collection Builder
*/
-.vc {
+.vc .builder {
margin-top: 4pt;
.docGroup, .doc {
@@ -73,34 +73,6 @@
// This will be overruled by JS!
content: "or";
}
-
- /*
- &:after {
- .button-stat {
- > span {
- cursor: pointer;
- box-shadow: $choose-box-shadow;
- font-size: 9pt;
- line-height: 1.5em;
- padding: 0 4px;
- display: inline-block;
- @include choose-item;
- border-style: solid;
- border-width: $border-size 0;
- &:hover {
- @include choose-hover;
- }
- &:first-child {
- border: {
- left-width: $border-size;
- right-width: $border-size;
- }
- }
-
- }
- }
- }
- */
}
// And operation
@@ -366,20 +338,4 @@
div.panel.vcinfo {
padding: 3pt 0pt 3pt 3pt;
background-color: $dark-green;
- /*
- div.button-group {
- display: inline-block;
- margin-right: .5em;
- > span {
- position: relative;
- box-shadow: none;
- }
- }
-*/
}
-
-/*
-.button-group.vcstatistic{
- position:relative;
- }
-*/
\ No newline at end of file