Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
#4/#5: sorted items, and adjusted update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
grtjn committed Feb 14, 2020
1 parent 5c4d530 commit e87e6ee
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 22 deletions.
19 changes: 13 additions & 6 deletions dist/grove-vue-core-components.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,13 @@ var script$1 = {
return totalSum;
},
updateSuggestions: function updateSuggestions(nodes) {
var this$1 = this;

var self = this;
self.suggestionsList = [];
Object.keys(nodes).forEach(function (id) {
var node = nodes[id];
if (node.sum > 0) {
if (this$1.showEmpty_ || node.sum > 0) {
if (node.label) {
self.suggestionsList.push(node.label);
}
Expand Down Expand Up @@ -564,9 +566,13 @@ var script$1 = {
var this$1 = this;

if (this.facet !== undefined && Object.keys(this.nodes_).length) {
this.facet.facetValues.forEach(function (facetValue) {
this$1.nodes_[facetValue.value].value = facetValue.count;
});
if (this.facet.facetValues) {
this.facet.facetValues.forEach(function (facetValue) {
if (this$1.nodes_[facetValue.value]) {
this$1.nodes_[facetValue.value].value = facetValue.count;
}
});
}
this.calculateSums(this.nodes_, this.startIds);
this.updateSuggestions(this.nodes_);

Expand All @@ -582,6 +588,7 @@ var script$1 = {
showEmpty: function showEmpty(newEmpty) {
if (newEmpty !== undefined) {
this.showEmpty_ = newEmpty;
this.updateSuggestions(this.nodes_);
}
},
facet: function facet() {
Expand Down Expand Up @@ -751,11 +758,11 @@ __vue_render__$1._withStripped = true;
/* style */
var __vue_inject_styles__$1 = function (inject) {
if (!inject) { return }
inject("data-v-005bd809_0", { source: ".ml-facet .facet-add-pos[data-v-005bd809],\n.ml-facet .facet-add-neg[data-v-005bd809] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-005bd809],\n.ml-facet div:hover > .facet-add-neg[data-v-005bd809] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-005bd809] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });
inject("data-v-72871f89_0", { source: ".ml-facet .facet-add-pos[data-v-72871f89],\n.ml-facet .facet-add-neg[data-v-72871f89] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-72871f89],\n.ml-facet div:hover > .facet-add-neg[data-v-72871f89] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-72871f89] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });

};
/* scoped */
var __vue_scope_id__$1 = "data-v-005bd809";
var __vue_scope_id__$1 = "data-v-72871f89";
/* module identifier */
var __vue_module_identifier__$1 = undefined;
/* functional template */
Expand Down
19 changes: 13 additions & 6 deletions dist/grove-vue-core-components.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,13 @@ var CoreComponents = (function (exports, Multiselect) {
return totalSum;
},
updateSuggestions: function updateSuggestions(nodes) {
var this$1 = this;

var self = this;
self.suggestionsList = [];
Object.keys(nodes).forEach(function (id) {
var node = nodes[id];
if (node.sum > 0) {
if (this$1.showEmpty_ || node.sum > 0) {
if (node.label) {
self.suggestionsList.push(node.label);
}
Expand Down Expand Up @@ -566,9 +568,13 @@ var CoreComponents = (function (exports, Multiselect) {
var this$1 = this;

if (this.facet !== undefined && Object.keys(this.nodes_).length) {
this.facet.facetValues.forEach(function (facetValue) {
this$1.nodes_[facetValue.value].value = facetValue.count;
});
if (this.facet.facetValues) {
this.facet.facetValues.forEach(function (facetValue) {
if (this$1.nodes_[facetValue.value]) {
this$1.nodes_[facetValue.value].value = facetValue.count;
}
});
}
this.calculateSums(this.nodes_, this.startIds);
this.updateSuggestions(this.nodes_);

Expand All @@ -584,6 +590,7 @@ var CoreComponents = (function (exports, Multiselect) {
showEmpty: function showEmpty(newEmpty) {
if (newEmpty !== undefined) {
this.showEmpty_ = newEmpty;
this.updateSuggestions(this.nodes_);
}
},
facet: function facet() {
Expand Down Expand Up @@ -753,11 +760,11 @@ var CoreComponents = (function (exports, Multiselect) {
/* style */
var __vue_inject_styles__$1 = function (inject) {
if (!inject) { return }
inject("data-v-005bd809_0", { source: ".ml-facet .facet-add-pos[data-v-005bd809],\n.ml-facet .facet-add-neg[data-v-005bd809] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-005bd809],\n.ml-facet div:hover > .facet-add-neg[data-v-005bd809] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-005bd809] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });
inject("data-v-72871f89_0", { source: ".ml-facet .facet-add-pos[data-v-72871f89],\n.ml-facet .facet-add-neg[data-v-72871f89] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-72871f89],\n.ml-facet div:hover > .facet-add-neg[data-v-72871f89] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-72871f89] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });

};
/* scoped */
var __vue_scope_id__$1 = "data-v-005bd809";
var __vue_scope_id__$1 = "data-v-72871f89";
/* module identifier */
var __vue_module_identifier__$1 = undefined;
/* functional template */
Expand Down
19 changes: 13 additions & 6 deletions dist/grove-vue-core-components.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,13 @@
return totalSum;
},
updateSuggestions: function updateSuggestions(nodes) {
var this$1 = this;

var self = this;
self.suggestionsList = [];
Object.keys(nodes).forEach(function (id) {
var node = nodes[id];
if (node.sum > 0) {
if (this$1.showEmpty_ || node.sum > 0) {
if (node.label) {
self.suggestionsList.push(node.label);
}
Expand Down Expand Up @@ -569,9 +571,13 @@
var this$1 = this;

if (this.facet !== undefined && Object.keys(this.nodes_).length) {
this.facet.facetValues.forEach(function (facetValue) {
this$1.nodes_[facetValue.value].value = facetValue.count;
});
if (this.facet.facetValues) {
this.facet.facetValues.forEach(function (facetValue) {
if (this$1.nodes_[facetValue.value]) {
this$1.nodes_[facetValue.value].value = facetValue.count;
}
});
}
this.calculateSums(this.nodes_, this.startIds);
this.updateSuggestions(this.nodes_);

Expand All @@ -587,6 +593,7 @@
showEmpty: function showEmpty(newEmpty) {
if (newEmpty !== undefined) {
this.showEmpty_ = newEmpty;
this.updateSuggestions(this.nodes_);
}
},
facet: function facet() {
Expand Down Expand Up @@ -756,11 +763,11 @@
/* style */
var __vue_inject_styles__$1 = function (inject) {
if (!inject) { return }
inject("data-v-005bd809_0", { source: ".ml-facet .facet-add-pos[data-v-005bd809],\n.ml-facet .facet-add-neg[data-v-005bd809] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-005bd809],\n.ml-facet div:hover > .facet-add-neg[data-v-005bd809] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-005bd809] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });
inject("data-v-72871f89_0", { source: ".ml-facet .facet-add-pos[data-v-72871f89],\n.ml-facet .facet-add-neg[data-v-72871f89] {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos[data-v-72871f89],\n.ml-facet div:hover > .facet-add-neg[data-v-72871f89] {\n visibility: visible !important;\n}\n.ml-facet form[data-v-72871f89] {\n padding-bottom: 0;\n}\n", map: {"version":3,"sources":["ml-tree-facet.vue"],"names":[],"mappings":"AAAA;;EAEE,kBAAkB;AACpB;AACA;;EAEE,8BAA8B;AAChC;AACA;EACE,iBAAiB;AACnB","file":"ml-tree-facet.vue","sourcesContent":[".ml-facet .facet-add-pos,\n.ml-facet .facet-add-neg {\n visibility: hidden;\n}\n.ml-facet span:hover > .facet-add-pos,\n.ml-facet div:hover > .facet-add-neg {\n visibility: visible !important;\n}\n.ml-facet form {\n padding-bottom: 0;\n}\n"]}, media: undefined });

};
/* scoped */
var __vue_scope_id__$1 = "data-v-005bd809";
var __vue_scope_id__$1 = "data-v-72871f89";
/* module identifier */
var __vue_module_identifier__$1 = undefined;
/* functional template */
Expand Down
13 changes: 9 additions & 4 deletions src/components/ml-tree-facet/ml-tree-facet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default {
self.suggestionsList = [];
Object.keys(nodes).forEach(id => {
const node = nodes[id];
if (node.sum > 0) {
if (this.showEmpty_ || node.sum > 0) {
if (node.label) {
self.suggestionsList.push(node.label);
}
Expand Down Expand Up @@ -197,9 +197,13 @@ export default {
},
init() {
if (this.facet !== undefined && Object.keys(this.nodes_).length) {
this.facet.facetValues.forEach(facetValue => {
this.nodes_[facetValue.value].value = facetValue.count;
});
if (this.facet.facetValues) {
this.facet.facetValues.forEach(facetValue => {
if (this.nodes_[facetValue.value]) {
this.nodes_[facetValue.value].value = facetValue.count;
}
});
}
this.calculateSums(this.nodes_, this.startIds);
this.updateSuggestions(this.nodes_);
Expand All @@ -215,6 +219,7 @@ export default {
showEmpty(newEmpty) {
if (newEmpty !== undefined) {
this.showEmpty_ = newEmpty;
this.updateSuggestions(this.nodes_);
}
},
facet() {
Expand Down

0 comments on commit e87e6ee

Please sign in to comment.