From 5e66bef50cc391f04e3b2ffeb2034883a835fa7f Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Fri, 10 Mar 2017 07:19:43 +0100 Subject: [PATCH 1/2] Clientes: Recordar campos busqueda avanzada --- client/client/src/search-panel/index.html | 2 +- client/client/src/search-panel/index.js | 21 +++++++++++++++---- .../src/components/searchbar/searchbar.js | 10 ++++++--- db.json | 6 ++++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/client/client/src/search-panel/index.html b/client/client/src/search-panel/index.html index 365308173..60385efc5 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 2692e1136..bf8af3c03 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 44cc2a38c..246d15cfc 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 c15712c4f..d27a7e649 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 From 4bc1cf455bff7dd529417f89cd808d6f2daa264b Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Fri, 10 Mar 2017 11:18:16 +0100 Subject: [PATCH 2/2] notes: Crear --- client/client/src/new-note/index.js | 2 +- services/client/common/models/ClientObservation.js | 9 ++++----- services/client/common/models/ClientObservation.json | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/client/src/new-note/index.js b/client/client/src/new-note/index.js index 2658df2a6..e4001c688 100644 --- a/client/client/src/new-note/index.js +++ b/client/client/src/new-note/index.js @@ -11,7 +11,7 @@ class Controller { }; } onSubmit() { - this.element.querySelector('vn-watcher').$ctrl.submit().then ( + this.element.querySelector('vn-watcher').$ctrl.submit().then( () => this.$state.go('clientCard.notes') ); } diff --git a/services/client/common/models/ClientObservation.js b/services/client/common/models/ClientObservation.js index 3338e33e9..046baf646 100644 --- a/services/client/common/models/ClientObservation.js +++ b/services/client/common/models/ClientObservation.js @@ -1,12 +1,11 @@ module.exports = function(ClientObservation) { - - ClientObservation.validate('text',isEnabled,{message: 'Se debe rellenar el campo de texto'}); + ClientObservation.validate('text', isEnabled, {message: 'Se debe rellenar el campo de texto'}); function isEnabled(err) { - if (!this.text) err(); + if (!this.text) err(); } - ClientObservation.observe('before save', function (ctx, next) { + ClientObservation.observe('before save', function(ctx, next) { ctx.instance.creationDate = Date(); next(); }); -}; \ No newline at end of file +}; diff --git a/services/client/common/models/ClientObservation.json b/services/client/common/models/ClientObservation.json index 09d9cbc32..e4ed95743 100644 --- a/services/client/common/models/ClientObservation.json +++ b/services/client/common/models/ClientObservation.json @@ -24,9 +24,9 @@ "model": "SalesPerson", "foreignKey": "id" }, - "client": { + "clients": { + "type": "hasOne", "model": "Client", - "type": "belongsTo", "foreignKey": "id" } }