Hot bugs fixed
This commit is contained in:
parent
89826182c2
commit
84c0002cb1
|
@ -69,7 +69,7 @@ describe('Ticket Create new tracking state path', () => {
|
|||
|
||||
it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
|
||||
let result = await nightmare
|
||||
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
|
||||
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado')
|
||||
.waitToClick(selectors.createStateView.saveStateButton)
|
||||
.waitForLastSnackbar();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@import "colors";
|
||||
|
||||
vn-calendar {
|
||||
width: 100%;
|
||||
display: block;
|
||||
|
||||
.header vn-one {
|
||||
text-align: center;
|
||||
|
@ -30,7 +30,7 @@ vn-calendar {
|
|||
span {
|
||||
transition: background-color 0.3s;
|
||||
text-align: center;
|
||||
font-size: 0.8vw;
|
||||
font-size: .8em;
|
||||
border-radius: 50%;
|
||||
display: block;
|
||||
padding: 0.2em;
|
||||
|
|
|
@ -10,7 +10,7 @@ vn-searchbar {
|
|||
}
|
||||
|
||||
.search-panel {
|
||||
max-height: 44em;
|
||||
max-height: 48em;
|
||||
|
||||
& > form {
|
||||
@extend .pad-large;
|
||||
|
|
|
@ -94,6 +94,13 @@ vn-app {
|
|||
right: 0;
|
||||
}
|
||||
}
|
||||
.main-with-right-menu {
|
||||
padding-right: $menu-width;
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
& > .background {
|
||||
display: none;
|
||||
|
@ -147,6 +154,9 @@ vn-app {
|
|||
transform: translateZ(0) translateX($menu-width);
|
||||
}
|
||||
}
|
||||
.main-with-right-menu {
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
& > .background.shown {
|
||||
display: block;
|
||||
|
|
|
@ -4,27 +4,24 @@
|
|||
fields="['zoneFk', 'delivered']"
|
||||
link="{zoneFk: $ctrl.$stateParams.id}"
|
||||
data="$ctrl.data"
|
||||
primary-key="zoneFk" auto-load="true">
|
||||
primary-key="zoneFk"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-horizontal>
|
||||
<vn-vertical vn-one>
|
||||
<vn-card>
|
||||
<vn-vertical>
|
||||
<vn-vertical pad-small>
|
||||
<vn-calendar vn-id="stMonth" events="$ctrl.events" skip="2"
|
||||
on-selection="$ctrl.onSelection(stMonth, values)"
|
||||
on-move-next="$ctrl.onMoveNext(ndMonth)"
|
||||
on-move-previous="$ctrl.onMovePrevious(ndMonth)">
|
||||
</vn-calendar>
|
||||
</vn-vertical>
|
||||
<vn-vertical pad-small>
|
||||
<vn-calendar vn-id="ndMonth" events="$ctrl.events" skip="2"
|
||||
display-controls="false"
|
||||
on-selection="$ctrl.onSelection(ndMonth, values)"
|
||||
default-date="$ctrl.ndMonthDate">
|
||||
</vn-calendar>
|
||||
</vn-vertical>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
</vn-horizontal>
|
||||
<vn-calendar
|
||||
pad-small
|
||||
vn-id="stMonth"
|
||||
events="$ctrl.events"
|
||||
skip="2"
|
||||
on-selection="$ctrl.onSelection(stMonth, values)"
|
||||
on-move-next="$ctrl.onMoveNext(ndMonth)"
|
||||
on-move-previous="$ctrl.onMovePrevious(ndMonth)">
|
||||
</vn-calendar>
|
||||
<vn-calendar
|
||||
pad-small
|
||||
vn-id="ndMonth"
|
||||
events="$ctrl.events"
|
||||
skip="2"
|
||||
display-controls="false"
|
||||
on-selection="$ctrl.onSelection(ndMonth, values)"
|
||||
default-date="$ctrl.ndMonthDate">
|
||||
</vn-calendar>
|
|
@ -1,7 +1,8 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $stateParams, $http) {
|
||||
constructor($element, $scope, $stateParams, $http) {
|
||||
this.$element = $element;
|
||||
this.$stateParams = $stateParams;
|
||||
this.$scope = $scope;
|
||||
this.$http = $http;
|
||||
|
@ -16,6 +17,14 @@ class Controller {
|
|||
this.ndMonth = this.$scope.ndMonth;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.app.rightMenu = this.$element[0];
|
||||
}
|
||||
|
||||
$onDestroy() {
|
||||
this.app.rightMenu = null;
|
||||
}
|
||||
|
||||
get zone() {
|
||||
return this._zone;
|
||||
}
|
||||
|
@ -138,11 +147,14 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$scope', '$stateParams', '$http'];
|
||||
Controller.$inject = ['$element', '$scope', '$stateParams', '$http'];
|
||||
|
||||
ngModule.component('vnZoneCalendar', {
|
||||
template: require('./index.html'),
|
||||
controller: Controller,
|
||||
require: {
|
||||
app: '^vnApp'
|
||||
},
|
||||
bindings: {
|
||||
zone: '<'
|
||||
}
|
||||
|
|
|
@ -4,21 +4,20 @@
|
|||
filter="::$ctrl.filter"
|
||||
params="{zoneFk: $ctrl.$stateParams.id, parentFk: 1}">
|
||||
</vn-crud-model>
|
||||
<vn-horizontal>
|
||||
<vn-vertical vn-one>
|
||||
<vn-card pad-large>
|
||||
<vn-searchbar
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
on-search="$ctrl.onSearch()"
|
||||
vn-focus>
|
||||
</vn-searchbar>
|
||||
<vn-treeview vn-id="treeview" model="model"
|
||||
on-selection="$ctrl.onSelection(item)">
|
||||
</vn-treeview>
|
||||
</vn-card>
|
||||
</vn-vertical>
|
||||
<vn-auto class="right-block">
|
||||
<vn-zone-calendar zone="::$ctrl.zone"></vn-zone-calendar>
|
||||
</vn-auto>
|
||||
</vn-horizontal>
|
||||
<div class="main-with-right-menu">
|
||||
<vn-card compact pad-large>
|
||||
<vn-searchbar
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
on-search="$ctrl.onSearch()"
|
||||
vn-focus>
|
||||
</vn-searchbar>
|
||||
<vn-treeview vn-id="treeview" model="model"
|
||||
on-selection="$ctrl.onSelection(item)">
|
||||
</vn-treeview>
|
||||
</vn-card>
|
||||
<vn-zone-calendar
|
||||
class="right-menu"
|
||||
zone="::$ctrl.zone">
|
||||
</vn-zone-calendar>
|
||||
</div>
|
|
@ -230,13 +230,13 @@
|
|||
"abstract": true,
|
||||
"state": "client.card.creditInsurance",
|
||||
"component": "ui-view",
|
||||
"acl": ["creditInsurance"]
|
||||
"acl": ["insurance"]
|
||||
}, {
|
||||
"url": "/index",
|
||||
"state": "client.card.creditInsurance.index",
|
||||
"component": "vn-client-credit-insurance-index",
|
||||
"description": "Credit contracts",
|
||||
"acl": ["creditInsurance"],
|
||||
"acl": ["insurance"],
|
||||
"params": {
|
||||
"client": "$ctrl.client"
|
||||
}
|
||||
|
@ -253,13 +253,13 @@
|
|||
"abstract": true,
|
||||
"state": "client.card.creditInsurance.insurance",
|
||||
"component": "ui-view",
|
||||
"acl": ["creditInsurance"]
|
||||
"acl": ["insurance"]
|
||||
}, {
|
||||
"url": "/:classificationId/index",
|
||||
"state": "client.card.creditInsurance.insurance.index",
|
||||
"component": "vn-client-credit-insurance-insurance-index",
|
||||
"description": "Requested credits",
|
||||
"acl": ["creditInsurance"],
|
||||
"acl": ["insurance"],
|
||||
"params": {
|
||||
"client": "$ctrl.client"
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<vn-crud-model auto-load="false"
|
||||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="/order/api/Orders/CatalogFilter"
|
||||
filter="$ctrl.filter"
|
||||
limit="50"
|
||||
data="items" on-data-change="$ctrl.onDataChange()" >
|
||||
data="items"
|
||||
on-data-change="$ctrl.onDataChange()" >
|
||||
</vn-crud-model>
|
||||
<div class="items">
|
||||
<div class="main-with-right-menu">
|
||||
<vn-card>
|
||||
<vn-horizontal class="catalog-header" pad-medium-h>
|
||||
<vn-one ng-if="model.moreRows">
|
||||
|
|
|
@ -1,25 +1,16 @@
|
|||
@import "colors";
|
||||
|
||||
vn-order-catalog {
|
||||
.catalog-header {
|
||||
border-color: $lines;
|
||||
border-bottom: 1px solid rgba($lines, 0.5);
|
||||
|
||||
vn-one:first-child {
|
||||
padding-top: 2em;
|
||||
}
|
||||
vn-one:nth-child(2) {
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
span {
|
||||
color: $secondary-font-color
|
||||
}
|
||||
}
|
||||
& > .items {
|
||||
padding-right: 16em;
|
||||
vn-order-catalog .catalog-header {
|
||||
border-color: $lines;
|
||||
border-bottom: 1px solid rgba($lines, 0.5);
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
padding-right: 0;
|
||||
}
|
||||
vn-one:first-child {
|
||||
padding-top: 2em;
|
||||
}
|
||||
vn-one:nth-child(2) {
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
span {
|
||||
color: $secondary-font-color
|
||||
}
|
||||
}
|
|
@ -25,24 +25,34 @@ module.exports = Self => {
|
|||
|
||||
Self.changeState = async(ctx, data) => {
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let models = Self.app.models;
|
||||
let $ = Self.app.models;
|
||||
|
||||
let isEditable = await models.Ticket.isEditable(data.ticketFk);
|
||||
let assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}});
|
||||
let isAssigned = assignedState.id === data.stateFk;
|
||||
if (!data.stateFk)
|
||||
throw new UserError('State cannot be blank');
|
||||
|
||||
let isProduction = await models.Account.hasRole(userId, 'production');
|
||||
let isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
|
||||
let isAllowed = isProduction || isSalesPerson && isEditable && isAssigned;
|
||||
let isProduction = await $.Account.hasRole(userId, 'production');
|
||||
let isSalesPerson = await $.Account.hasRole(userId, 'salesPerson');
|
||||
|
||||
let ticket = await $.TicketState.findById(
|
||||
data.ticketFk,
|
||||
{fields: ['stateFk']}
|
||||
);
|
||||
|
||||
let oldState = await $.State.findById(ticket.stateFk);
|
||||
let newState = await $.State.findById(data.stateFk);
|
||||
|
||||
let isAllowed = isProduction || isSalesPerson
|
||||
&& oldState.isEditable()
|
||||
&& newState.isEditable();
|
||||
|
||||
if (!isAllowed)
|
||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||
|
||||
if (!isAssigned) {
|
||||
let worker = await models.Worker.findOne({where: {userFk: userId}});
|
||||
if (newState.code != 'PICKER_DESIGNED') {
|
||||
let worker = await $.Worker.findOne({where: {userFk: userId}});
|
||||
data.workerFk = worker.id;
|
||||
}
|
||||
|
||||
return await models.TicketTracking.create(data);
|
||||
return await $.TicketTracking.create(data);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -14,4 +14,8 @@ module.exports = Self => {
|
|||
);
|
||||
return result[0].alertLevel == 0;
|
||||
};
|
||||
|
||||
Self.prototype.isEditable = function() {
|
||||
return this.code == 'PICKER_DESIGNED' || this.alertLevel == 0;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
"name": "State",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "state"
|
||||
}
|
||||
"mysql": {
|
||||
"table": "state"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -16,15 +16,15 @@
|
|||
"type": "String",
|
||||
"required": false
|
||||
},
|
||||
"order":{
|
||||
"order": {
|
||||
"type": "Number",
|
||||
"required": false
|
||||
},
|
||||
"alertLevel":{
|
||||
"alertLevel": {
|
||||
"type": "Number",
|
||||
"required": false
|
||||
},
|
||||
"code":{
|
||||
"code": {
|
||||
"type": "String",
|
||||
"required": false
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
{
|
||||
"name": "TicketState",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "ticketState"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"ticketFk": {
|
||||
"id": true,
|
||||
"type": "Number",
|
||||
"forceId": false
|
||||
"name": "TicketState",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "ticketState"
|
||||
}
|
||||
},
|
||||
"updated": {
|
||||
"type": "Date"
|
||||
"properties": {
|
||||
"ticketFk": {
|
||||
"id": true,
|
||||
"type": "Number",
|
||||
"forceId": false
|
||||
},
|
||||
"updated": {
|
||||
"type": "Date"
|
||||
},
|
||||
"alertLevel": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"alertLevel": {
|
||||
"type": "Number"
|
||||
"relations": {
|
||||
"ticket": {
|
||||
"type": "belongsTo",
|
||||
"model": "Ticket",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"state": {
|
||||
"type": "belongsTo",
|
||||
"model": "State",
|
||||
"foreignKey": "stateFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"ticket": {
|
||||
"type": "belongsTo",
|
||||
"model": "Ticket",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"state": {
|
||||
"type": "belongsTo",
|
||||
"model": "State",
|
||||
"foreignKey": "stateFk"
|
||||
},
|
||||
"worker": {
|
||||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue