From 64eef322e9623b6fe1dda273ea9eaac238af59ac Mon Sep 17 00:00:00 2001 From: Joan Date: Tue, 3 Jul 2018 14:57:08 +0200 Subject: [PATCH 1/3] Fixed vnTable trying to apply filter an it's not defined. --- client/core/src/components/table/index.js | 2 +- client/core/src/components/table/style.scss | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/core/src/components/table/index.js b/client/core/src/components/table/index.js index 047e82278..9f78a3e96 100644 --- a/client/core/src/components/table/index.js +++ b/client/core/src/components/table/index.js @@ -25,7 +25,7 @@ export default class Table { } $onChanges() { - if (this.model) + if (this.model && this.model.filter) this.applyFilter(); } diff --git a/client/core/src/components/table/style.scss b/client/core/src/components/table/style.scss index 821a71f52..5a7be62c0 100644 --- a/client/core/src/components/table/style.scss +++ b/client/core/src/components/table/style.scss @@ -13,6 +13,7 @@ vn-table { display: table-header-group; vn-th[field] { + position: relative; cursor: pointer } @@ -84,6 +85,10 @@ vn-table { &[number]{ text-align: right; } + + vn-icon.bright, i.bright { + color: #f7931e; + } } } } From d461e8e2fab0cd951887378f45a268b7bcc40bba Mon Sep 17 00:00:00 2001 From: Joan Date: Tue, 3 Jul 2018 14:58:38 +0200 Subject: [PATCH 2/3] responsive fetched-tags --- client/ticket/src/fetched-tags/index.html | 4 ++-- client/ticket/src/fetched-tags/style.scss | 24 +++++++++-------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/client/ticket/src/fetched-tags/index.html b/client/ticket/src/fetched-tags/index.html index 4a3c679a7..dddbaf6df 100644 --- a/client/ticket/src/fetched-tags/index.html +++ b/client/ticket/src/fetched-tags/index.html @@ -1,6 +1,6 @@ - + {{::$ctrl.sale.concept}} - +
Date: Tue, 3 Jul 2018 15:00:33 +0200 Subject: [PATCH 3/3] Added saleTracking section #351. CR: Juan + Javi --- client/ticket/routes.json | 12 +++ client/ticket/src/locale/es.yml | 5 +- client/ticket/src/sale-tracking/index.html | 62 ++++++++++++ client/ticket/src/sale-tracking/index.js | 31 ++++++ client/ticket/src/ticket.js | 1 + services/loopback/common/models/sale.json | 7 +- .../methods/sale-tracking/listSaleTracking.js | 94 +++++++++++++++++++ .../specs/listSaleTracking.spec.js | 22 +++++ .../ticket/common/models/sale-tracking.js | 3 + services_tests.js | 1 + 10 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 client/ticket/src/sale-tracking/index.html create mode 100644 client/ticket/src/sale-tracking/index.js create mode 100644 services/ticket/common/methods/sale-tracking/listSaleTracking.js create mode 100644 services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js create mode 100644 services/ticket/common/models/sale-tracking.js diff --git a/client/ticket/routes.json b/client/ticket/routes.json index eb65fe367..91724fad4 100644 --- a/client/ticket/routes.json +++ b/client/ticket/routes.json @@ -195,6 +195,18 @@ "description": "Components", "icon": "icon-components" } + }, + { + "url" : "/sale-tracking", + "state": "ticket.card.saleTracking", + "component": "vn-ticket-sale-tracking", + "params": { + "ticket": "$ctrl.ticket" + }, + "menu": { + "description": "Sale tracking", + "icon": "assignment" + } } ] } \ No newline at end of file diff --git a/client/ticket/src/locale/es.yml b/client/ticket/src/locale/es.yml index cdd5897ba..065cce211 100644 --- a/client/ticket/src/locale/es.yml +++ b/client/ticket/src/locale/es.yml @@ -35,6 +35,7 @@ New : Nuevo New state: Nuevo estado Next: Siguiente Observation type: Tipo de observación +Original quantity: Cantidad original Package size: Bultos Package type: Tipo de porte Phone: Teléfono @@ -58,4 +59,6 @@ Volume: Volumen Warehouse: Almacén Worker: Trabajador VAT: IVA -Hour: Hora \ No newline at end of file +Hour: Hora +Sale tracking: Líneas preparadas +The quantity do not match: Las cantidades no coinciden \ No newline at end of file diff --git a/client/ticket/src/sale-tracking/index.html b/client/ticket/src/sale-tracking/index.html new file mode 100644 index 000000000..13b81943a --- /dev/null +++ b/client/ticket/src/sale-tracking/index.html @@ -0,0 +1,62 @@ + + + + + + Sale tracking + + + + + Item + Description + Quantity + Original quantity + Worker + State + Created + + + + + + + + + {{::sale.itemFk}} + + + {{::sale.quantity}} + {{::sale.originalQuantity}} + + {{::sale.firstName}} {{::sale.name}} + + {{::sale.state}} + {{::sale.created | date: 'dd/MM/yyyy HH:mm'}} + + + + No results + + + + + + + + + + diff --git a/client/ticket/src/sale-tracking/index.js b/client/ticket/src/sale-tracking/index.js new file mode 100644 index 000000000..b1fd653a3 --- /dev/null +++ b/client/ticket/src/sale-tracking/index.js @@ -0,0 +1,31 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $state, $http) { + this.$scope = $scope; + this.$http = $http; + this.filter = { + where: {ticketFk: $state.params.id} + }; + } + + showDescriptor(event, itemFk) { + this.$scope.descriptor.itemFk = itemFk; + this.$scope.descriptor.parent = event.target; + this.$scope.descriptor.show(); + } + + onDescriptorLoad() { + this.$scope.popover.relocate(); + } +} + +Controller.$inject = ['$scope', '$state', '$http']; + +ngModule.component('vnTicketSaleTracking', { + template: require('./index.html'), + controller: Controller, + bindings: { + ticket: '<' + } +}); diff --git a/client/ticket/src/ticket.js b/client/ticket/src/ticket.js index d07caa7cd..2632740d6 100644 --- a/client/ticket/src/ticket.js +++ b/client/ticket/src/ticket.js @@ -21,3 +21,4 @@ import './tracking/edit'; import './fetched-tags'; import './sale-checked'; import './component'; +import './sale-tracking'; diff --git a/services/loopback/common/models/sale.json b/services/loopback/common/models/sale.json index cc2569b89..562eecfc7 100644 --- a/services/loopback/common/models/sale.json +++ b/services/loopback/common/models/sale.json @@ -56,6 +56,11 @@ "type": "hasMany", "model": "SaleComponent", "foreignKey": "saleFk" - } + }, + "saleTracking": { + "type": "hasOne", + "model": "SaleTracking", + "foreignKey": "saleFk" + } } } diff --git a/services/ticket/common/methods/sale-tracking/listSaleTracking.js b/services/ticket/common/methods/sale-tracking/listSaleTracking.js new file mode 100644 index 000000000..e45249ec6 --- /dev/null +++ b/services/ticket/common/methods/sale-tracking/listSaleTracking.js @@ -0,0 +1,94 @@ +module.exports = Self => { + Self.remoteMethod('listSaleTracking', { + description: 'Returns all ticket sale trackings', + accessType: 'READ', + accepts: [{ + arg: 'filter', + type: 'Object', + required: false, + description: 'Filter defining where and paginated data', + http: {source: 'query'} + }], + returns: { + type: ["Object"], + root: true + }, + http: { + path: `/listSaleTracking`, + verb: 'get' + } + }); + + Self.listSaleTracking = async filter => { + let where = ''; + let limit = ''; + let order = ''; + let params; + + if (filter) { + let connector = Self.dataSource.connector; + if (filter.where) { + where = 'WHERE s.ticketFk = ?'; + params = [filter.where.ticketFk]; + } + + limit = connector._buildLimit(null, filter.limit, filter.skip); + order = connector.buildOrderBy('Item', filter.order); + } + + let query = `SELECT + st.id, + s.quantity, + s.concept, + s.itemFk, + st.originalQuantity, + st.created, + st.workerFk, + w.firstName, + w.name, + ste.name AS state + FROM saleTracking st + JOIN sale s ON s.id = st.saleFK + JOIN worker w ON w.id = st.workerFk + JOIN ticketState ts ON ts.ticketFk = s.ticketFk + JOIN state ste ON ste.id = ts.stateFK ${where} ${order} ${limit}`; + + let trackings = await Self.rawSql(query, params); + + let salesFilter = { + include: [ + { + relation: 'item', + scope: { + fields: ['itemFk', 'name'], + include: { + relation: 'tags', + scope: { + fields: ['tagFk', 'value'], + include: { + relation: 'tag', + scope: { + fields: ['name'] + } + }, + limit: 6 + } + } + } + } + ], + where: {ticketFk: filter.where.ticketFk} + }; + + let sales = await Self.app.models.Sale.find(salesFilter); + + trackings.forEach(tracking => { + sales.forEach(sale => { + if (tracking.itemFk == sale.itemFk) + tracking.item = sale.item(); + }); + }); + + return trackings; + }; +}; diff --git a/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js b/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js new file mode 100644 index 000000000..80ba86147 --- /dev/null +++ b/services/ticket/common/methods/sale-tracking/specs/listSaleTracking.spec.js @@ -0,0 +1,22 @@ +const app = require(`${servicesDir}/ticket/server/server`); + +describe('ticket listSaleTracking()', () => { + it('should call the listSaleTracking method and return the response', done => { + let filter = {where: {ticketFk: 1}}; + app.models.SaleTracking.listSaleTracking(filter) + .then(response => { + expect(response[0].concept).toEqual('Gem of Time'); + done(); + }); + }); + + it(`should call the listSaleTracking method and return zero if doesn't have lines`, done => { + let filter = {where: {ticketFk: 2}}; + app.models.SaleTracking.listSaleTracking(filter) + .then(response => { + expect(response.length).toEqual(0); + done(); + }); + }); +}); + diff --git a/services/ticket/common/models/sale-tracking.js b/services/ticket/common/models/sale-tracking.js new file mode 100644 index 000000000..4a46dd6b7 --- /dev/null +++ b/services/ticket/common/models/sale-tracking.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/sale-tracking/listSaleTracking')(Self); +}; diff --git a/services_tests.js b/services_tests.js index 3ab2ed8ec..c891bab91 100644 --- a/services_tests.js +++ b/services_tests.js @@ -24,6 +24,7 @@ jasmine.loadConfig({ 'auth/server/**/*[sS]pec.js', 'client/common/**/*[sS]pec.js', 'item/common/**/*[sS]pec.js', + 'ticket/common/**/*[sS]pec.js', 'loopback/common/**/*[sS]pec.js' ], helpers: [