diff --git a/client/client/src/search-panel/index.html b/client/client/src/search-panel/index.html index 3653081737..60385efc56 100644 --- a/client/client/src/search-panel/index.html +++ b/client/client/src/search-panel/index.html @@ -1,5 +1,5 @@
-
+ diff --git a/client/client/src/search-panel/index.js b/client/client/src/search-panel/index.js index 2692e11369..bf8af3c039 100644 --- a/client/client/src/search-panel/index.js +++ b/client/client/src/search-panel/index.js @@ -3,13 +3,26 @@ import {module} from '../module'; export const NAME = 'vnClientSearchPanel'; export const COMPONENT = { 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.onSubmit = function() {}; - this.getKeyPressed = function(event){ - if (event.which === 27) + this.onSearch = () => { + this.setStorageValue(); + this.onSubmit(this.filter); + }; + this.getKeyPressed = function(event) { + if (event.which === 27) 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); diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js index 44cc2a38cd..246d15cfc5 100644 --- a/client/salix/src/components/searchbar/searchbar.js +++ b/client/salix/src/components/searchbar/searchbar.js @@ -2,12 +2,13 @@ import {module} from '../../module'; require('./style.css'); class Controller { - constructor($element, $scope, $document, $compile, vnPopover) { + constructor($element, $scope, $document, $compile, vnPopover, $window) { this.element = $element[0]; this.$scope = $scope; this.$document = $document; this.$compile = $compile; this.vnPopover = vnPopover; + this.$window = $window; } onClick(event) { var child = this.$document[0].createElement(this.popover); @@ -26,11 +27,14 @@ class Controller { this.onSubmit(); } onSubmit() { - if(this.onSearch) + if (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 COMPONENT = { diff --git a/db.json b/db.json index c15712c4f7..d27a7e649f 100644 --- a/db.json +++ b/db.json @@ -10,7 +10,7 @@ "Province": 44, "Agency": 4, "Account": 32, - "ClientObservation": 1272 + "ClientObservation": 1274 }, "models": { "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}", "1269": "{\"text\":\"yyyyy\",\"creationDate\":\"2017-02-07T09:11:11.000Z\",\"id\":1269}", "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}" } } } \ No newline at end of file