diff --git a/e2e/paths/client-module/13_log.spec.js b/e2e/paths/client-module/13_log.spec.js
index aba23ab72..60ab6e7bc 100644
--- a/e2e/paths/client-module/13_log.spec.js
+++ b/e2e/paths/client-module/13_log.spec.js
@@ -4,8 +4,6 @@ import createNightmare from '../../helpers/nightmare';
describe('Client log path', () => {
const nightmare = createNightmare();
- let date;
-
beforeAll(() => {
nightmare
.loginAndModule('employee', 'client')
@@ -19,7 +17,6 @@ describe('Client log path', () => {
.write(selectors.clientBasicData.nameInput, 'this is a test')
.waitToClick(selectors.clientBasicData.saveButton)
.waitForLastSnackbar();
- date = new Date();
expect(result).toEqual('Data saved!');
});
@@ -41,32 +38,13 @@ describe('Client log path', () => {
});
it('should check the current value of the last logged change', async() => {
- let lastModificationDate = await nightmare
- .waitToGetProperty(selectors.clientLog.lastModificationDate, 'innerText');
-
let lastModificationPreviousValue = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationPreviousValue, 'innerText');
let lastModificationCurrentValue = await nightmare
.waitToGetProperty(selectors.clientLog.lastModificationCurrentValue, 'innerText');
- let month = date.getMonth() + 1;
- let day = date.getDate();
- let year = date.getFullYear();
- let hours = date.getHours();
- let minutes = date.getMinutes();
- if (month.toString().length < 2) month = '0' + month;
- if (day.toString().length < 2) day = `0${day}`;
- if (hours.toString().length < 2) hours = '0' + hours;
- if (minutes.toString().length < 2) minutes = `0${minutes}`;
-
- let today = [day, month, year].join('/');
- let time = [hours, minutes].join(':');
-
- let now = [today, time].join(' ');
-
- expect(lastModificationDate).toContain(now);
expect(lastModificationPreviousValue).toEqual('name: DavidCharlesHaller');
expect(lastModificationCurrentValue).toEqual('name: this is a test');
});
diff --git a/modules/ticket/back/methods/ticket/getVolume.js b/modules/ticket/back/methods/ticket/getVolume.js
index 0bfb6b9ea..9b4d28edc 100644
--- a/modules/ticket/back/methods/ticket/getVolume.js
+++ b/modules/ticket/back/methods/ticket/getVolume.js
@@ -10,7 +10,8 @@ module.exports = Self => {
http: {source: 'path'}
}],
returns: {
- arg: 'volumes'
+ type: ['Object'],
+ root: true
},
http: {
path: `/:id/getVolume`,
diff --git a/modules/ticket/front/volume/index.html b/modules/ticket/front/volume/index.html
index ee00d025a..1efb07149 100644
--- a/modules/ticket/front/volume/index.html
+++ b/modules/ticket/front/volume/index.html
@@ -3,8 +3,12 @@
url="/ticket/api/sales"
filter="::$ctrl.filter"
link="{ticketFk: $ctrl.$stateParams.id}"
- limit="20"
- data="sales" on-data-change="$ctrl.onDataChange()">
+ data="$ctrl.sales"
+ limit="20">
+
+
@@ -30,7 +34,7 @@
-
+
{
- if (response.data) {
- this.$scope.model.data.forEach(sale => {
- response.data.volumes.forEach(volume => {
- if (sale.id === volume.saleFk)
- sale.volume = volume;
- });
- });
- }
+ get sales() {
+ return this._sales;
+ }
+
+ set sales(value) {
+ this._sales = value;
+
+ if (value) this.applyVolumes();
+ }
+
+ get volumes() {
+ return this._volumes;
+ }
+
+ set volumes(value) {
+ this._volumes = value;
+
+ if (value) this.applyVolumes();
+ }
+
+
+ applyVolumes() {
+ if (!this.sales || !this.volumes) return;
+
+ this.sales.forEach(sale => {
+ this.volumes.forEach(volume => {
+ if (sale.id === volume.saleFk)
+ sale.volume = volume;
});
+ });
}
showDescriptor(event, itemFk) {
diff --git a/modules/ticket/front/volume/index.spec.js b/modules/ticket/front/volume/index.spec.js
index 66206895f..f94085417 100644
--- a/modules/ticket/front/volume/index.spec.js
+++ b/modules/ticket/front/volume/index.spec.js
@@ -22,7 +22,50 @@ describe('ticket', () => {
controller = $componentController('vnTicketVolume', {$scope, $httpBackend, $state});
}));
- it('should join the sale volumes to its respective sale', () => {
+ describe('sales() setter', () => {
+ it('should set sales property on controller an then call applyVolumes() method', () => {
+ spyOn(controller, 'applyVolumes');
+
+ controller.sales = [{id: 1}];
+
+ expect(controller.applyVolumes).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('volumes() setter', () => {
+ it('should set volumes property on controller an then call applyVolumes() method', () => {
+ spyOn(controller, 'applyVolumes');
+
+ controller.volumes = [{id: 1}];
+
+ expect(controller.applyVolumes).toHaveBeenCalledWith();
+ });
+ });
+
+ describe('applyVolumes()', () => {
+ it(`should not apply volumes to the sales if sales property is not defined on controller`, () => {
+ controller.sales = [{id: 1, name: 'Sale one'}, {id: 2, name: 'Sale two'}];
+
+ expect(controller.sales[0].volume).toBeUndefined();
+ expect(controller.sales[1].volume).toBeUndefined();
+ });
+
+ it(`should not apply volumes to the sales if sales property is not defined on controller`, () => {
+ controller.volumes = [{saleFk: 1, m3: 0.012}, {saleFk: 2, m3: 0.015}];
+
+ expect(controller.sales).toBeUndefined();
+ });
+
+ it(`should apply volumes to the sales if sales and volumes properties are defined on controller`, () => {
+ controller.sales = [{id: 1, name: 'Sale one'}, {id: 2, name: 'Sale two'}];
+ controller.volumes = [{saleFk: 1, m3: 0.012}, {saleFk: 2, m3: 0.015}];
+
+ expect(controller.sales[0].volume.m3).toEqual(0.012);
+ expect(controller.sales[1].volume.m3).toEqual(0.015);
+ });
+ });
+
+ /* it('should join the sale volumes to its respective sale', () => {
controller.ticket = {id: 1};
let response = {volumes: [{saleFk: 1, m3: 0.008}, {saleFk: 2, m3: 0.003}]};
$httpBackend.whenGET(`/api/tickets/1/getVolume`).respond(response);
@@ -32,6 +75,6 @@ describe('ticket', () => {
expect($scope.model.data[0].volume.m3).toBe(0.008);
expect($scope.model.data[1].volume.m3).toBe(0.003);
- });
+ }); */
});
});