diff --git a/client/client/routes.json b/client/client/routes.json index bd49efb49..ecfdc4ea7 100644 --- a/client/client/routes.json +++ b/client/client/routes.json @@ -7,6 +7,10 @@ "url": "/clients", "state": "clients", "component": "vn-client-index" + }, { + "url": "/create", + "state": "create", + "component": "vn-client-create" }, { "url": "/clients/:id", "state": "clientCard", @@ -23,7 +27,7 @@ "description": "Datos básicos", "icon": "person" } - }, { + }, { "url": "/fiscal-data", "state": "clientCard.fiscalData", "component": "vn-client-fiscal-data", @@ -45,7 +49,7 @@ "description": "Datos facturación", "icon": "assignment" } - },{ + }, { "url": "/addresses", "state": "clientCard.addresses", "component": "ui-view", @@ -80,7 +84,7 @@ "description": "Acceso web", "icon": "language" } - },{ + }, { "url": "/notes", "state": "clientCard.notes", "component": "ui-view", @@ -96,15 +100,10 @@ "description": "Notas", "icon": "insert_drive_file" } - }, { "url": "/create", "state": "clientCard.notes.create", - "component": "vn-new-note" - },{ - "url": "/create", - "state": "create", - "component": "vn-client-create" + "component": "vn-note-create" } ] } diff --git a/client/client/src/address-create/address-create.html b/client/client/src/address-create/address-create.html index f014ceb36..caf042a21 100644 --- a/client/client/src/address-create/address-create.html +++ b/client/client/src/address-create/address-create.html @@ -5,7 +5,7 @@ data="$ctrl.address" form="form"> -
+ Consignatario diff --git a/client/client/src/address-create/address-create.js b/client/client/src/address-create/address-create.js index 8e23af6ea..6c3e4521b 100644 --- a/client/client/src/address-create/address-create.js +++ b/client/client/src/address-create/address-create.js @@ -1,25 +1,16 @@ -import {module} from '../module'; +import ngModule from '../module'; -class Controller { - constructor($scope, $state) { - this.$ = $scope; - this.$state = $state; +export default class Controller { + constructor($state) { this.address = { clientFk: parseInt($state.params.id), enabled: true }; } - onSubmit() { - this.$.watcher.submit().then( - () => this.$state.go('clientCard.addresses') - ); - } } -Controller.$inject = ['$scope', '$state']; +Controller.$inject = ['$state']; -export const NAME = 'vnAddressCreate'; -export const COMPONENT = { +ngModule.component('vnAddressCreate', { template: require('./address-create.html'), controller: Controller -}; -module.component(NAME, COMPONENT); +}); diff --git a/client/client/src/address-edit/address-edit.html b/client/client/src/address-edit/address-edit.html index c2086ff2a..a34dddee0 100644 --- a/client/client/src/address-edit/address-edit.html +++ b/client/client/src/address-edit/address-edit.html @@ -3,7 +3,7 @@ get="true" url="/client/api/Addresses" id-field="id" - data="addressData.address" + data="$ctrl.address" form="form"> @@ -11,18 +11,18 @@ Consignatario - - + + - - + + - - + + - - + + diff --git a/client/client/src/address-edit/address-edit.js b/client/client/src/address-edit/address-edit.js index 1e4fdb600..0605a3c02 100644 --- a/client/client/src/address-edit/address-edit.js +++ b/client/client/src/address-edit/address-edit.js @@ -1,18 +1,5 @@ -import {module} from '../module'; +import ngModule from '../module'; -class Controller { - constructor($stateParams) { - this.address = { - id: $stateParams.addressId - }; - } -} -Controller.$inject = ['$stateParams']; - -export const NAME = 'vnAddressEdit'; -export const COMPONENT = { - template: require('./address-edit.html'), - controllerAs: 'addressData', - controller: Controller -}; -module.component(NAME, COMPONENT); +ngModule.component('vnAddressEdit', { + template: require('./address-edit.html') +}); diff --git a/client/client/src/addresses/addresses.js b/client/client/src/addresses/addresses.js index be0e6f398..12c2c380e 100644 --- a/client/client/src/addresses/addresses.js +++ b/client/client/src/addresses/addresses.js @@ -1,6 +1,5 @@ -import {module} from '../module'; +import ngModule from '../module'; -export const component = { +ngModule.component('vnClientAddresses', { template: require('./addresses.html') -}; -module.component('vnClientAddresses', component); +}); diff --git a/client/client/src/basic-data/basic-data.html b/client/client/src/basic-data/basic-data.html index 0283320b3..5563d1e7d 100644 --- a/client/client/src/basic-data/basic-data.html +++ b/client/client/src/basic-data/basic-data.html @@ -1,9 +1,9 @@ - + + save="patch"> diff --git a/client/client/src/basic-data/basic-data.js b/client/client/src/basic-data/basic-data.js index de05dd81a..e7d877432 100644 --- a/client/client/src/basic-data/basic-data.js +++ b/client/client/src/basic-data/basic-data.js @@ -1,9 +1,8 @@ -import {module} from '../module'; +import ngModule from '../module'; -export const component = { +ngModule.component('vnClientBasicData', { template: require('./basic-data.html'), bindings: { client: '<' } -}; -module.component('vnClientBasicData', component); +}); diff --git a/client/client/src/billing-data/billing-data.html b/client/client/src/billing-data/billing-data.html index 5d37e4f3a..f43f41e76 100644 --- a/client/client/src/billing-data/billing-data.html +++ b/client/client/src/billing-data/billing-data.html @@ -1,30 +1,30 @@ - + + save="patch"> - + Información de facturación - - + + - - - - + + + + @@ -32,9 +32,9 @@ Documentación - - - + + + @@ -44,7 +44,7 @@
+ on-response="$ctrl.returnDialog(response)"> Changed terms diff --git a/client/client/src/billing-data/billing-data.js b/client/client/src/billing-data/billing-data.js index 813aa79b1..8fe8062c6 100644 --- a/client/client/src/billing-data/billing-data.js +++ b/client/client/src/billing-data/billing-data.js @@ -1,8 +1,6 @@ -import {module} from '../module'; +import ngModule from '../module'; -export const NAME = 'vnClientBillingData'; - -class billingData { +export default class Controller { constructor($scope, $http, $timeout, vnAppLogger, $translate) { this.$ = $scope; this.http = $http; @@ -13,18 +11,15 @@ class billingData { this.dueDay = null; this.copyData(); } - $onChanges(changes) { this.copyData(); } - copyData() { if (this.client) { this.payId = this.client.payMethodFk || null; this.dueDay = this.client.dueDay ? this.client.dueDay : null; } } - checkChanges() { let payId = this.client.payMethodFk || null; let dueDay = this.client.dueDay || null; @@ -45,19 +40,16 @@ class billingData { } this.timeout(() => this.$.watcher.submit()); } - sendMail() { return this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id}); } } -billingData.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate']; +Controller.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate']; -export const COMPONENT = { +ngModule.component('vnClientBillingData', { template: require('./billing-data.html'), - controller: billingData, - controllerAs: 'bill', + controller: Controller, bindings: { client: '<' } -}; -module.component(NAME, COMPONENT); +}); diff --git a/client/client/src/card/card.html b/client/client/src/card/card.html index 589deb152..0319c72fd 100644 --- a/client/client/src/card/card.html +++ b/client/client/src/card/card.html @@ -1,7 +1,15 @@ - + + - + + diff --git a/client/client/src/card/card.js b/client/client/src/card/card.js index 43d19facf..06689a697 100644 --- a/client/client/src/card/card.js +++ b/client/client/src/card/card.js @@ -1,17 +1,14 @@ -import {module} from '../module'; +import ngModule from '../module'; import './style.css'; -export const NAME = 'vnClientCard'; - -export default class vnClientCard { +export default class Controller { constructor() { this.client = null; } } - -module.component(NAME, { +ngModule.component('vnClientCard', { template: require('./card.html'), - controllerAs: 'card', - controller: vnClientCard + controller: Controller, + controllerAs: 'card' }); diff --git a/client/client/src/client.js b/client/client/src/client.js index 1ae857fa4..6dc0de725 100644 --- a/client/client/src/client.js +++ b/client/client/src/client.js @@ -1,27 +1,16 @@ export * from './module'; -export {NAME as CLIENT_CARD, - COMPONENT as CLIENT_CARD_COMPONENT} from './card/card'; -export {NAME as CLIENTS, - COMPONENT as CLIENTS_COMPONENT} from './index/index'; -export {NAME as CLIENT_FISCAL_DATA_INDEX, - COMPONENT as CLIENT_FISCAL_DATA_INDEX_COMPONENT} from './fiscal-data/fiscal-data'; -export {NAME as CLIENT_BILLING_DATA_INDEX, - COMPONENT as CLIENT_BILLINGL_DATA_INDEX_COMPONENT} from './billing-data/billing-data'; -export {NAME as CLIENT_DESCRIPTOR, - COMPONENT as CLIENT_DESCRIPTOR_COMPONENT} from './descriptor/descriptor'; -export {NAME as CLIENT_NOTES, - COMPONENT as CLIENT_NOTES_COMPONENT} from './notes/notes'; -export {NAME as CLIENT_SEARCH_PANEL, - COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/search-panel'; -export {NAME as CLIENT_CREATE, - COMPONENT as CLIENT_CREATE_COMPONENT} from './create/create'; -export {NAME as CLIENT_ADDRESS_EDIT_INDEX, - COMPONENT as CLIENT_ADDRESS_EDIT_INDEX_COMPONENT} from './address-edit/address-edit'; -export {NAME as NEW_NOTE_INDEX, - COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/new-note'; - +import './index/index'; +import './card/card'; +import './create/create'; +import './basic-data/basic-data'; +import './fiscal-data/fiscal-data'; +import './billing-data/billing-data'; +import './descriptor/descriptor'; +import './search-panel/search-panel'; import './addresses/addresses'; import './address-create/address-create'; -import './basic-data/basic-data'; +import './address-edit/address-edit'; +import './notes/notes'; +import './note-create/note-create'; import './web-access/web-access'; diff --git a/client/client/src/create/create.js b/client/client/src/create/create.js index bdf825481..601bab71b 100644 --- a/client/client/src/create/create.js +++ b/client/client/src/create/create.js @@ -1,23 +1,22 @@ -import {module} from '../module'; +import ngModule from '../module'; -class Controller { +export default class Controller { constructor($scope, $state) { - this.$scope = $scope; + this.$ = $scope; this.$state = $state; this.client = { active: true }; } onSubmit() { - this.$scope.watcher.submit().then( + this.$.watcher.submit().then( json => this.$state.go('clientCard.basicData', {id: json.data.id}) ); } } Controller.$inject = ['$scope', '$state']; -export const component = { +ngModule.component('vnClientCreate', { template: require('./create.html'), controller: Controller -}; -module.component('vnClientCreate', component); +}); diff --git a/client/client/src/descriptor/descriptor.html b/client/client/src/descriptor/descriptor.html index 333803051..48a878221 100644 --- a/client/client/src/descriptor/descriptor.html +++ b/client/client/src/descriptor/descriptor.html @@ -5,10 +5,10 @@ person -
{{descriptor.client.id}}
-
{{descriptor.client.name}}
-
{{descriptor.client.phone}}
- +
{{$ctrl.client.id}}
+
{{$ctrl.client.name}}
+
{{$ctrl.client.phone}}
+
diff --git a/client/client/src/descriptor/descriptor.js b/client/client/src/descriptor/descriptor.js index a9c5722ec..b8c2092a9 100644 --- a/client/client/src/descriptor/descriptor.js +++ b/client/client/src/descriptor/descriptor.js @@ -1,21 +1,27 @@ -import {module} from '../module'; +import ngModule from '../module'; import './style.css'; -export const NAME = 'vnDescriptor'; -export const COMPONENT = { +export default class Controller { + constructor($scope, $http) { + this.$http = $http; + } + $onChanges(changes) { + let active = changes.active; + let sendPut = active + && !active.isFirstChange() + && active.previousValue !== active.currentValue; + + if (sendPut) + $http.put(`/client/api/Clients/${this.client.id}/activate`); + } +} +Controller.$inject = ['$scope', '$http']; + +ngModule.component('vnDescriptor', { template: require('./descriptor.html'), - controllerAs: 'descriptor', + controller: Controller, bindings: { client: '<', active: '<' - }, - controller: function($http, $scope) { - var self = this; - $scope.$watch('descriptor.active', function(newValue, oldValue) { - if (oldValue !== undefined) - $http.put(`/client/api/Clients/${self.client.id}/activate`); - }); } -}; -COMPONENT.controller.$inject = ['$http', '$scope']; -module.component(NAME, COMPONENT); +}); diff --git a/client/client/src/fiscal-data/fiscal-data.html b/client/client/src/fiscal-data/fiscal-data.html index 7e9b2a7e9..8dc48b5e8 100644 --- a/client/client/src/fiscal-data/fiscal-data.html +++ b/client/client/src/fiscal-data/fiscal-data.html @@ -1,35 +1,35 @@ - + + save="patch">
Datos fiscales y de facturación - - + + - - + + - + -
{{itemClient.client.name}}
-
Id Cliente: {{itemClient.client.id}}
-
Teléfono: {{itemClient.client.phone | phone}}
-
Población: {{itemClient.client.city}}
-
email: {{itemClient.client.email}}
+ +
{{$ctrl.client.name}}
+
Id Cliente: {{$ctrl.client.id}}
+
Teléfono: {{$ctrl.client.phone | phone}}
+
Población: {{$ctrl.client.city}}
+
email: {{$ctrl.client.email}}
diff --git a/client/client/src/index/item-client.js b/client/client/src/index/item-client.js index 0c666fd7b..ea664d09c 100644 --- a/client/client/src/index/item-client.js +++ b/client/client/src/index/item-client.js @@ -1,11 +1,8 @@ -import {module} from '../module'; +import ngModule from '../module'; -export const NAME = 'vnItemClient'; -export const COMPONENT = { +ngModule.component('vnItemClient', { template: require('./item-client.html'), - controllerAs: 'itemClient', bindings: { client: '<' } -}; -module.component(NAME, COMPONENT); +}); diff --git a/client/client/src/module.js b/client/client/src/module.js index 431ebee0b..1f9ed9768 100644 --- a/client/client/src/module.js +++ b/client/client/src/module.js @@ -1,4 +1,5 @@ import {ng} from 'vendor'; import 'core'; -export const module = ng.module('client', []); +const ngModule = ng.module('client', []); +export default ngModule; diff --git a/client/client/src/new-note/new-note.js b/client/client/src/new-note/new-note.js deleted file mode 100644 index 8138990b5..000000000 --- a/client/client/src/new-note/new-note.js +++ /dev/null @@ -1,27 +0,0 @@ -import template from './new-note.html'; -import {module} from '../module'; - -class Controller { - constructor($element, $state) { - this.element = $element[0]; - this.$state = $state; - this.note = { - clientFk: $state.params.id, - text: null - }; - } - onSubmit() { - this.element.querySelector('vn-watcher').$ctrl.submit().then( - () => this.$state.go('clientCard.notes') - ); - } -} -Controller.$inject = ['$element', '$state']; - -export const NAME = 'vnNewNote'; -export const COMPONENT = { - template: template, - controllerAs: 'newNote', - controller: Controller -}; -module.component(NAME, COMPONENT); diff --git a/client/client/src/new-note/new-note.html b/client/client/src/note-create/note-create.html similarity index 61% rename from client/client/src/new-note/new-note.html rename to client/client/src/note-create/note-create.html index 2e05ec244..4a0617c3a 100644 --- a/client/client/src/new-note/new-note.html +++ b/client/client/src/note-create/note-create.html @@ -2,14 +2,14 @@ vn-id="watcher" url="/client/api/ClientObservations" id-field="id" - data="newNote.note" + data="$ctrl.note" form="form"> - + Nueva nota - + diff --git a/client/client/src/note-create/note-create.js b/client/client/src/note-create/note-create.js new file mode 100644 index 000000000..3f5c68ce2 --- /dev/null +++ b/client/client/src/note-create/note-create.js @@ -0,0 +1,16 @@ +import ngModule from '../module'; + +export default class Controller { + constructor($state) { + this.note = { + clientFk: parseInt($state.params.id), + text: null + }; + } +} +Controller.$inject = ['$state']; + +ngModule.component('vnNoteCreate', { + template: require('./note-create.html'), + controller: Controller +}); diff --git a/client/client/src/notes/notes.html b/client/client/src/notes/notes.html index a671a353e..aad8a06e3 100644 --- a/client/client/src/notes/notes.html +++ b/client/client/src/notes/notes.html @@ -1,7 +1,7 @@ - + Notas - +
{{n.created | date:'dd/MM/yyyy HH:mm'}}
{{n.employee.name}}
@@ -12,6 +12,6 @@
\ No newline at end of file diff --git a/client/client/src/notes/notes.js b/client/client/src/notes/notes.js index d5482bcb1..e482bd276 100644 --- a/client/client/src/notes/notes.js +++ b/client/client/src/notes/notes.js @@ -1,34 +1,34 @@ +import ngModule from '../module'; import './style.css'; -import template from './notes.html'; -import {module} from '../module'; -export const NAME = 'vnClientNotes'; -export const COMPONENT = { - template: template, - controllerAs: 'observation', +export default class Controller { + constructor($http, $state) { + this.$http = $http; + this.$state = $state; + } + $onChanges(changes) { + if (this.client) { + this.getObservation(this.client.id); + } + } + getObservation(clientId) { + let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'}); + this.$http.get(`/client/api/clientObservations?filter=${json}`).then( + json => { + this.observations = json.data; + } + ); + } + newObservation() { + this.$state.go("clientCard.notes.create", {id: this.client.id}); + } +} +Controller.$inject = ['$http', '$state']; + +ngModule.component('vnClientNotes', { + template: require('./notes.html'), + controller: Controller, bindings: { client: '<' - }, - controller: function($http, $state) { - this.$onChanges = function(changes) { - if (this.client) { - this.getObservation(this.client.id); - } - }; - - this.getObservation = function(clientId) { - let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'}); - $http.get(`/client/api/clientObservations?filter=${json}`).then( - json => { - this.observations = json.data; - } - ); - }; - - this.newObservation = () => { - $state.go("clientCard.notes.create", {id: this.client.id}); - }; } -}; -COMPONENT.controller.$inject = ['$http', '$state']; -module.component(NAME, COMPONENT); +}); diff --git a/client/client/src/search-panel/search-panel.html b/client/client/src/search-panel/search-panel.html index 60385efc5..43ab1c73e 100644 --- a/client/client/src/search-panel/search-panel.html +++ b/client/client/src/search-panel/search-panel.html @@ -1,5 +1,5 @@ -
- +
+ diff --git a/client/client/src/search-panel/search-panel.js b/client/client/src/search-panel/search-panel.js index c809bc615..7d15301fe 100644 --- a/client/client/src/search-panel/search-panel.js +++ b/client/client/src/search-panel/search-panel.js @@ -1,28 +1,35 @@ -import {module} from '../module'; +import ngModule from '../module'; -export const NAME = 'vnClientSearchPanel'; -export const COMPONENT = { - template: require('./search-panel.html'), - 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.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)); +export default class Controller { + constructor($window) { + this.$window = $window; + this.filter = { + id: null, + fi: null, + name: null, + socialName: null, + city: null, + postcode: null, + email: null, + phone: null }; } -}; + onSearch() { + this.setStorageValue(); + this.onSubmit(this.filter); + } + $onChanges() { + var value = JSON.parse(this.$window.sessionStorage.getItem('filter')); + if (value !== undefined) + this.filter = value; + } + setStorageValue() { + this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter)); + } +} +Controller.$inject = ['$window']; -module.component(NAME, COMPONENT); +ngModule.component('vnClientSearchPanel', { + template: require('./search-panel.html'), + controller: Controller +}); diff --git a/client/client/src/web-access/web-access.js b/client/client/src/web-access/web-access.js index 413d80059..6a2eedecb 100644 --- a/client/client/src/web-access/web-access.js +++ b/client/client/src/web-access/web-access.js @@ -1,8 +1,8 @@ -import {module} from '../module'; +import ngModule from '../module'; -class Controller { +export default class Controller { constructor($scope, $http, vnAppLogger) { - this.$scope = $scope; + this.$ = $scope; this.$http = $http; this.vnAppLogger = vnAppLogger; } @@ -13,7 +13,7 @@ class Controller { onPassOpen() { this.newPassword = ''; this.repeatPassword = ''; - this.$scope.$apply(); + this.$.$apply(); } onPassChange(response) { if (response == 'ACCEPT') @@ -26,7 +26,7 @@ class Controller { password: this.newPassword }; - this.$http.put(`/client/api/Accounts/${this.client.id}`, account); + this.$http.patch(`/client/api/Accounts/${this.client.id}`, account); } catch (e) { this.vnAppLogger.showError(e.message); return false; @@ -37,10 +37,10 @@ class Controller { } Controller.$inject = ['$scope', '$http', 'vnAppLogger']; -module.component('vnClientWebAccess', { +ngModule.component('vnClientWebAccess', { template: require('./web-access.html'), + controller: Controller, bindings: { client: '<' - }, - controller: Controller + } }); diff --git a/client/core/src/dialog/dialog.js b/client/core/src/dialog/dialog.js index e2be65799..6f2c7d3c7 100644 --- a/client/core/src/dialog/dialog.js +++ b/client/core/src/dialog/dialog.js @@ -56,6 +56,9 @@ export default class Dialog extends Component { } /** * Calls the response handler. + * + * @param {String} response The response code + * @return {Boolean} %true if response was canceled, %false otherwise */ fireResponse(response) { let cancel = false; diff --git a/client/core/src/lib/crud.js b/client/core/src/lib/crud.js index 5bddebfb8..f515009b5 100644 --- a/client/core/src/lib/crud.js +++ b/client/core/src/lib/crud.js @@ -24,6 +24,14 @@ function put(mgPut) { } module.factory('vnPut', put); +put.$inject = ['mgPatch']; +function patch(mgPatch) { + return Object.assign({}, mgPatch, { + success: 'vnSuccessFactoryCreate' + }); +} +module.factory('vnPatch', patch); + post.$inject = ['mgCreate']; function post(mgCreate) { return Object.assign({}, mgCreate, { diff --git a/client/core/src/popover/popover.js b/client/core/src/popover/popover.js index 30a56a633..f04cb3d09 100644 --- a/client/core/src/popover/popover.js +++ b/client/core/src/popover/popover.js @@ -2,12 +2,12 @@ import {module} from '../module'; import './style.css'; directive.$inject = ['vnPopover']; -export function directive(popover) { +export function directive(vnPopover) { return { restrict: 'A', link: function($scope, $element, $attrs) { $element.on('click', function(event) { - popover.showComponent($attrs.vnDialog, $scope, $element); + vnPopover.showComponent($attrs.vnDialog, $scope, $element); event.preventDefault(); }); } @@ -24,7 +24,7 @@ export class Popover { let popover = this.document.createElement('div'); popover.className = 'vn-popover'; popover.addEventListener('mousedown', - event => this.onPopoverMouseDown(event)); + e => this.onPopoverMouseDown(e)); popover.appendChild(childElement); this.popover = popover; @@ -70,8 +70,12 @@ export class Popover { } this.document.body.appendChild(popover); - this.docMouseDownHandler = event => this.onDocMouseDown(event); + + this.docMouseDownHandler = e => this.onDocMouseDown(e); this.document.addEventListener('mousedown', this.docMouseDownHandler); + + this.docKeyDownHandler = e => this.onDocKeyDown(e); + this.document.addEventListener('keydown', this.docKeyDownHandler); } showComponent(childComponent, $scope, parent) { let childElement = this.document.createElement(childComponent); @@ -81,15 +85,21 @@ export class Popover { hide() { if (!this.popover) return; this.document.removeEventListener('mousedown', this.docMouseDownHandler); + this.document.removeEventListener('keydown', this.docKeyDownHandler); this.document.body.removeChild(this.popover); this.popover = null; this.lastEvent = null; this.docMouseDownHandler = null; + this.docKeyDownHandler = null; } onDocMouseDown(event) { if (event != this.lastEvent) this.hide(); } + onDocKeyDown(event) { + if (event.keyCode === 27) + this.hide(); + } onPopoverMouseDown(event) { this.lastEvent = event; } diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index aec3bc0a8..e4b5c2305 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -54,6 +54,16 @@ export default class Watcher extends Component { () => this.window.history.back() ); } + /** + * Submits the data and goes another state. + * + * @param {String} state The state name + */ + submitGo(state) { + this.submit().then( + () => this.$state.go(state) + ); + } /** * Submits the data to the server. * @@ -91,7 +101,7 @@ export default class Watcher extends Component { if (id) { return new Promise((resolve, reject) => { - this.$http.put(`${this.url}/${id}`, changedData).then( + this.$http.patch(`${this.url}/${id}`, changedData).then( json => this.writeData(json, resolve), json => reject(json) ); diff --git a/services/auth/package.json b/services/auth/package.json index cc2ba6428..bc6233e61 100644 --- a/services/auth/package.json +++ b/services/auth/package.json @@ -1,5 +1,5 @@ { - "name": "login", + "name": "vn-auth", "version": "1.0.0", "main": "server/server.js", "scripts": { @@ -11,14 +11,14 @@ "compression": "^1.0.3", "cors": "^2.5.2", "helmet": "^1.3.0", - "loopback": "^2.22.0", - "loopback-boot": "^2.6.5", - "loopback-component-explorer": "^2.4.0", + "loopback": "^3.8.0", + "loopback-boot": "^2.24.0", + "loopback-component-explorer": "^4.2.0", "loopback-connector-mysql": "^3.0.0", - "loopback-datasource-juggler": "^2.39.0", + "loopback-context": "^3.1.0", "md5": "^2.2.1", "serve-favicon": "^2.0.1", - "strong-error-handler": "^1.0.1" + "strong-error-handler": "^2.1.0" }, "devDependencies": { "eslint": "^2.13.1", @@ -27,8 +27,8 @@ }, "repository": { "type": "git", - "url": "http://git.verdnatura.es:/salix" + "url": "https://git.verdnatura.es/salix" }, - "license": "UNLICENSED", - "description": "app" + "license": "GPL-3.0", + "description": "Authentication service" } diff --git a/services/client/common/scopes/client/activate.js b/services/client/common/methods/client/activate.js similarity index 100% rename from services/client/common/scopes/client/activate.js rename to services/client/common/methods/client/activate.js diff --git a/services/client/common/scopes/client/addresses.js b/services/client/common/methods/client/addresses.js similarity index 100% rename from services/client/common/scopes/client/addresses.js rename to services/client/common/methods/client/addresses.js diff --git a/services/client/common/scopes/client/before-save.js b/services/client/common/methods/client/before-save.js similarity index 100% rename from services/client/common/scopes/client/before-save.js rename to services/client/common/methods/client/before-save.js diff --git a/services/client/common/scopes/client/card.js b/services/client/common/methods/client/card.js similarity index 89% rename from services/client/common/scopes/client/card.js rename to services/client/common/methods/client/card.js index 74023ee31..34dd7a280 100644 --- a/services/client/common/scopes/client/card.js +++ b/services/client/common/methods/client/card.js @@ -1,7 +1,4 @@ module.exports = function(Client) { - // Validations - var card = require('./card.json'); - Client.remoteMethod('card', { description: 'Get client for card call', accepts: { @@ -27,7 +24,7 @@ module.exports = function(Client) { where: { id: id }, - include: card + include: require('./card.json') }; Client.find(filter, function(err, instances) { diff --git a/services/client/common/methods/client/card.json b/services/client/common/methods/client/card.json new file mode 100644 index 000000000..05b86ea6f --- /dev/null +++ b/services/client/common/methods/client/card.json @@ -0,0 +1,33 @@ +[ + { + "relation": "salesPerson", + "scope": { + "fields": ["id", "name"] + } + }, { + "relation": "contactChannel", + "scope": { + "fields": ["id", "name"] + } + }, { + "relation": "province", + "scope": { + "fields": ["id", "name"] + } + }, { + "relation": "country", + "scope": { + "fields": ["id", "name"] + } + }, { + "relation": "payMethod", + "scope": { + "fields": ["id", "name"] + } + }, { + "relation": "account", + "scope": { + "fields": ["id", "name", "active"] + } + } +] \ No newline at end of file diff --git a/services/client/common/scopes/client/filter.js b/services/client/common/methods/client/filter.js similarity index 95% rename from services/client/common/scopes/client/filter.js rename to services/client/common/methods/client/filter.js index d60f4c21c..8080b7057 100644 --- a/services/client/common/scopes/client/filter.js +++ b/services/client/common/methods/client/filter.js @@ -1,7 +1,8 @@ module.exports = function(Client){ Client.installMethod('filter', filterClients); + function filterClients(p) { - if(p.search && p.search !== "") + if(p.search) return searchWhere(p); return andWhere(p); } diff --git a/services/client/common/models/Client.js b/services/client/common/models/Client.js index d358d5b56..5061a5a43 100644 --- a/services/client/common/models/Client.js +++ b/services/client/common/models/Client.js @@ -5,11 +5,11 @@ module.exports = function(Client) { // Methods - require('../scopes/client/card.js')(Client); - require('../scopes/client/activate.js')(Client); - require('../scopes/client/addresses.js')(Client); - require('../scopes/client/filter.js')(Client); - require('../scopes/client/before-save.js')(Client); + require('../methods/client/card.js')(Client); + require('../methods/client/activate.js')(Client); + require('../methods/client/addresses.js')(Client); + require('../methods/client/filter.js')(Client); + require('../methods/client/before-save.js')(Client); // Validations @@ -62,7 +62,7 @@ module.exports = function(Client) { done(); }); } - +/* Client.validateAsync('credit', validateCredit, { message: 'No tienes privilegios para modificar el crédito' }); @@ -137,4 +137,5 @@ module.exports = function(Client) { done(); } } +*/ }; \ No newline at end of file diff --git a/services/client/common/scopes/client/card.json b/services/client/common/scopes/client/card.json deleted file mode 100644 index 332a0409b..000000000 --- a/services/client/common/scopes/client/card.json +++ /dev/null @@ -1,57 +0,0 @@ -[ - { - "relation": "salesPerson", - "scope": { - "fields": [ - "id", - "name" - ] - } - }, - { - "relation": "contactChannel", - "scope": { - "fields": [ - "id", - "name" - ] - } - }, - { - "relation": "province", - "scope": { - "fields": [ - "id", - "name" - ] - } - }, - { - "relation": "country", - "scope": { - "fields": [ - "id", - "name" - ] - } - }, - { - "relation": "payMethod", - "scope": { - "fields": [ - "id", - "name" - ] - } - }, - { - "relation": "account", - "scope": { - "fields": [ - "id", - "name", - "active" - ] - } - } -] \ No newline at end of file diff --git a/services/client/package.json b/services/client/package.json index 4bfb66723..bb21bcb06 100644 --- a/services/client/package.json +++ b/services/client/package.json @@ -1,5 +1,5 @@ { - "name": "client", + "name": "vn-client", "version": "1.0.0", "main": "server/server.js", "scripts": { @@ -12,14 +12,13 @@ "cors": "^2.5.2", "helmet": "^1.3.0", "i18n": "^0.8.3", - "loopback": "^2.38.3", - "loopback-boot": "^2.6.5", - "loopback-component-explorer": "^2.7.0", + "loopback": "^3.8.0", + "loopback-boot": "^2.24.0", + "loopback-component-explorer": "^4.2.0", "loopback-connector-mysql": "^3.0.0", "loopback-context": "^3.1.0", - "loopback-datasource-juggler": "^2.54.1", "serve-favicon": "^2.0.1", - "strong-error-handler": "^1.2.1" + "strong-error-handler": "^2.1.0" }, "devDependencies": { "eslint": "^2.13.1", @@ -27,9 +26,9 @@ "nsp": "^2.1.0" }, "repository": { - "type": "", - "url": "" + "type": "git", + "url": "https://git.verdnatura.es/salix" }, - "license": "UNLICENSED", - "description": "client" + "license": "GPL-3.0", + "description": "Client service" } diff --git a/services/salix/package.json b/services/salix/package.json index 2eaa676a0..d4c0099c4 100644 --- a/services/salix/package.json +++ b/services/salix/package.json @@ -1,5 +1,5 @@ { - "name": "app", + "name": "salix", "version": "1.0.0", "main": "server/server.js", "scripts": { @@ -9,15 +9,16 @@ }, "dependencies": { "compression": "^1.0.3", + "cookie-parser": "^1.4.3", "cors": "^2.5.2", "helmet": "^1.3.0", - "loopback": "^2.22.0", - "loopback-boot": "^2.6.5", - "loopback-component-explorer": "^2.4.0", - "loopback-connector-mysql": "^4.1.0", - "loopback-datasource-juggler": "^2.39.0", + "loopback": "^3.8.0", + "loopback-boot": "^2.24.0", + "loopback-component-explorer": "^4.2.0", + "loopback-connector-mysql": "^3.0.0", + "loopback-context": "^3.1.0", "serve-favicon": "^2.0.1", - "strong-error-handler": "^1.0.1" + "strong-error-handler": "^2.1.0" }, "devDependencies": { "eslint": "^2.13.1", @@ -25,9 +26,9 @@ "nsp": "^2.1.0" }, "repository": { - "type": "", - "url": "" + "type": "git", + "url": "https://git.verdnatura.es/salix" }, - "license": "UNLICENSED", - "description": "app" + "license": "GPL-3.0", + "description": "Salix application service" } diff --git a/webpack.config.js b/webpack.config.js index c4e78fced..d5166e84f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -57,7 +57,7 @@ var config = { names: ['bundle.vendor', 'bundle.manifest'] }) ], - devtool: 'source-map' + devtool: 'eval-source-map' }; if (!devMode) {