Clientes: Recordar campos busqueda avanzada

This commit is contained in:
Vicente Falco 2017-03-10 07:19:43 +01:00
parent 7059eadfc7
commit 5e66bef50c
4 changed files with 29 additions and 10 deletions

View File

@ -1,5 +1,5 @@
<div pad-large style="min-width: 30em;" ng-show="$ctrl.formVisibility"> <div pad-large style="min-width: 30em;" ng-show="$ctrl.formVisibility">
<form name="form" ng-submit="form.$valid && $ctrl.onSubmit($ctrl.filter)" ng-keyup="$ctrl.getKeyPressed($event)"> <form name="form" ng-submit="form.$valid && $ctrl.onSearch()" ng-keyup="$ctrl.getKeyPressed($event)">
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Id Cliente" model="$ctrl.filter.id" vn-focus></vn-textfield> <vn-textfield vn-one label="Id Cliente" model="$ctrl.filter.id" vn-focus></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" model="$ctrl.filter.fi"></vn-textfield> <vn-textfield vn-one label="NIF/CIF" model="$ctrl.filter.fi"></vn-textfield>

View File

@ -3,13 +3,26 @@ import {module} from '../module';
export const NAME = 'vnClientSearchPanel'; export const NAME = 'vnClientSearchPanel';
export const COMPONENT = { export const COMPONENT = {
template: require('./index.html'), template: require('./index.html'),
controller: function($scope) { controller: function($scope, $window) {
this.filter = {id: null, fi: null, name: null, socialName: null, city: null, postcode: null, email: null, phone: null};
this.formVisibility = true; this.formVisibility = true;
this.onSubmit = function() {}; this.onSearch = () => {
this.getKeyPressed = function(event){ this.setStorageValue();
if (event.which === 27) this.onSubmit(this.filter);
};
this.getKeyPressed = function(event) {
if (event.which === 27)
this.formVisibility = false; this.formVisibility = false;
}; };
this.$onChanges = () => {
var value = JSON.parse($window.sessionStorage.getItem('filter'));
if (value !== undefined)
this.filter = value;
};
this.setStorageValue = () => {
$window.sessionStorage.setItem('filter', JSON.stringify(this.filter));
};
} }
}; };
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -2,12 +2,13 @@ import {module} from '../../module';
require('./style.css'); require('./style.css');
class Controller { class Controller {
constructor($element, $scope, $document, $compile, vnPopover) { constructor($element, $scope, $document, $compile, vnPopover, $window) {
this.element = $element[0]; this.element = $element[0];
this.$scope = $scope; this.$scope = $scope;
this.$document = $document; this.$document = $document;
this.$compile = $compile; this.$compile = $compile;
this.vnPopover = vnPopover; this.vnPopover = vnPopover;
this.$window = $window;
} }
onClick(event) { onClick(event) {
var child = this.$document[0].createElement(this.popover); var child = this.$document[0].createElement(this.popover);
@ -26,11 +27,14 @@ class Controller {
this.onSubmit(); this.onSubmit();
} }
onSubmit() { onSubmit() {
if(this.onSearch) if (this.onSearch)
this.onSearch(); this.onSearch();
} }
$onDestroy() {
this.$window.sessionStorage.removeItem('filter');
}
} }
Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover']; Controller.$inject = ['$element', '$scope', '$document', '$compile', 'vnPopover', '$window'];
export const NAME = 'vnSearchbar' export const NAME = 'vnSearchbar'
export const COMPONENT = { export const COMPONENT = {

View File

@ -10,7 +10,7 @@
"Province": 44, "Province": 44,
"Agency": 4, "Agency": 4,
"Account": 32, "Account": 32,
"ClientObservation": 1272 "ClientObservation": 1274
}, },
"models": { "models": {
"User": { "User": {
@ -140,7 +140,9 @@
"1268": "{\"text\":\"dsfasdf asf asfdasf sda fdsadf adsf sdafh sdalfhsdlafd haslkfhalsfh alskdhf lasdkfh laskf hlaskdhf lkadsh lkasdhfla ksdhf lsdfh askldfh lasf hsald fhasldf hsalkhf lsdh flkshf lskdhf lskdfh lskf hlsfh lasdkhf lskhf laskfh lsaf ksdh flshf lkashf lsakhf laskfh lsakdhf laskdf hlaskdfh laskhfd lasf hlaskfh lasdkhf laskdf hlsad fhskfhaslkdfh askdfh asklf lsakdf\",\"creationDate\":\"2017-01-23T08:14:58.000Z\",\"client\":\"17\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1268}", "1268": "{\"text\":\"dsfasdf asf asfdasf sda fdsadf adsf sdafh sdalfhsdlafd haslkfhalsfh alskdhf lasdkfh laskf hlaskdhf lkadsh lkasdhfla ksdhf lsdfh askldfh lasf hsald fhasldf hsalkhf lsdh flkshf lskdhf lskdfh lskf hlsfh lasdkhf lskhf laskfh lsaf ksdh flshf lkashf lsakhf laskfh lsakdhf laskdf hlaskdfh laskhfd lasf hlaskfh lasdkhf laskdf hlsad fhskfhaslkdfh askdfh asklf lsakdf\",\"creationDate\":\"2017-01-23T08:14:58.000Z\",\"client\":\"17\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1268}",
"1269": "{\"text\":\"yyyyy\",\"creationDate\":\"2017-02-07T09:11:11.000Z\",\"id\":1269}", "1269": "{\"text\":\"yyyyy\",\"creationDate\":\"2017-02-07T09:11:11.000Z\",\"id\":1269}",
"1270": "{\"text\":\"7777\",\"creationDate\":\"2017-02-07T09:12:13.000Z\",\"id\":1270}", "1270": "{\"text\":\"7777\",\"creationDate\":\"2017-02-07T09:12:13.000Z\",\"id\":1270}",
"1271": "{\"text\":\"dddd\",\"creationDate\":\"2017-02-07T09:12:39.000Z\",\"id\":1271}" "1271": "{\"text\":\"dddd\",\"creationDate\":\"2017-02-07T09:12:39.000Z\",\"id\":1271}",
"1272": "{\"text\":\"12121\",\"creationDate\":\"2017-03-09T13:29:01.000Z\",\"id\":1272}",
"1273": "{\"text\":\"23232323232323\",\"creationDate\":\"2017-03-09T13:29:28.000Z\",\"id\":1273}"
} }
} }
} }