From ca4009088d915ce0e1046ff8f0ae54c4b371d76b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 26 Sep 2019 10:43:06 +0200 Subject: [PATCH 1/4] Descuadre de meses componente calendar #1733 --- front/core/components/calendar/index.js | 36 +++++++++++--------- front/core/components/calendar/index.spec.js | 10 ++++++ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index 23c0450fa..b00c0ddff 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -259,10 +259,11 @@ export default class Calendar extends Component { * @param {Integer} skip - Months to skip at once */ moveNext(skip = 1) { - let next = this.defaultDate.getMonth() + skip; - this.defaultDate.setMonth(next); - this.defaultDate.setHours(0, 0, 0, 0); + const next = this.defaultDate.getMonth() + skip; + this.defaultDate.setDate(1); + this.defaultDate.setHours(null, null, null, null); + this.defaultDate.setMonth(next); this.repaint(); this.emit('moveNext'); @@ -274,14 +275,14 @@ export default class Calendar extends Component { * @param {Integer} skip - Months to skip at once */ movePrevious(skip = 1) { - let previous = this.defaultDate.getMonth() - skip; - this.defaultDate.setMonth(previous); - this.defaultDate.setHours(0, 0, 0, 0); + const previous = this.defaultDate.getMonth() - skip; - const lastDate = this.lastDay(this.defaultDate); - this.defaultDate.setDate(lastDate.getDate()); + this.defaultDate.setDate(1); + this.defaultDate.setHours(null, null, null, null); + this.defaultDate.setMonth(previous); this.repaint(); + this.emit('movePrevious'); } @@ -318,14 +319,17 @@ export default class Calendar extends Component { } renderStyle(style) { - if (style) { - return { - 'background-color': style.backgroundColor, - 'font-weight': style.fontWeight, - 'opacity': style.opacity, - 'color': style.color - }; - } + const normalizedStyle = {}; + + const properties = Object.keys(style); + properties.forEach(attribute => { + const attrName = attribute.split(/(?=[A-Z])/). + join('-').toLowerCase(); + + normalizedStyle[attrName] = style[attribute]; + }); + + return normalizedStyle; } } diff --git a/front/core/components/calendar/index.spec.js b/front/core/components/calendar/index.spec.js index 3f9915278..157dea0c2 100644 --- a/front/core/components/calendar/index.spec.js +++ b/front/core/components/calendar/index.spec.js @@ -116,5 +116,15 @@ describe('Component vnCalendar', () => { expect(controller.emit).toHaveBeenCalledWith('selection', {values: days}); }); }); + + describe('renderStyle()', () => { + it(`should normalize CSS attributes`, () => { + const result = controller.renderStyle({ + backgroundColor: 'red' + }); + + expect(result['background-color']).toEqual('red'); + }); + }); }); From 2a2c5ae3c4c28fec7556732dbb027223f3e1eaca Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 26 Sep 2019 10:56:49 +0200 Subject: [PATCH 2/4] #1719 claim.detail cambiar descuento falla --- modules/ticket/back/methods/ticket/isEditable.js | 6 +++--- modules/ticket/back/methods/ticket/specs/isEditable.spec.js | 5 ++--- modules/ticket/back/methods/ticket/updateDiscount.js | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/ticket/isEditable.js b/modules/ticket/back/methods/ticket/isEditable.js index 766933d45..06fb2fed2 100644 --- a/modules/ticket/back/methods/ticket/isEditable.js +++ b/modules/ticket/back/methods/ticket/isEditable.js @@ -26,7 +26,7 @@ module.exports = Self => { where: {ticketFk: id} }); - let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss'); + let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); let alertLevel = state ? state.alertLevel : null; let ticket = await Self.app.models.Ticket.findById(id, { fields: ['isDeleted', 'clientFk', 'refFk'], @@ -42,10 +42,10 @@ module.exports = Self => { const isDeleted = ticket && ticket.isDeleted; const isOnDelivery = (alertLevel && alertLevel > 0); - const isNotNormalClient = ticket && ticket.client().type().code != 'normal'; + const isNormalClient = ticket && ticket.client().type().code == 'normal'; const isInvoiced = ticket && ticket.refFk; - if (!ticket || (isOnDelivery && isNotNormalClient && !isProductionBoss) || isInvoiced || isDeleted) + if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isProductionBoss)) return false; return true; diff --git a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js index 3e55c5abd..b64981d02 100644 --- a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js +++ b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js @@ -29,15 +29,14 @@ describe('ticket isEditable()', () => { expect(result).toEqual(true); }); - it('should be able to edit a not deleted or invoiced ticket if the role is productionBoss', async() => { + it('should be able to edit a deleted or invoiced ticket if the role is productionBoss', async() => { let ctx = {req: {accessToken: {userId: 50}}}; let result = await app.models.Ticket.isEditable(ctx, 8); expect(result).toEqual(true); }); - // #1719 claim.detail cambiar descuento falla con usuario nacho - xit('should not be able to edit a not deleted or invoiced ticket if the role is salesPerson', async() => { + it('should not be able to edit a deleted or invoiced ticket if the role is salesPerson', async() => { let ctx = {req: {accessToken: {userId: 18}}}; let result = await app.models.Ticket.isEditable(ctx, 8); diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index e4a54d6ba..94ada046f 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -42,7 +42,6 @@ module.exports = Self => { const options = {transaction: tx}; const filter = { - fields: ['id', 'ticketFk', 'price'], where: { id: {inq: salesIds} }, @@ -102,8 +101,7 @@ module.exports = Self => { value: value, componentFk: componentId}, options); - const updatedSale = models.Sale.updateAll({id: sale.id}, - {discount: newDiscount}, options); + const updatedSale = sale.updateAttribute('discount', newDiscount, options); promises.push(newComponent, updatedSale); } From b64a6fd05c5b45e9ff69c70b8d6f6e1933f286b2 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 26 Sep 2019 11:41:56 +0200 Subject: [PATCH 3/4] Mostrar fotos de reclamaciones en el summary #1732 --- modules/claim/front/routes.json | 2 +- modules/claim/front/summary/index.html | 18 ++++++++++++++++++ modules/claim/front/summary/index.js | 7 +++++-- modules/claim/front/summary/style.scss | 22 ++++++++++++++++++++++ modules/ticket/front/locale/es.yml | 2 +- 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 modules/claim/front/summary/style.scss diff --git a/modules/claim/front/routes.json b/modules/claim/front/routes.json index 885328dc4..892e21635 100644 --- a/modules/claim/front/routes.json +++ b/modules/claim/front/routes.json @@ -84,7 +84,7 @@ "url" : "/index", "state": "claim.card.dms.index", "component": "vn-claim-dms-index", - "description": "Pictures", + "description": "Photos", "params": { "claim": "$ctrl.claim" } diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 2d58364af..7877987d1 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -1,3 +1,9 @@ + +
{{$ctrl.summary.claim.id}} - {{$ctrl.summary.claim.client.name}}
@@ -73,6 +79,18 @@ + +

Photos

+ +
+
+ +
+
+
+

Development

diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js index 5741f2c06..257be55e0 100644 --- a/modules/claim/front/summary/index.js +++ b/modules/claim/front/summary/index.js @@ -1,9 +1,12 @@ import ngModule from '../module'; +import './style.scss'; class Controller { - constructor($scope, $http) { + constructor($scope, $http, $stateParams, vnToken) { this.$http = $http; this.$ = $scope; + this.$stateParams = $stateParams; + this.accessToken = vnToken.token; } getSummary() { @@ -36,7 +39,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http']; +Controller.$inject = ['$scope', '$http', '$stateParams', 'vnToken']; ngModule.component('vnClaimSummary', { template: require('./index.html'), diff --git a/modules/claim/front/summary/style.scss b/modules/claim/front/summary/style.scss new file mode 100644 index 000000000..778d91d0e --- /dev/null +++ b/modules/claim/front/summary/style.scss @@ -0,0 +1,22 @@ +@import "./variables"; + +.photo-list { + align-items: flex-start; + flex-wrap: wrap; + + .photo { + box-sizing: border-box; + padding: $pad-small; + width: 33%; + + .image { + border: 2px solid $color-main; + border-radius: 0.5em; + overflow: hidden; + + img { + max-width: 100% + } + } + } +} \ No newline at end of file diff --git a/modules/ticket/front/locale/es.yml b/modules/ticket/front/locale/es.yml index e796407d1..d90c7c707 100644 --- a/modules/ticket/front/locale/es.yml +++ b/modules/ticket/front/locale/es.yml @@ -77,5 +77,5 @@ Tracking: Estados Sale checked: Control clientes Components: Componentes Sale tracking: LĂ­neas preparadas -Pictures: Fotos +Photos: Fotos Log: Historial \ No newline at end of file From a8c6c57b7e158d2a7b9abd05ab10b41ad21d81e9 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 26 Sep 2019 12:07:40 +0200 Subject: [PATCH 4/4] #1719 claim.detail final amends and tests --- modules/ticket/back/methods/ticket/isEditable.js | 7 +++++-- .../ticket/back/methods/ticket/specs/isEditable.spec.js | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/isEditable.js b/modules/ticket/back/methods/ticket/isEditable.js index 06fb2fed2..3ebf15bf0 100644 --- a/modules/ticket/back/methods/ticket/isEditable.js +++ b/modules/ticket/back/methods/ticket/isEditable.js @@ -26,7 +26,10 @@ module.exports = Self => { where: {ticketFk: id} }); - let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); + const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); + const isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss'); + const isValidRole = isSalesAssistant || isProductionBoss; + let alertLevel = state ? state.alertLevel : null; let ticket = await Self.app.models.Ticket.findById(id, { fields: ['isDeleted', 'clientFk', 'refFk'], @@ -45,7 +48,7 @@ module.exports = Self => { const isNormalClient = ticket && ticket.client().type().code == 'normal'; const isInvoiced = ticket && ticket.refFk; - if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isProductionBoss)) + if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isValidRole)) return false; return true; diff --git a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js index b64981d02..a40128954 100644 --- a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js +++ b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js @@ -29,6 +29,13 @@ describe('ticket isEditable()', () => { expect(result).toEqual(true); }); + it('should be able to edit a deleted or invoiced ticket if the role is salesAssistant', async() => { + let ctx = {req: {accessToken: {userId: 21}}}; + let result = await app.models.Ticket.isEditable(ctx, 8); + + expect(result).toEqual(true); + }); + it('should be able to edit a deleted or invoiced ticket if the role is productionBoss', async() => { let ctx = {req: {accessToken: {userId: 50}}}; let result = await app.models.Ticket.isEditable(ctx, 8);