Hot bugs fixed

This commit is contained in:
Juan Ferrer 2019-02-01 17:11:14 +01:00
parent 89826182c2
commit 84c0002cb1
15 changed files with 152 additions and 128 deletions

View File

@ -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() => { it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
let result = await nightmare let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') .autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado')
.waitToClick(selectors.createStateView.saveStateButton) .waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar(); .waitForLastSnackbar();

View File

@ -1,7 +1,7 @@
@import "colors"; @import "colors";
vn-calendar { vn-calendar {
width: 100%; display: block;
.header vn-one { .header vn-one {
text-align: center; text-align: center;
@ -30,7 +30,7 @@ vn-calendar {
span { span {
transition: background-color 0.3s; transition: background-color 0.3s;
text-align: center; text-align: center;
font-size: 0.8vw; font-size: .8em;
border-radius: 50%; border-radius: 50%;
display: block; display: block;
padding: 0.2em; padding: 0.2em;

View File

@ -10,7 +10,7 @@ vn-searchbar {
} }
.search-panel { .search-panel {
max-height: 44em; max-height: 48em;
& > form { & > form {
@extend .pad-large; @extend .pad-large;

View File

@ -94,6 +94,13 @@ vn-app {
right: 0; right: 0;
} }
} }
.main-with-right-menu {
padding-right: $menu-width;
@media screen and (max-width: 800px) {
padding-right: 0;
}
}
} }
& > .background { & > .background {
display: none; display: none;
@ -147,6 +154,9 @@ vn-app {
transform: translateZ(0) translateX($menu-width); transform: translateZ(0) translateX($menu-width);
} }
} }
.main-with-right-menu {
padding-right: 0;
}
} }
& > .background.shown { & > .background.shown {
display: block; display: block;

View File

@ -4,27 +4,24 @@
fields="['zoneFk', 'delivered']" fields="['zoneFk', 'delivered']"
link="{zoneFk: $ctrl.$stateParams.id}" link="{zoneFk: $ctrl.$stateParams.id}"
data="$ctrl.data" data="$ctrl.data"
primary-key="zoneFk" auto-load="true"> primary-key="zoneFk"
auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-horizontal> <vn-calendar
<vn-vertical vn-one> pad-small
<vn-card> vn-id="stMonth"
<vn-vertical> events="$ctrl.events"
<vn-vertical pad-small> skip="2"
<vn-calendar vn-id="stMonth" events="$ctrl.events" skip="2"
on-selection="$ctrl.onSelection(stMonth, values)" on-selection="$ctrl.onSelection(stMonth, values)"
on-move-next="$ctrl.onMoveNext(ndMonth)" on-move-next="$ctrl.onMoveNext(ndMonth)"
on-move-previous="$ctrl.onMovePrevious(ndMonth)"> on-move-previous="$ctrl.onMovePrevious(ndMonth)">
</vn-calendar> </vn-calendar>
</vn-vertical> <vn-calendar
<vn-vertical pad-small> pad-small
<vn-calendar vn-id="ndMonth" events="$ctrl.events" skip="2" vn-id="ndMonth"
events="$ctrl.events"
skip="2"
display-controls="false" display-controls="false"
on-selection="$ctrl.onSelection(ndMonth, values)" on-selection="$ctrl.onSelection(ndMonth, values)"
default-date="$ctrl.ndMonthDate"> default-date="$ctrl.ndMonthDate">
</vn-calendar> </vn-calendar>
</vn-vertical>
</vn-vertical>
</vn-card>
</vn-vertical>
</vn-horizontal>

View File

@ -1,7 +1,8 @@
import ngModule from '../module'; import ngModule from '../module';
class Controller { class Controller {
constructor($scope, $stateParams, $http) { constructor($element, $scope, $stateParams, $http) {
this.$element = $element;
this.$stateParams = $stateParams; this.$stateParams = $stateParams;
this.$scope = $scope; this.$scope = $scope;
this.$http = $http; this.$http = $http;
@ -16,6 +17,14 @@ class Controller {
this.ndMonth = this.$scope.ndMonth; this.ndMonth = this.$scope.ndMonth;
} }
$onInit() {
this.app.rightMenu = this.$element[0];
}
$onDestroy() {
this.app.rightMenu = null;
}
get zone() { get zone() {
return this._zone; return this._zone;
} }
@ -138,11 +147,14 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$stateParams', '$http']; Controller.$inject = ['$element', '$scope', '$stateParams', '$http'];
ngModule.component('vnZoneCalendar', { ngModule.component('vnZoneCalendar', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,
require: {
app: '^vnApp'
},
bindings: { bindings: {
zone: '<' zone: '<'
} }

View File

@ -4,9 +4,8 @@
filter="::$ctrl.filter" filter="::$ctrl.filter"
params="{zoneFk: $ctrl.$stateParams.id, parentFk: 1}"> params="{zoneFk: $ctrl.$stateParams.id, parentFk: 1}">
</vn-crud-model> </vn-crud-model>
<vn-horizontal> <div class="main-with-right-menu">
<vn-vertical vn-one> <vn-card compact pad-large>
<vn-card pad-large>
<vn-searchbar <vn-searchbar
model="model" model="model"
expr-builder="$ctrl.exprBuilder(param, value)" expr-builder="$ctrl.exprBuilder(param, value)"
@ -17,8 +16,8 @@
on-selection="$ctrl.onSelection(item)"> on-selection="$ctrl.onSelection(item)">
</vn-treeview> </vn-treeview>
</vn-card> </vn-card>
</vn-vertical> <vn-zone-calendar
<vn-auto class="right-block"> class="right-menu"
<vn-zone-calendar zone="::$ctrl.zone"></vn-zone-calendar> zone="::$ctrl.zone">
</vn-auto> </vn-zone-calendar>
</vn-horizontal> </div>

View File

@ -230,13 +230,13 @@
"abstract": true, "abstract": true,
"state": "client.card.creditInsurance", "state": "client.card.creditInsurance",
"component": "ui-view", "component": "ui-view",
"acl": ["creditInsurance"] "acl": ["insurance"]
}, { }, {
"url": "/index", "url": "/index",
"state": "client.card.creditInsurance.index", "state": "client.card.creditInsurance.index",
"component": "vn-client-credit-insurance-index", "component": "vn-client-credit-insurance-index",
"description": "Credit contracts", "description": "Credit contracts",
"acl": ["creditInsurance"], "acl": ["insurance"],
"params": { "params": {
"client": "$ctrl.client" "client": "$ctrl.client"
} }
@ -253,13 +253,13 @@
"abstract": true, "abstract": true,
"state": "client.card.creditInsurance.insurance", "state": "client.card.creditInsurance.insurance",
"component": "ui-view", "component": "ui-view",
"acl": ["creditInsurance"] "acl": ["insurance"]
}, { }, {
"url": "/:classificationId/index", "url": "/:classificationId/index",
"state": "client.card.creditInsurance.insurance.index", "state": "client.card.creditInsurance.insurance.index",
"component": "vn-client-credit-insurance-insurance-index", "component": "vn-client-credit-insurance-insurance-index",
"description": "Requested credits", "description": "Requested credits",
"acl": ["creditInsurance"], "acl": ["insurance"],
"params": { "params": {
"client": "$ctrl.client" "client": "$ctrl.client"
} }

View File

@ -1,11 +1,12 @@
<vn-crud-model auto-load="false" <vn-crud-model
vn-id="model" vn-id="model"
url="/order/api/Orders/CatalogFilter" url="/order/api/Orders/CatalogFilter"
filter="$ctrl.filter" filter="$ctrl.filter"
limit="50" limit="50"
data="items" on-data-change="$ctrl.onDataChange()" > data="items"
on-data-change="$ctrl.onDataChange()" >
</vn-crud-model> </vn-crud-model>
<div class="items"> <div class="main-with-right-menu">
<vn-card> <vn-card>
<vn-horizontal class="catalog-header" pad-medium-h> <vn-horizontal class="catalog-header" pad-medium-h>
<vn-one ng-if="model.moreRows"> <vn-one ng-if="model.moreRows">

View File

@ -1,7 +1,6 @@
@import "colors"; @import "colors";
vn-order-catalog { vn-order-catalog .catalog-header {
.catalog-header {
border-color: $lines; border-color: $lines;
border-bottom: 1px solid rgba($lines, 0.5); border-bottom: 1px solid rgba($lines, 0.5);
@ -15,11 +14,3 @@ vn-order-catalog {
color: $secondary-font-color color: $secondary-font-color
} }
} }
& > .items {
padding-right: 16em;
@media screen and (max-width: 800px) {
padding-right: 0;
}
}
}

View File

@ -25,24 +25,34 @@ module.exports = Self => {
Self.changeState = async(ctx, data) => { Self.changeState = async(ctx, data) => {
let userId = ctx.req.accessToken.userId; let userId = ctx.req.accessToken.userId;
let models = Self.app.models; let $ = Self.app.models;
let isEditable = await models.Ticket.isEditable(data.ticketFk); if (!data.stateFk)
let assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}); throw new UserError('State cannot be blank');
let isAssigned = assignedState.id === data.stateFk;
let isProduction = await models.Account.hasRole(userId, 'production'); let isProduction = await $.Account.hasRole(userId, 'production');
let isSalesPerson = await models.Account.hasRole(userId, 'salesPerson'); let isSalesPerson = await $.Account.hasRole(userId, 'salesPerson');
let isAllowed = isProduction || isSalesPerson && isEditable && isAssigned;
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) if (!isAllowed)
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED'); throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
if (!isAssigned) { if (newState.code != 'PICKER_DESIGNED') {
let worker = await models.Worker.findOne({where: {userFk: userId}}); let worker = await $.Worker.findOne({where: {userFk: userId}});
data.workerFk = worker.id; data.workerFk = worker.id;
} }
return await models.TicketTracking.create(data); return await $.TicketTracking.create(data);
}; };
}; };

View File

@ -14,4 +14,8 @@ module.exports = Self => {
); );
return result[0].alertLevel == 0; return result[0].alertLevel == 0;
}; };
Self.prototype.isEditable = function() {
return this.code == 'PICKER_DESIGNED' || this.alertLevel == 0;
};
}; };

File diff suppressed because one or more lines are too long