searchbar clean filters
This commit is contained in:
parent
d4a0cf205d
commit
44dde2b705
|
@ -1,8 +1,8 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($window) {
|
||||
this.$window = $window;
|
||||
constructor(sessionStorage) {
|
||||
this.sessionStorage = sessionStorage;
|
||||
// onSubmit() is defined by @vnSearchbar
|
||||
this.onSubmit = () => {};
|
||||
}
|
||||
|
@ -13,16 +13,16 @@ export default class Controller {
|
|||
}
|
||||
|
||||
$onChanges() {
|
||||
var value = JSON.parse(this.$window.sessionStorage.getItem('filter'));
|
||||
var value = this.sessionStorage.get('filter');
|
||||
if (value !== undefined)
|
||||
this.filter = value;
|
||||
}
|
||||
|
||||
setStorageValue() {
|
||||
this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter));
|
||||
this.sessionStorage.set('filter', this.filter);
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$window'];
|
||||
Controller.$inject = ['sessionStorage'];
|
||||
|
||||
ngModule.component('vnClientSearchPanel', {
|
||||
template: require('./search-panel.html'),
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
style="cursor: pointer;">
|
||||
</vn-icon>
|
||||
<vn-button ng-if="$ctrl.label" vn-none label="{{$ctrl.label}}"></vn-button>
|
||||
<vn-icon-button ng-if="!$ctrl.label" icon="search"></vn-icon-button>
|
||||
<vn-icon-button ng-if="!$ctrl.label" icon="search" ng-click="$ctrl.clearFilter()"></vn-icon-button>
|
||||
</vn-horizontal>
|
||||
</form>
|
|
@ -1,15 +1,22 @@
|
|||
import ngModule from '../../module';
|
||||
|
||||
export default class Controller {
|
||||
constructor($element, $scope, $document, $compile, vnPopover, $window) {
|
||||
constructor($element, $scope, $document, $compile, vnPopover, sessionStorage, $timeout) {
|
||||
this.element = $element[0];
|
||||
this.$scope = $scope;
|
||||
this.$document = $document;
|
||||
this.$compile = $compile;
|
||||
this.vnPopover = vnPopover;
|
||||
this.$window = $window;
|
||||
this.sessionStorage = sessionStorage;
|
||||
this.$timeout = $timeout;
|
||||
}
|
||||
clearFilter() {
|
||||
this.index.filter = {};
|
||||
this.sessionStorage.remove('filter');
|
||||
}
|
||||
onClick(event) {
|
||||
this.search = null;
|
||||
|
||||
this.child = this.vnPopover.showComponent(this.popover, this.$scope, this.element);
|
||||
|
||||
// XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente?
|
||||
|
@ -37,10 +44,10 @@ export default class Controller {
|
|||
delete this.child;
|
||||
}
|
||||
$onDestroy() {
|
||||
this.$window.sessionStorage.removeItem('filter');
|
||||
this.clearFilter();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', '$window'];
|
||||
Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', 'sessionStorage', '$timeout'];
|
||||
|
||||
ngModule.component('vnSearchbar', {
|
||||
template: require('./searchbar.html'),
|
||||
|
|
Loading…
Reference in New Issue