ElasticUI
ElasticUI copied to clipboard
Remove query, filter, etc. on controller $destroy
Current implementation seems to assume eui-filters are stable, but I am trying to dynamically add/remove them like elasticsearch-head does.
It is not intuitive that a disappeared eui-filter is still in indexVM, and the user must reload the page to deactivate it.
I appreciate if FilterController and its families add something like follows in init().
this.scope.$on '$destroy', (ev) =>
this.scope.filter.enabled = false
this.updateFilter()
Thanks, that's good feedback on an issue I didn't run into myself yet. Do you think you could apply the changes and submit a PR? On Jan 27, 2015 6:09 PM, "tomykaira" [email protected] wrote:
Current implementation seems to assume eui-filters are stable, but I am trying to dynamically add/remove them like elasticsearch-head does. It is not intuitive that a disappeared eui-filter is still in indexVM, and the user must reload the page to deactivate it. I appreciate if FilterController and its families add something like follows in init().
this.scope.$on '$destroy', (ev) => this.scope.filter.enabled = false this.updateFilter()
Reply to this email directly or view it on GitHub https://github.com/YousefED/ElasticUI/issues/21.
Sure! I am new to TypeScript, so please point out something is awkward.
I think I have the same problem, when a eui-filter disappears it's still in indexVM.
I try to add like you said in FilterController.prototype.init
FilterController.prototype.init = function() {
var _this = this;
if (this.scope.filter.filter) {
var isEnabled = this.scope.filters.contains(this.scope.filter.filter);
if (!isEnabled && this.scope.filter.enabled) {
this.scope.filters.add(this.scope.filter.filter);
isEnabled = true;
}
}
this.scope.filter.enabled = isEnabled;
this.scope.$watch('filter.enabled', function(newVal, oldVal) {
if (newVal !== oldVal) {
_this.updateFilter();
}
});
this.scope.$watch('filter.filter', function(newVal, oldVal) {
if (!elasticui.util.EjsTool.equals(oldVal, newVal)) {
if (oldVal) {
_this.scope.filters.remove(oldVal);
}
_this.updateFilter();
}
});
this.scope.$on('$destroy', function() {
_this.scope.filter.enabled = false;
_this.updateFilter();
});
};
But when I checked one item filter.enabled always change on false.