From 7aeed467e93695c5a0033b41e157428fba5b76c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20S=C3=A1nchez?= Date: Wed, 21 Mar 2018 14:54:12 +0100 Subject: [PATCH] Quantity validation on ticket packaging --- client/ticket/routes.json | 8 +------- .../src/package/{list/package-list.html => package.html} | 0 .../src/package/{list/package-list.js => package.js} | 6 +++--- .../{list/package-list.spec.js => package.spec.js} | 6 +++--- client/ticket/src/ticket.js | 2 +- e2e/helpers/selectors.js | 2 +- services/ticket/common/models/ticketPackaging.js | 2 +- 7 files changed, 10 insertions(+), 16 deletions(-) rename client/ticket/src/package/{list/package-list.html => package.html} (100%) rename client/ticket/src/package/{list/package-list.js => package.js} (93%) rename client/ticket/src/package/{list/package-list.spec.js => package.spec.js} (91%) diff --git a/client/ticket/routes.json b/client/ticket/routes.json index 18c8632ae..7014d1c0c 100644 --- a/client/ticket/routes.json +++ b/client/ticket/routes.json @@ -60,14 +60,8 @@ }, { "url" : "/package", - "abstract": true, "state": "ticket.card.package", - "component": "ui-view" - }, - { - "url": "/list", - "state": "ticket.card.package.list", - "component": "vn-ticket-package-list", + "component": "vn-ticket-package", "params": { "ticket": "$ctrl.ticket" }, diff --git a/client/ticket/src/package/list/package-list.html b/client/ticket/src/package/package.html similarity index 100% rename from client/ticket/src/package/list/package-list.html rename to client/ticket/src/package/package.html diff --git a/client/ticket/src/package/list/package-list.js b/client/ticket/src/package/package.js similarity index 93% rename from client/ticket/src/package/list/package-list.js rename to client/ticket/src/package/package.js index 0bf6903a2..6cb749517 100644 --- a/client/ticket/src/package/list/package-list.js +++ b/client/ticket/src/package/package.js @@ -1,4 +1,4 @@ -import ngModule from '../../module'; +import ngModule from '../module'; class Controller { @@ -64,8 +64,8 @@ class Controller { Controller.$inject = ['$http', '$scope']; -ngModule.component('vnTicketPackageList', { - template: require('./package-list.html'), +ngModule.component('vnTicketPackage', { + template: require('./package.html'), controller: Controller, bindings: { ticket: '<' diff --git a/client/ticket/src/package/list/package-list.spec.js b/client/ticket/src/package/package.spec.js similarity index 91% rename from client/ticket/src/package/list/package-list.spec.js rename to client/ticket/src/package/package.spec.js index f6c38cc49..b9b7c310a 100644 --- a/client/ticket/src/package/list/package-list.spec.js +++ b/client/ticket/src/package/package.spec.js @@ -1,7 +1,7 @@ -import './package-list.js'; +import './package.js'; describe('Ticket', () => { - describe('Component vnTicketPackageList', () => { + describe('Component vnTicketPackage', () => { let $componentController; let controller; let $httpBackend; @@ -19,7 +19,7 @@ describe('Ticket', () => { accept: function() {} } }; - controller = $componentController('vnTicketPackageList', {$scope: $scope}); + controller = $componentController('vnTicketPackage', {$scope: $scope}); })); describe('removePackage()', () => { diff --git a/client/ticket/src/ticket.js b/client/ticket/src/ticket.js index d02656ba2..f317794b2 100644 --- a/client/ticket/src/ticket.js +++ b/client/ticket/src/ticket.js @@ -6,6 +6,6 @@ import './card/ticket-card'; import './summary/ticket-summary'; import './data/ticket-data'; import './notes/ticket-observations'; -import './package/list/package-list'; +import './package/package'; import './sale/sale'; import './review/review'; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 9acf8b1fe..ad7aa9b8b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -289,7 +289,7 @@ export default { submitNotesButton: `${components.vnSubmit}` }, ticketPackages: { - packagesButton: `${components.vnMenuItem}[ui-sref="ticket.card.package.list"]`, + packagesButton: `${components.vnMenuItem}[ui-sref="ticket.card.package"]`, firstPackageSelect: `${components.vnAutocomplete}[label="Package"] input` } }; diff --git a/services/ticket/common/models/ticketPackaging.js b/services/ticket/common/models/ticketPackaging.js index 55e13b494..610dca7ad 100644 --- a/services/ticket/common/models/ticketPackaging.js +++ b/services/ticket/common/models/ticketPackaging.js @@ -8,7 +8,7 @@ module.exports = function(Self) { }); function validateQuantity(quantity) { - return quantity != 0; + return !isNaN(quantity) && quantity != 0; } Self.validatesPresenceOf('packagingFk', {message: 'Package cannot be blank'});