Merge
gitea/salix/dev This commit looks good Details

This commit is contained in:
Juan Ferrer 2019-09-26 13:36:22 +02:00
commit dbd70da866
10 changed files with 84 additions and 21 deletions

View File

@ -288,14 +288,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;
}
hasEvents() {

View File

@ -68,5 +68,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');
});
});
});

View File

@ -84,7 +84,7 @@
"url" : "/index",
"state": "claim.card.dms.index",
"component": "vn-claim-dms-index",
"description": "Pictures",
"description": "Photos",
"params": {
"claim": "$ctrl.claim"
}

View File

@ -1,3 +1,9 @@
<vn-crud-model
url="/api/ClaimDms"
where="{claimFk: $ctrl.$stateParams.id}"
data="photos"
auto-load="true">
</vn-crud-model>
<vn-card class="summary">
<h5>{{$ctrl.summary.claim.id}} - {{$ctrl.summary.claim.client.name}}</h5>
<vn-horizontal>
@ -73,6 +79,18 @@
</vn-tbody>
</vn-table>
</vn-auto>
<vn-auto ng-if="photos.length > 0">
<h4 translate>Photos</h4>
<vn-horizontal class="photo-list">
<section class="photo" ng-repeat="photo in photos">
<section class="image">
<img alt="" on-error-src
ng-src="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}"
zoom-image="/api/dms/{{::photo.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}">
</section>
</section>
</vn-horizontal>
</vn-auto>
<vn-auto>
<h4 translate>Development</h4>
<vn-table model="model">

View File

@ -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'),

View File

@ -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%
}
}
}
}

View File

@ -26,7 +26,10 @@ module.exports = Self => {
where: {ticketFk: id}
});
let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss');
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'],
@ -42,10 +45,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 && !isValidRole))
return false;
return true;

View File

@ -29,15 +29,21 @@ 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 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);
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);

View File

@ -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);
}

View File

@ -77,5 +77,5 @@ Tracking: Estados
Sale checked: Control clientes
Components: Componentes
Sale tracking: Líneas preparadas
Pictures: Fotos
Photos: Fotos
Log: Historial