From 0c2eaa33d2930baa1206bac148057acd767d592e Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 18 Apr 2018 14:39:44 +0200 Subject: [PATCH 01/17] fix wrong command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9911d47b47..834cac070c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ $ npm install -g karma-cli gulp webpack nodemon Your user must be on the docker group to use it so you will need to run this command: ``` -$ sudo usermod -G docker yourusername +$ sudo usermod -a -G docker yourusername ``` ## Getting Started // Installing From 2d5cd04b8afa5f84bc64c0d94de90b67c40393ac Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 18 Apr 2018 14:42:11 +0200 Subject: [PATCH 02/17] fix wrong type of the id after a change iin the fixtures --- services/loopback/common/models/ink.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/loopback/common/models/ink.json b/services/loopback/common/models/ink.json index 04117aa3b7..a3cd857bfe 100644 --- a/services/loopback/common/models/ink.json +++ b/services/loopback/common/models/ink.json @@ -8,7 +8,7 @@ }, "properties": { "id": { - "type": "Number", + "type": "String", "id": true, "description": "Identifier" }, From 25d099513dda785828e2850c0ddfa6f7eeecc9d4 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 18 Apr 2018 14:42:48 +0200 Subject: [PATCH 03/17] fix wrong type of data --- services/loopback/common/models/tag.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/loopback/common/models/tag.json b/services/loopback/common/models/tag.json index b327c6588a..e35a7eddc3 100644 --- a/services/loopback/common/models/tag.json +++ b/services/loopback/common/models/tag.json @@ -18,7 +18,7 @@ "required": true }, "isFree": { - "type": "Number" + "type": "Boolean" }, "sourceTable": { "type": "String" From bb0e6dd9941624c8c6781430c9bb7b7a795fd0c5 Mon Sep 17 00:00:00 2001 From: Gerard Date: Wed, 18 Apr 2018 14:44:07 +0200 Subject: [PATCH 04/17] refactor of autocomplete --- client/core/src/components/autocomplete/autocomplete.js | 8 ++++++-- client/core/src/components/autocomplete/style.scss | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/core/src/components/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js index 986b252c82..5a52fdd895 100755 --- a/client/core/src/components/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -125,8 +125,12 @@ export default class Autocomplete extends Input { this.selection = data; else this.selection = data[0]; - } else - this.selection = null; + } else { + let selection = {}; + selection[this.showField] = this._field; + selection[this.valueField] = this._field; + this.selection = selection; + } } refreshDisplayed() { diff --git a/client/core/src/components/autocomplete/style.scss b/client/core/src/components/autocomplete/style.scss index 2dda276532..3b56675f98 100755 --- a/client/core/src/components/autocomplete/style.scss +++ b/client/core/src/components/autocomplete/style.scss @@ -5,7 +5,7 @@ vn-autocomplete > div > .mdl-textfield { & > input { cursor: pointer; - height: 26px; + height: 30px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; From 5546890ee9a5a33f960c7847990b8f164fa3f2c8 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 14:46:06 +0200 Subject: [PATCH 05/17] =?UTF-8?q?tarea=20#230=20refactorizar=20Icon-Button?= =?UTF-8?q?=20y=20a=C3=B1adir=20focus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/src/address-edit/address-edit.html | 8 ++++---- .../components/icon-button/icon-button.html | 6 +----- .../src/components/icon-button/icon-button.js | 18 ++++++++++++++++++ .../core/src/components/icon-button/style.scss | 17 +++++++++++++++++ client/item/src/barcode/barcode.html | 13 +++++++------ client/item/src/niche/niche.html | 12 +++++++----- client/ticket/src/note/ticket-observation.html | 7 ++++--- client/ticket/src/package/index/package.html | 6 +++--- 8 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 client/core/src/components/icon-button/style.scss diff --git a/client/client/src/address-edit/address-edit.html b/client/client/src/address-edit/address-edit.html index 0497570afb..c1b9cb20d3 100644 --- a/client/client/src/address-edit/address-edit.html +++ b/client/client/src/address-edit/address-edit.html @@ -41,7 +41,7 @@ @@ -61,6 +61,7 @@ - - + diff --git a/client/core/src/components/icon-button/icon-button.html b/client/core/src/components/icon-button/icon-button.html index fdd0227108..4bd8ad78ac 100644 --- a/client/core/src/components/icon-button/icon-button.html +++ b/client/core/src/components/icon-button/icon-button.html @@ -1,5 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/client/core/src/components/icon-button/icon-button.js b/client/core/src/components/icon-button/icon-button.js index c257b9da9e..5765fb2493 100644 --- a/client/core/src/components/icon-button/icon-button.js +++ b/client/core/src/components/icon-button/icon-button.js @@ -1,6 +1,24 @@ import ngModule from '../../module'; +import './style.scss'; +export default class IconButton { + constructor($element) { + $element[0].tabIndex = 0; + $element.on("keyup", event => this.onKeyDown(event, $element)); + } + + onKeyDown(event, $element) { + if (event.defaultPrevented) return; + if (event.keyCode == 13) { + event.preventDefault(); + $element.triggerHandler('click'); + } + } +} + +IconButton.$inject = ['$element']; ngModule.component('vnIconButton', { + controller: IconButton, template: require('./icon-button.html'), bindings: { icon: '@', diff --git a/client/core/src/components/icon-button/style.scss b/client/core/src/components/icon-button/style.scss new file mode 100644 index 0000000000..7754c871a1 --- /dev/null +++ b/client/core/src/components/icon-button/style.scss @@ -0,0 +1,17 @@ +vn-icon-button { + display: inline-block; + text-align: center; + color: rgba(#f7931e, 0.7); + transition: color 200ms ease-in-out; + cursor: pointer; + + & > i, + & > i.material-icons { + display: block; + font-size: inherit; + color: inherit; + } + &:hover { + color: #f7931e; + } +} diff --git a/client/item/src/barcode/barcode.html b/client/item/src/barcode/barcode.html index 6a77eacd03..f741c96f6f 100644 --- a/client/item/src/barcode/barcode.html +++ b/client/item/src/barcode/barcode.html @@ -6,26 +6,27 @@ vn-three label="Code" model="barcode.code" - vn-acl="buyer, replenisher"> + vn-acl="buyer, replenisher" + vn-focus> - - + diff --git a/client/item/src/niche/niche.html b/client/item/src/niche/niche.html index 0d296a30ff..8c4b4b5eed 100644 --- a/client/item/src/niche/niche.html +++ b/client/item/src/niche/niche.html @@ -10,6 +10,7 @@ - - + diff --git a/client/ticket/src/note/ticket-observation.html b/client/ticket/src/note/ticket-observation.html index 7ca2567602..5c683ba092 100644 --- a/client/ticket/src/note/ticket-observation.html +++ b/client/ticket/src/note/ticket-observation.html @@ -14,6 +14,7 @@ - - + diff --git a/client/ticket/src/package/index/package.html b/client/ticket/src/package/index/package.html index d1838924eb..3f3130f623 100644 --- a/client/ticket/src/package/index/package.html +++ b/client/ticket/src/package/index/package.html @@ -16,6 +16,7 @@ - - + From 4455f77f8e654b46e801a2988c7866fbf05b9e31 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 14:48:38 +0200 Subject: [PATCH 06/17] #230 refactor de tabIndex debido al refactor de icon-button --- client/core/src/components/textfield/textfield.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/core/src/components/textfield/textfield.js b/client/core/src/components/textfield/textfield.js index feb5b98a97..56fc239553 100644 --- a/client/core/src/components/textfield/textfield.js +++ b/client/core/src/components/textfield/textfield.js @@ -24,9 +24,11 @@ export default class Textfield extends Input { this.hasValue = Boolean(this._value); this.mdlUpdate(); } - set tabIndex(value) { - this.input.tabIndex = value; + + set vnTabIndex(value) { + this.input.tabindex = value; } + clear() { this.value = null; this.input.focus(); @@ -49,6 +51,6 @@ ngModule.component('vnTextfield', { readonly: ' Date: Thu, 19 Apr 2018 14:51:21 +0200 Subject: [PATCH 07/17] merge --- .../client/specs/getAverageInvoiced.spec.js | 12 +----- .../methods/client/specs/getMana.spec.js | 12 +----- .../methods/ticket/specs/get-taxes.spec.js | 12 +----- .../methods/ticket/specs/get-total.spec.js | 14 ++----- .../methods/ticket/specs/get-volume.spec.js | 12 +----- .../methods/ticket/specs/summary.spec.js | 30 +++++--------- .../loopback/common/test-helpers/loopback.js | 39 ------------------- services_tests.js | 1 + 8 files changed, 22 insertions(+), 110 deletions(-) delete mode 100644 services/loopback/common/test-helpers/loopback.js diff --git a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js index 9d076c9f00..8bd2d9baa8 100644 --- a/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js +++ b/services/loopback/common/methods/client/specs/getAverageInvoiced.spec.js @@ -1,16 +1,8 @@ -const getAverageInvoiced = require('../getAverageInvoiced'); -const model = { - remoteMethod: () => {} -}; -let Loopback = require('../../../test-helpers/loopback'); -Loopback.init(model); - -Loopback.rawSql(model); -getAverageInvoiced(model); +const app = require(`${servicesDir}/client/server/server`); describe('client getAverageInvoiced()', () => { it('should call the getAverageInvoiced method', done => { - model.getAverageInvoiced(101) + app.models.Client.getAverageInvoiced(101) .then(response => { expect(response.invoiced).toEqual(1500); done(); diff --git a/services/loopback/common/methods/client/specs/getMana.spec.js b/services/loopback/common/methods/client/specs/getMana.spec.js index 31e7ce2319..f4e317bf3c 100644 --- a/services/loopback/common/methods/client/specs/getMana.spec.js +++ b/services/loopback/common/methods/client/specs/getMana.spec.js @@ -1,16 +1,8 @@ -const getMana = require('../getMana'); -const model = { - remoteMethod: () => {} -}; -let Loopback = require('../../../test-helpers/loopback'); -Loopback.init(model); - -Loopback.rawSql(model); -getMana(model); +const app = require(`${servicesDir}/client/server/server`); describe('client getMana()', () => { it('should call the getMana method', done => { - model.getMana(101) + app.models.Client.getMana(101) .then(response => { expect(response.mana).toEqual(30.02); done(); diff --git a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js b/services/loopback/common/methods/ticket/specs/get-taxes.spec.js index 179b8907c1..087c8ce10c 100644 --- a/services/loopback/common/methods/ticket/specs/get-taxes.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-taxes.spec.js @@ -1,16 +1,8 @@ -const getTaxes = require('../get-taxes'); -const model = { - remoteMethod: () => {} -}; -let Loopback = require('../../../test-helpers/loopback'); -Loopback.init(model); - -Loopback.rawSql(model); -getTaxes(model); +const app = require(`${servicesDir}/ticket/server/server`); describe('ticket getTaxes()', () => { it('should call the getTaxes method', done => { - model.getTaxes(1) + app.models.Ticket.getTaxes(1) .then(response => { expect(response[0].tax).toEqual(1.05); done(); diff --git a/services/loopback/common/methods/ticket/specs/get-total.spec.js b/services/loopback/common/methods/ticket/specs/get-total.spec.js index a422341947..0a9d74e840 100644 --- a/services/loopback/common/methods/ticket/specs/get-total.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-total.spec.js @@ -1,16 +1,8 @@ -const getTotal = require('../get-total'); -const model = { - remoteMethod: () => {} -}; -let Loopback = require('../../../test-helpers/loopback'); -Loopback.init(model); - -Loopback.rawSql(model); -getTotal(model); +const app = require(`${servicesDir}/ticket/server/server`); describe('ticket getTotal()', () => { it('should call the getTotal method and return the response', done => { - model.getTotal(1) + app.models.Ticket.getTotal(1) .then(response => { expect(response).toEqual(11.55); done(); @@ -18,7 +10,7 @@ describe('ticket getTotal()', () => { }); it(`should call the getTotal method and return zero if doesn't have lines`, done => { - model.getTotal(13) + app.models.Ticket.getTotal(13) .then(response => { expect(response).toEqual(0); done(); diff --git a/services/loopback/common/methods/ticket/specs/get-volume.spec.js b/services/loopback/common/methods/ticket/specs/get-volume.spec.js index 99e1d4a638..dbe97684d8 100644 --- a/services/loopback/common/methods/ticket/specs/get-volume.spec.js +++ b/services/loopback/common/methods/ticket/specs/get-volume.spec.js @@ -1,17 +1,9 @@ -const getVolume = require('../get-volume'); -const model = { - remoteMethod: () => {} -}; -let Loopback = require('../../../test-helpers/loopback'); -Loopback.init(model); - -Loopback.rawSql(model); -getVolume(model); +const app = require(`${servicesDir}/ticket/server/server`); describe('ticket getVolume()', () => { it('should call the getVolume method', done => { let ticketFk = 1; - model.getVolume(ticketFk) + app.models.Ticket.getVolume(ticketFk) .then(response => { expect(response[0][0].m3_total).toEqual(0.008); done(); diff --git a/services/loopback/common/methods/ticket/specs/summary.spec.js b/services/loopback/common/methods/ticket/specs/summary.spec.js index 5b1c3f3981..5072c7c37d 100644 --- a/services/loopback/common/methods/ticket/specs/summary.spec.js +++ b/services/loopback/common/methods/ticket/specs/summary.spec.js @@ -1,22 +1,12 @@ -/* let Jasmine = require('jasmine'); -const {getTicketData} = require('../summary'); +// const app = require(`${servicesDir}/ticket/server/server`); -const summary = require('../summary'); -const model = { - remoteMethod: () => {} -}; +// fdescribe('ticket summary()', () => { +// describe('getTicketData()', () => { +// it('should sum all sales price', done => { +// let result = getTicketData(model, 1); -summary(model); - -fdescribe('ticket summary()', () => { - describe('getTicketData()', () => { - it('should sum all sales price', done => { - let result = getTicketData(model, 1); - - expect(result).toEqual("pepinillos"); - done(); - }); - }); -}); - - */ \ No newline at end of file +// expect(result).toEqual("pepinillos"); +// done(); +// }); +// }); +// }); diff --git a/services/loopback/common/test-helpers/loopback.js b/services/loopback/common/test-helpers/loopback.js deleted file mode 100644 index c6a11cb6dd..0000000000 --- a/services/loopback/common/test-helpers/loopback.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - importLoopbackModules: function() { - this.rawSqlModule = require('../methods/vnModel/rawSql.js'); - this.findOneModule = require('../methods/vnModel/rawSql.js'); - }, - - /** - * Initializes DataSource once - * @param {Object} Self - Model - */ - init: function(Self) { - if (!this.dataSource) - this.connect(); - - Self.dataSource = this.dataSource; - - this.importLoopbackModules(); - }, - - /** - * Instantiate Loopback DataSource - */ - connect: function() { - let DataSource = require('loopback-datasource-juggler').DataSource; - let dataSourceConfig = { - connector: 'mysql', - host: 'localhost', - user: 'root', - password: 'root', - database: 'salix' - }; - - this.dataSource = new DataSource(dataSourceConfig); - }, - - rawSql: function(Self) { - this.rawSqlModule(Self); - } -}; diff --git a/services_tests.js b/services_tests.js index cbd7e7f81b..3ab2ed8ec6 100644 --- a/services_tests.js +++ b/services_tests.js @@ -9,6 +9,7 @@ var verbose = false; if (process.argv[2] === '--v') { verbose = true; } +servicesDir = `${__dirname}/services`; var Jasmine = require('jasmine'); var jasmine = new Jasmine(); From 592b34a87928346c9ddb18fcc6b162927d2c7c3b Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 14:56:05 +0200 Subject: [PATCH 08/17] Bug #243 Indice de Tickets --- client/ticket/src/list/ticket-list.html | 66 ++++++++++++++++--- client/ticket/src/list/ticket-list.js | 25 +++++-- client/ticket/src/list/ticket-list.spec.js | 48 ++++++++++++++ .../loopback/common/methods/ticket/filter.js | 48 +++++++++++++- 4 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 client/ticket/src/list/ticket-list.spec.js diff --git a/client/ticket/src/list/ticket-list.html b/client/ticket/src/list/ticket-list.html index f06ef58cac..ca5e9eca14 100644 --- a/client/ticket/src/list/ticket-list.html +++ b/client/ticket/src/list/ticket-list.html @@ -1,20 +1,66 @@ -
-
- - +
+
+ + TICKETS + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID TicketComercialDateHoraAliasProvinciaEstadoAgenciaAlmacenFacturaRuta
+ + {{::ticket.id}}{{::ticket.client.salesPerson.name | dashIfEmpty}}{{::ticket.shipped | date:'dd/MM/yyyy'}}{{::ticket.shipped | date:'HH:MM'}}{{::ticket.nickname}}{{::ticket.address.province.name}}{{::ticket.ticketTracking.state.name}}{{::ticket.agencyMode.name}}{{::ticket.warehouse.name}}{{::ticket.refFk | dashIfEmpty}}{{::ticket.routeFk | dashIfEmpty}} + + +
+
diff --git a/client/ticket/src/list/ticket-list.js b/client/ticket/src/list/ticket-list.js index 569a135e0e..ee48e2c73e 100644 --- a/client/ticket/src/list/ticket-list.js +++ b/client/ticket/src/list/ticket-list.js @@ -8,13 +8,30 @@ export default class Controller { this.ticketSelected = null; } - search(index) { - index.accept(); + compareDate(date) { + let today = new Date(); + today.setHours(0, 0, 0, 0); + let timeTicket = new Date(date); + timeTicket.setHours(0, 0, 0, 0); + + let comparation = today - timeTicket; + + if (comparation == 0) + return 'warning'; + + if (comparation < 0) + return 'success'; } - openSummary(ticket) { - this.ticketSelected = ticket; + preview(event, ticket) { + event.preventDefault(); + event.stopImmediatePropagation(); this.$scope.dialogSummaryTicket.show(); + this.ticketSelected = ticket; + } + + search(index) { + index.accept(); } } diff --git a/client/ticket/src/list/ticket-list.spec.js b/client/ticket/src/list/ticket-list.spec.js new file mode 100644 index 0000000000..6a50756a27 --- /dev/null +++ b/client/ticket/src/list/ticket-list.spec.js @@ -0,0 +1,48 @@ +import './ticket-list.js'; + +describe('ticket', () => { + describe('Component vnTicketList', () => { + let $componentController; + let controller; + + beforeEach(() => { + angular.mock.module('ticket'); + }); + + beforeEach(angular.mock.inject(_$componentController_ => { + $componentController = _$componentController_; + controller = $componentController('vnTicketList'); + })); + + describe('compareDate()', () => { + it('should return warning when the date is the present', () => { + let date = new Date(); + let result = controller.compareDate(date); + + expect(result).toEqual('warning'); + }); + + it('should return warning when the date is in the future', () => { + let date = '2518-05-19T00:00:00.000Z'; + let result = controller.compareDate(date); + + expect(result).toEqual('success'); + }); + }); + + describe('preview()', () => { + it('should call preventDefault and stopImmediatePropagation from event and show', () => { + let event = jasmine.createSpyObj('event', ['preventDefault', 'stopImmediatePropagation']); + + controller.$scope = {dialogSummaryTicket: {show: () => {}}}; + spyOn(controller.$scope.dialogSummaryTicket, 'show'); + let ticket = {}; + controller.preview(event, ticket); + + expect(event.preventDefault).toHaveBeenCalledWith(); + expect(event.stopImmediatePropagation).toHaveBeenCalledWith(); + expect(controller.$scope.dialogSummaryTicket.show).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/services/loopback/common/methods/ticket/filter.js b/services/loopback/common/methods/ticket/filter.js index 8550d579ad..5bada154f1 100644 --- a/services/loopback/common/methods/ticket/filter.js +++ b/services/loopback/common/methods/ticket/filter.js @@ -6,7 +6,53 @@ module.exports = Self => { where: {}, skip: (params.page - 1) * params.size, limit: params.size, - order: params.order || 'created DESC' + order: params.order || 'created DESC', + include: [ + { + relation: 'address', + scope: { + fields: ['provinceFk'], + include: { + relation: 'province', + scope: { + fields: ['name'] + } + } + } + }, { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, { + relation: 'ticketTracking', + scope: { + fields: ['stateFk'], + include: { + relation: 'state', + scope: { + fields: ['name'] + } + } + } + }, { + relation: 'client', + scope: { + fields: ['salesPersonFk'], + include: { + relation: 'salesPerson', + scope: { + fields: ['name'] + } + } + } + } + ] }; delete params.page; From 399f14a5b55051681cc6f64033505faeb155e52b Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 14:57:55 +0200 Subject: [PATCH 09/17] Tarea #230 cambio en vnIndex --- client/core/src/components/textfield/textfield.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/core/src/components/textfield/textfield.html b/client/core/src/components/textfield/textfield.html index 57837cf09e..97501ae8ab 100644 --- a/client/core/src/components/textfield/textfield.html +++ b/client/core/src/components/textfield/textfield.html @@ -11,7 +11,8 @@ ng-disabled="$ctrl.disabled" ng-readonly="$ctrl.readonly" ng-focus="$ctrl.hasFocus = true" - ng-blur="$ctrl.hasFocus = false"/> + ng-blur="$ctrl.hasFocus = false" + tabindex="{{$ctrl.input.tabindex}}"/>
Date: Thu, 19 Apr 2018 14:58:43 +0200 Subject: [PATCH 10/17] Tarea #230 refactor de vnseachbar debido al refactor de vnIconButton --- client/salix/src/components/searchbar/searchbar.html | 11 +++++++---- client/salix/src/components/searchbar/searchbar.js | 2 +- client/salix/src/components/searchbar/style.scss | 9 +++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 client/salix/src/components/searchbar/style.scss diff --git a/client/salix/src/components/searchbar/searchbar.html b/client/salix/src/components/searchbar/searchbar.html index 9e21968bc9..72d5dad90d 100644 --- a/client/salix/src/components/searchbar/searchbar.html +++ b/client/salix/src/components/searchbar/searchbar.html @@ -1,18 +1,21 @@
+ + + style="cursor: pointer; color: #aaa"> - -
- + \ No newline at end of file diff --git a/client/salix/src/components/searchbar/searchbar.js b/client/salix/src/components/searchbar/searchbar.js index 81e71198cf..6ff9a80727 100644 --- a/client/salix/src/components/searchbar/searchbar.js +++ b/client/salix/src/components/searchbar/searchbar.js @@ -1,4 +1,5 @@ import ngModule from '../../module'; +import './style.scss'; export default class Controller { constructor($element, $scope, $compile, $timeout, $state, $transitions) { @@ -152,7 +153,6 @@ ngModule.component('vnSearchbar', { onSearch: '&', advanced: '=', popover: '@', - label: '@?', ignoreKeys: ' form > vn-horizontal > vn-icon-button { + color: black; + } +} \ No newline at end of file From c6514280637b9e842aead04669d2ad05819c7276 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:00:44 +0200 Subject: [PATCH 11/17] Bug #243 Creacion del filtro dash-if-empty para ticket Index --- client/core/src/filters/dash-if-empty.js | 15 +++++++++++++++ client/core/src/filters/index.js | 1 + 2 files changed, 16 insertions(+) create mode 100644 client/core/src/filters/dash-if-empty.js diff --git a/client/core/src/filters/dash-if-empty.js b/client/core/src/filters/dash-if-empty.js new file mode 100644 index 0000000000..704ec28475 --- /dev/null +++ b/client/core/src/filters/dash-if-empty.js @@ -0,0 +1,15 @@ +import ngModule from '../module'; + +/** + * Returns dash when value is empty, otherwise returns the same string. + * + * @return {String} The string result + */ +export default function dashIfEmpty() { + return function(input) { + if (input == null || input == '') + return '-'; + return input; + }; +} +ngModule.filter('dashIfEmpty', dashIfEmpty); diff --git a/client/core/src/filters/index.js b/client/core/src/filters/index.js index 885f3cd666..65d3a996b0 100644 --- a/client/core/src/filters/index.js +++ b/client/core/src/filters/index.js @@ -1,2 +1,3 @@ import './phone'; import './ucwords'; +import './dash-if-empty'; From 85a5d986b96f04227f71ce88eeb7e3ae6836b3c6 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:02:06 +0200 Subject: [PATCH 12/17] Selectores modificados para icon-button --- e2e/helpers/selectors.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 44f145bb72..440090d411 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -17,7 +17,7 @@ export default { }, clientsIndex: { searchClientInput: `${components.vnTextfield}`, - searchButton: `${components.vnSearchBar} > vn-icon-button > button`, + searchButton: `${components.vnSearchBar} > vn-icon-button`, searchResult: `vn-item-client a`, createClientButton: `${components.vnFloatButton}` }, @@ -157,7 +157,7 @@ export default { searchResultCloneButton: `vn-item-product .buttons > [icon="icon-clone"]`, acceptClonationAlertButton: `vn-item-list [vn-id="clone"] [response="ACCEPT"]`, searchItemInput: `${components.vnTextfield}`, - searchButton: `${components.vnSearchBar} > vn-icon-button > button`, + searchButton: `${components.vnSearchBar} > vn-icon-button`, closeItemSummaryPreview: 'vn-item-list [vn-id="preview"] button.close' }, itemCreateView: { @@ -191,27 +191,27 @@ export default { tagsButton: `${components.vnMenuItem}[ui-sref="item.card.tags"]`, firstRemoveTagButton: `vn-item-tags vn-horizontal:nth-child(2) > ${components.vnIcon}[icon="remove_circle_outline"]`, firstTagSelect: `vn-item-tags vn-horizontal:nth-child(2) > ${components.vnAutocomplete}[field="itemTag.tagFk"] input`, - firstTagDisabled: `vn-item-tags vn-horizontal:nth-child(2) > vn-textfield[label="Tag"] > div > input`, + firstTagDisabled: `vn-item-tags vn-horizontal:nth-child(2) > vn-autocomplete > div > div > input`, firstTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(2) > ${components.vnAutocomplete}[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`, firstValueInput: `vn-item-tags vn-horizontal:nth-child(2) > vn-textfield[label="Value"] > div > input`, firstRelevancyInput: `vn-horizontal:nth-child(2) > vn-textfield[label="Relevancy"] > div > input`, secondTagSelect: `vn-item-tags vn-horizontal:nth-child(3) > ${components.vnAutocomplete}[field="itemTag.tagFk"] input`, - secondTagDisabled: `vn-item-tags vn-horizontal:nth-child(3) > vn-textfield[label="Tag"] > div > input`, + secondTagDisabled: `vn-item-tags vn-horizontal:nth-child(3) > vn-autocomplete > div > div > input`, secondTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(3) > ${components.vnAutocomplete}[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`, secondValueInput: `vn-item-tags vn-horizontal:nth-child(3) > vn-textfield[label="Value"] > div > input`, secondRelevancyInput: `vn-horizontal:nth-child(3) > vn-textfield[label="Relevancy"] > div > input`, thirdTagSelect: `vn-item-tags vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemTag.tagFk"] input`, - thirdTagDisabled: `vn-item-tags vn-horizontal:nth-child(4) > vn-textfield[label="Tag"] > div > input`, + thirdTagDisabled: `vn-item-tags vn-horizontal:nth-child(4) > vn-autocomplete > div > div > input`, thirdTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(4) > ${components.vnAutocomplete}[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`, thirdValueInput: `vn-item-tags vn-horizontal:nth-child(4) > vn-textfield[label="Value"] > div > input`, thirdRelevancyInput: `vn-horizontal:nth-child(4) > vn-textfield[label="Relevancy"] > div > input`, fourthTagSelect: `vn-item-tags vn-horizontal:nth-child(5) > ${components.vnAutocomplete}[field="itemTag.tagFk"] input`, - fourthTagDisabled: `vn-item-tags vn-horizontal:nth-child(5) > vn-textfield[label="Tag"] > div > input`, + fourthTagDisabled: `vn-item-tags vn-horizontal:nth-child(5) > vn-autocomplete > div > div > input`, fourthTagSelectOptionOne: `vn-item-tags vn-horizontal:nth-child(5) > ${components.vnAutocomplete}[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(1)`, fourthValueInput: `vn-item-tags vn-horizontal:nth-child(5) > vn-textfield[label="Value"] > div > input`, fourthRelevancyInput: `vn-horizontal:nth-child(5) > vn-textfield[label="Relevancy"] > div > input`, fifthTagSelect: `vn-item-tags vn-horizontal:nth-child(6) > ${components.vnAutocomplete}[field="itemTag.tagFk"] input`, - fifthTagDisabled: `vn-item-tags vn-horizontal:nth-child(6) > vn-textfield[label="Tag"] > div > input`, + fifthTagDisabled: `vn-item-tags vn-horizontal:nth-child(6) > vn-autocomplete > div > div > input`, fifthTagSelectOptionFive: `vn-item-tags vn-horizontal:nth-child(6) > ${components.vnAutocomplete}[field="itemTag.tagFk"] vn-drop-down ul > li:nth-child(5)`, fifthValueInput: `vn-item-tags vn-horizontal:nth-child(6) > vn-textfield[label="Value"] > div > input`, fifthRelevancyInput: `vn-horizontal:nth-child(6) > vn-textfield[label="Relevancy"] > div > input`, @@ -264,18 +264,18 @@ export default { submitBotanicalButton: `${components.vnSubmit}` }, itemSummary: { - basicData: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(2) > vn-vertical`, - vat: `${components.vnItemSummary} > vn-horizontal:nth-child(1) > vn-one:nth-child(3) > vn-vertical > p`, - tags: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(1) > vn-vertical:nth-child(1) > vn-label-value:nth-child(2)`, - niche: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(2) > vn-vertical > vn-label-value:nth-child(2)`, - botanical: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(3) > vn-vertical > vn-label-value:nth-child(2)`, - barcode: `${components.vnItemSummary} > vn-horizontal:nth-child(2) > vn-one:nth-child(4) > vn-vertical > p` + basicData: `${components.vnItemSummary} vn-vertical[name="basicData"]`, + vat: `${components.vnItemSummary} vn-vertical[name="tax"]`, + tags: `${components.vnItemSummary} vn-vertical[name="tags"]`, + niche: `${components.vnItemSummary} vn-vertical[name="niche"]`, + botanical: `${components.vnItemSummary} vn-vertical[name="botanical"]`, + barcode: `${components.vnItemSummary} vn-vertical[name="barcode"]` }, ticketsIndex: { createTicketButton: `${components.vnFloatButton}`, - searchResult: `vn-ticket-item a`, + searchResult: `table > tbody > tr`, searchTicketInput: `${components.vnTextfield}`, - searchButton: `${components.vnSearchBar} > vn-icon-button > button` + searchButton: `${components.vnSearchBar} > vn-icon-button` }, ticketNotes: { notesButton: `${components.vnMenuItem}[ui-sref="ticket.card.observation"]`, From 1e15826f8d4f94b6147ac0272d955053376889d7 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:12:39 +0200 Subject: [PATCH 13/17] Bug #211 Forzar a ciertos tags --- .../src/components/drop-down/drop-down.js | 2 +- client/core/src/components/drop-down/model.js | 11 ++++ .../src/components/drop-down/model.spec.js | 34 +++++++++++ client/item/src/tags/tags.html | 56 +++++++++++-------- client/item/src/tags/tags.js | 28 ++++++++-- client/item/src/tags/tags.spec.js | 39 +++++++++++++ .../common/methods/item-tag/filterItemTags.js | 26 +++++++++ .../item-tag/specs/filterItemTags.spec.js | 9 +++ services/loopback/common/models/item-tag.js | 1 + 9 files changed, 175 insertions(+), 31 deletions(-) create mode 100644 client/core/src/components/drop-down/model.spec.js create mode 100644 services/loopback/common/methods/item-tag/filterItemTags.js create mode 100644 services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js diff --git a/client/core/src/components/drop-down/drop-down.js b/client/core/src/components/drop-down/drop-down.js index 07a8562731..bfe372b7da 100755 --- a/client/core/src/components/drop-down/drop-down.js +++ b/client/core/src/components/drop-down/drop-down.js @@ -40,7 +40,7 @@ export default class DropDown extends Component { set search(value) { value = value == '' || value == null ? null : value; - if (value === this._search) return; + if (value === this._search && this.$.model.data != null) return; this._search = value; this.$.model.clear(); diff --git a/client/core/src/components/drop-down/model.js b/client/core/src/components/drop-down/model.js index 12888563c1..b8237bad76 100644 --- a/client/core/src/components/drop-down/model.js +++ b/client/core/src/components/drop-down/model.js @@ -13,6 +13,17 @@ export default class Model { return this.canceler != null; } + set url(url) { + if (this._url != url) { + this._url = url; + this.clear(); + } + } + + get url() { + return this._url; + } + loadMore() { if (this.moreRows) { let filter = Object.assign({}, this.myFilter); diff --git a/client/core/src/components/drop-down/model.spec.js b/client/core/src/components/drop-down/model.spec.js new file mode 100644 index 0000000000..5aff7554f1 --- /dev/null +++ b/client/core/src/components/drop-down/model.spec.js @@ -0,0 +1,34 @@ +import './model.js'; + +describe('Component vnModel', () => { + let $componentController; + let $httpBackend; + let controller; + + beforeEach(() => { + angular.mock.module('client'); + }); + + beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => { + $componentController = _$componentController_; + controller = $componentController('vnModel', {$httpBackend}); + })); + + describe('set url', () => { + it(`should call clear function when the controller _url is undefined`, () => { + spyOn(controller, 'clear'); + controller.url = 'localhost'; + + expect(controller._url).toEqual('localhost'); + expect(controller.clear).toHaveBeenCalledWith(); + }); + + it(`should do nothing when the url is matching`, () => { + controller._url = 'localhost'; + spyOn(controller, 'clear'); + controller.url = 'localhost'; + + expect(controller.clear).not.toHaveBeenCalledWith(); + }); + }); +}); diff --git a/client/item/src/tags/tags.html b/client/item/src/tags/tags.html index c92a13292f..bf71966fef 100644 --- a/client/item/src/tags/tags.html +++ b/client/item/src/tags/tags.html @@ -6,32 +6,41 @@
Item tags - + + on-change="$ctrl.checkAutocompleteChanges(itemTag)" + vn-acl="buyer" + vn-focus + disabled="itemTag.id != null"> - - + + - + ng-click="$ctrl.removeItemTag($index)"> - - - + + + + diff --git a/client/item/src/tags/tags.js b/client/item/src/tags/tags.js index 005446f751..1dad06d82a 100644 --- a/client/item/src/tags/tags.js +++ b/client/item/src/tags/tags.js @@ -20,10 +20,9 @@ class ItemTags { return true; }); this.instancedItemTags[this.instancedItemTags.length - 1].showAddIcon = true; - } else { - this.addItemTag(); } } + _setDirtyForm() { if (this.$scope.form) { this.$scope.form.$setDirty(); @@ -35,9 +34,13 @@ class ItemTags { } } + checkAutocompleteChanges(itemTag) { + itemTag.value = null; + } + addItemTag() { if (this.instancedItemTags) { - this.instancedItemTags.push({value: null, itemFk: this.params.id, tagFk: null, priority: this.getMaxPriority(this.instancedItemTags) + 1, showAddIcon: true}); + this.instancedItemTags.push({value: null, itemFk: this.params.id, tagFk: null, priority: this.getHighestPriority(this.instancedItemTags), showAddIcon: true}); this._setIconAdd(); } } @@ -54,13 +57,25 @@ class ItemTags { } } - getMaxPriority(instancedItemTags) { + getHighestPriority(instancedItemTags) { let max = 0; instancedItemTags.forEach(tag => { if (tag.priority > max) max = tag.priority; }); - return max; + return max + 1; + } + + getSourceTable(selection) { + if (!selection || selection.isFree === true) + return null; + + if (selection.sourceTable) { + return "/api/" + selection.sourceTable.charAt(0).toUpperCase() + + selection.sourceTable.substring(1) + 's'; + } else if (selection.sourceTable == null) { + return `/api/ItemTags/filterItemTags/${selection.id}`; + } } _equalItemTags(oldTag, newTag) { @@ -147,6 +162,7 @@ ngModule.component('vnItemTags', { template: require('./tags.html'), controller: ItemTags, bindings: { - itemTags: '=' + itemTags: '=', + selection: ' { }); }); + describe('getHighestPriority', () => { + it('should return the highest priority value + 1 from the array', () => { + let tags = [{priority: 1}, {priority: 2}, {priority: 1}]; + let result = controller.getHighestPriority(tags); + + expect(result).toEqual(3); + }); + + it('should return 1 when there is no priority defined', () => { + let tags = []; + let result = controller.getHighestPriority(tags); + + expect(result).toEqual(1); + }); + }); + + describe('getSourceTable', () => { + it('should return null when the property isFree equals true', () => { + let selection = {isFree: true}; + let result = controller.getSourceTable(selection); + + expect(result).toBe(null); + }); + + it('should return the route of the model in loopback with the first char of the string uppercase and adding a s', () => { + let selection = {sourceTable: "ink"}; + let result = controller.getSourceTable(selection); + + expect(result).toBe("/api/Inks"); + }); + + it('should return the route filteritemtags with the id of the selection', () => { + let selection = {id: 3, sourceTable: null, isFree: false}; + let result = controller.getSourceTable(selection); + + expect(result).toBe("/api/ItemTags/filterItemTags/3"); + }); + }); + describe('_equalItemTags()', () => { it('should return true if two tags are equals independent of control attributes', () => { let tag1 = {id: 1, typeFk: 1, value: '1111', showAddIcon: true}; diff --git a/services/loopback/common/methods/item-tag/filterItemTags.js b/services/loopback/common/methods/item-tag/filterItemTags.js new file mode 100644 index 0000000000..8e6b3665f4 --- /dev/null +++ b/services/loopback/common/methods/item-tag/filterItemTags.js @@ -0,0 +1,26 @@ +module.exports = Self => { + Self.remoteMethod('filterItemTags', { + description: 'Returns the distinct values of a tag property', + accessType: 'READ', + accepts: [{ + arg: 'tagFk', + type: 'number', + required: true, + description: 'The foreign key from tag table', + http: {source: 'path'} + }], + returns: { + root: true, + type: ['object'] + }, + http: { + path: `/filterItemTags/:tagFk`, + verb: 'get' + } + }); + + Self.filterItemTags = async tagFk => { + let query = `SELECT DISTINCT(value) AS name FROM vn.itemTag WHERE tagFk = ?`; + return await Self.rawSql(query, [tagFk]); + }; +}; diff --git a/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js b/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js new file mode 100644 index 0000000000..3ca35ece13 --- /dev/null +++ b/services/loopback/common/methods/item-tag/specs/filterItemTags.spec.js @@ -0,0 +1,9 @@ +const app = require(`${servicesDir}/item/server/server`); + +describe('item filterItemTags()', () => { + it('should call the filterItemTags method', async() => { + let [result] = await app.models.ItemTag.filterItemTags(1); + + expect(result.name).toEqual('Yellow'); + }); +}); diff --git a/services/loopback/common/models/item-tag.js b/services/loopback/common/models/item-tag.js index 4115288364..be9c3203aa 100644 --- a/services/loopback/common/models/item-tag.js +++ b/services/loopback/common/models/item-tag.js @@ -1,3 +1,4 @@ module.exports = function(Self) { require('../methods/item-tag/crudItemTags.js')(Self); + require('../methods/item-tag/filterItemTags.js')(Self); }; From fb6a8c72f0a2354435bd85ecd8f0a2c0621c6b90 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:13:45 +0200 Subject: [PATCH 14/17] quitada traduccion innecesaria --- client/client/src/fiscal-data/locale/es.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/client/client/src/fiscal-data/locale/es.yml b/client/client/src/fiscal-data/locale/es.yml index 7855c382ad..632fcc3a1b 100644 --- a/client/client/src/fiscal-data/locale/es.yml +++ b/client/client/src/fiscal-data/locale/es.yml @@ -1,4 +1,3 @@ -No: No Yes, notify: Sí, notificar You changed the equalization tax: Has cambiado el recargo de equivalencia Do you want to spread the change: ¿Deseas propagar el cambio a sus consignatarios? From 488675c209455db37c83b098395b8aef845b9e9e Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:14:43 +0200 Subject: [PATCH 15/17] editados los colores para que concuerden con la paleta de verdnatura --- client/salix/src/styles/colors.scss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/salix/src/styles/colors.scss b/client/salix/src/styles/colors.scss index f48dc9fc61..3e38763378 100644 --- a/client/salix/src/styles/colors.scss +++ b/client/salix/src/styles/colors.scss @@ -1,12 +1,12 @@ - $color-green: #a3d131; $color-orange: #f7931e; $color-white: white; $color-dark: #3d3d3d; $color-dark-grey: #424242; $color-light-grey: #e5e5e5; -$color-medium-grey: #9D9D9D; -$color-medium-green: rgba(163, 209, 49, 0.5); -$color-medium-orange: rgba(247, 147, 30, 0.5); -$color-light-green: rgba(163, 209, 49, 0.3); -$color-light-orange: rgba(247, 147, 30, 0.3); \ No newline at end of file +$color-medium-grey: #9b9b9b; +$color-grey: #c4c4c4; +$color-medium-green: rgba($color-green, 0.5); +$color-medium-orange: rgba($color-orange, 0.5); +$color-light-green: rgba($color-green, 0.3); +$color-light-orange: rgba($color-orange, 0.3); \ No newline at end of file From 846b3fb96ecd380d5da12ea52a5193d7ff4a6297 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 19 Apr 2018 15:16:11 +0200 Subject: [PATCH 16/17] solucionado problema con padding --- client/client/src/addresses/addresses.html | 2 +- client/client/src/index/index.html | 4 ++-- client/item/src/list/list.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/client/src/addresses/addresses.html b/client/client/src/addresses/addresses.html index 052b2ab113..699f85cfb2 100644 --- a/client/client/src/addresses/addresses.html +++ b/client/client/src/addresses/addresses.html @@ -30,7 +30,7 @@ {{::observation.description}} - + diff --git a/client/client/src/index/index.html b/client/client/src/index/index.html index 76953e6185..63f502e643 100644 --- a/client/client/src/index/index.html +++ b/client/client/src/index/index.html @@ -2,7 +2,7 @@
- + - +
- + Date: Thu, 19 Apr 2018 15:18:44 +0200 Subject: [PATCH 17/17] cambio en el estilo de las tablas --- client/core/src/components/grid/style.scss | 24 +++++++++++++++++++++ client/ticket/src/volume/ticket-volume.html | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/core/src/components/grid/style.scss b/client/core/src/components/grid/style.scss index 62365a5932..00232e6c36 100644 --- a/client/core/src/components/grid/style.scss +++ b/client/core/src/components/grid/style.scss @@ -21,5 +21,29 @@ } & > tbody > tr { border-bottom: 1px solid #9D9D9D; + transition: background-color 200ms ease-in-out; + + &.clickable { + cursor: pointer; + + &:hover { + background-color: #e5e5e5; + } + } + + &.success { + background-color: rgba(163, 209, 49, 0.3); + + &:hover { + background-color: rgba(163, 209, 49, 0.5); + } + } + &.warning { + background-color: rgba(247, 147, 30, 0.3); + + &:hover { + background-color: rgba(247, 147, 30, 0.5); + } + } } } \ No newline at end of file diff --git a/client/ticket/src/volume/ticket-volume.html b/client/ticket/src/volume/ticket-volume.html index 53e6ba87c7..935da8f994 100644 --- a/client/ticket/src/volume/ticket-volume.html +++ b/client/ticket/src/volume/ticket-volume.html @@ -15,7 +15,7 @@ - + {{::sale.itemFk}} {{::sale.quantity}}