From b68f34d3d4a02642ea74ab7e1a4e6c41f6b6838b Mon Sep 17 00:00:00 2001 From: gerard Date: Tue, 24 Jul 2018 13:48:31 +0200 Subject: [PATCH] Tarea #427 mover create order de ticket a order --- client/{ticket => order}/src/create/card.html | 2 +- client/{ticket => order}/src/create/card.js | 48 +++++------ .../{ticket => order}/src/create/index.html | 2 +- client/{ticket => order}/src/create/index.js | 5 +- .../src/create/locale/es.yml | 0 client/order/src/index.js | 2 + client/order/src/index/index.html | 5 +- client/order/src/locale/es.yml | 1 + client/ticket/routes.json | 5 -- client/ticket/src/create/card.spec.js | 79 ------------------- client/ticket/src/create/index.spec.js | 40 ---------- client/ticket/src/index/index.html | 3 - client/ticket/src/ticket.js | 2 - .../order/common/methods/{ => order}/new.js | 3 +- services/order/common/models/order.js | 2 +- 15 files changed, 38 insertions(+), 161 deletions(-) rename client/{ticket => order}/src/create/card.html (95%) rename client/{ticket => order}/src/create/card.js (56%) rename client/{ticket => order}/src/create/index.html (75%) rename client/{ticket => order}/src/create/index.js (74%) rename client/{ticket => order}/src/create/locale/es.yml (100%) delete mode 100644 client/ticket/src/create/card.spec.js delete mode 100644 client/ticket/src/create/index.spec.js rename services/order/common/methods/{ => order}/new.js (97%) diff --git a/client/ticket/src/create/card.html b/client/order/src/create/card.html similarity index 95% rename from client/ticket/src/create/card.html rename to client/order/src/create/card.html index fb1b982f2..b55bf7458 100644 --- a/client/ticket/src/create/card.html +++ b/client/order/src/create/card.html @@ -30,5 +30,5 @@ label="Agency" show-field="agency" value-field="id" - field="$ctrl.ticket.agencyModeFk"> + field="$ctrl.order.agencyModeFk"> diff --git a/client/ticket/src/create/card.js b/client/order/src/create/card.js similarity index 56% rename from client/ticket/src/create/card.js rename to client/order/src/create/card.js index 99880ab2b..195142838 100644 --- a/client/ticket/src/create/card.js +++ b/client/order/src/create/card.js @@ -1,59 +1,60 @@ import ngModule from '../module'; class Controller { - constructor($scope, $http, vnApp, $translate) { + constructor($scope, $http, vnApp, $translate, $state) { this.$scope = $scope; this.$http = $http; this.translate = $translate; this.vnApp = vnApp; - this.ticket = {}; + this.order = {}; + this.$state = $state; } - set ticket(value) { + set order(value) { if (value) { - this._ticket = value; + this._order = value; } } - get ticket() { - return this._ticket; + get order() { + return this._order; } set clientFk(value) { - this.ticket.clientFk = value; + this.order.clientFk = value; this.addressFk = null; } get clientFk() { - return this.ticket.clientFk; + return this.order.clientFk; } set addressFk(value) { - this.ticket.addressFk = value; + this.order.addressFk = value; this.getAvailableAgencies(); } get addressFk() { - return this.ticket.addressFk; + return this.order.addressFk; } set landed(value) { - this.ticket.landed = value; + this.order.landed = value; this.getAvailableAgencies(); } get landed() { - return this.ticket.landed; + return this.order.landed; } get warehouseFk() { - return this.ticket.warehouseFk; + return this.order.warehouseFk; } getAvailableAgencies() { - this.ticket.agencyModeFk = null; - if (this.ticket.landed && this.ticket.addressFk) { - let filter = {addressFk: this.ticket.addressFk, landed: this.ticket.landed}; + this.order.agencyModeFk = null; + if (this.order.landed && this.order.addressFk) { + let filter = {addressFk: this.order.addressFk, landed: this.order.landed}; filter = encodeURIComponent(JSON.stringify(filter)); let query = `/api/Agencies/landsThatDay?filter=${filter}`; this.$http.get(query).then(res => { @@ -68,26 +69,25 @@ class Controller { createOrder() { let params = { - landed: this.ticket.landed, - addressFk: this.ticket.addressFk, - agencyModeFk: this.ticket.agencyModeFk + landed: this.order.landed, + addressFk: this.order.addressFk, + agencyModeFk: this.order.agencyModeFk }; - this.$http.post(`order/api/Orders/new`, params).then(res => { this.vnApp.showSuccess(this.translate.instant('Data saved!')); - return res.data.id; + this.$state.go("order.card.summary", {id: res.data}); }).catch(e => { this.vnApp.showError(this.translate.instant(e.data.error.message)); }); } } -Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; +Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', '$state']; -ngModule.component('vnTicketCreateCard', { +ngModule.component('vnOrderCreateCard', { template: require('./card.html'), controller: Controller, bindings: { - ticket: '
- + diff --git a/client/ticket/src/create/index.js b/client/order/src/create/index.js similarity index 74% rename from client/ticket/src/create/index.js rename to client/order/src/create/index.js index 2c50c1e44..1bc1d7661 100644 --- a/client/ticket/src/create/index.js +++ b/client/order/src/create/index.js @@ -9,12 +9,13 @@ class Controller { async onSubmit() { let newOrderID = await this.$.card.createOrder(); - this.$state.go("ticket.card.summary", {id: newOrderID}); + console.log(newOrderID); + this.$state.go("order.card.summary", {id: newOrderID}); } } Controller.$inject = ['$scope', '$http', '$state']; -ngModule.component('vnTicketCreate', { +ngModule.component('vnOrderCreate', { template: require('./index.html'), controller: Controller }); diff --git a/client/ticket/src/create/locale/es.yml b/client/order/src/create/locale/es.yml similarity index 100% rename from client/ticket/src/create/locale/es.yml rename to client/order/src/create/locale/es.yml diff --git a/client/order/src/index.js b/client/order/src/index.js index a182e6392..6ef6ed1ea 100644 --- a/client/order/src/index.js +++ b/client/order/src/index.js @@ -8,3 +8,5 @@ import './summary'; import './catalogue'; import './catalogue/product'; import './volume'; +import './create'; +import './create/card'; diff --git a/client/order/src/index/index.html b/client/order/src/index/index.html index d2a58ee24..a83b7967f 100644 --- a/client/order/src/index/index.html +++ b/client/order/src/index/index.html @@ -35,9 +35,10 @@ scroll-selector="ui-view">
-