Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
nelo 2017-06-28 08:57:37 +02:00
commit 7b38d2f188
8 changed files with 134 additions and 43 deletions

View File

@ -19,6 +19,7 @@ import './icon-menu/icon-menu';
import './drop-down/drop-down'; import './drop-down/drop-down';
import './colum-header/colum-header'; import './colum-header/colum-header';
import './grid-header/grid-header'; import './grid-header/grid-header';
import './multi-check/multi-check';
export {NAME as BUTTON, directive as ButtonDirective} from './button/button'; export {NAME as BUTTON, directive as ButtonDirective} from './button/button';
export {NAME as BUTTON_MDL, factory as buttonMdl} from './button/button.mdl'; export {NAME as BUTTON_MDL, factory as buttonMdl} from './button/button.mdl';

View File

@ -1,4 +1,19 @@
<div class="multi-check {{$ctrl.className}}"> <vn-vertical vn-none class="multi-check {{$ctrl.className}}" tabindex="-1" ng-blur="$ctrl.showDropDown = false">
<vn-check model="$ctrl.checkAll"></vn-check> <vn-one>
<vn-horizontal>
</div> <vn-none class="primaryCheckbox" ng-if="$ctrl.checkAll===0">
<vn-icon vn-none icon="check_box_outline_blank" ng-click="$ctrl.checkAll = 1"></vn-icon>
</vn-none>
<vn-none class="primaryCheckbox color" ng-if="$ctrl.checkAll===1">
<vn-icon vn-none icon="check_box" ng-click="$ctrl.checkAll = 0"></vn-icon>
</vn-none>
<vn-none class="primaryCheckbox color" ng-if="$ctrl.checkAll===2">
<vn-icon vn-none icon="indeterminate_check_box" ng-click="$ctrl.checkAll = 0"></vn-icon>
</vn-none>
<vn-icon vn-none class="arrow_down" icon="keyboard_arrow_down" ng-click="$ctrl.showDropDown = true"></vn-icon>
</vn-horizontal>
</vn-one>
<vn-one>
<vn-drop-down vn-none items="$ctrl.options" show="$ctrl.showDropDown" selected="$ctrl.type"></vn-drop-down>
</vn-one>
</vn-vertical>

View File

@ -1,33 +1,73 @@
import {module} from '../module'; import {module} from '../module';
import './multi-check.scss'; import './multi-check.scss';
/*
* @description Draw checkbox with a drop-down and multi options
* @param {Array} options - List of options shown in drop-down
* @param {Array} models - Elements to check / unCheck
* @param {String=} className - Optional css class name
*/
export default class MultiCheck { export default class MultiCheck {
constructor($element) { constructor() {
this.$element = $element; this._checkAll = 0;
this._checkAll = false; this.type = {};
this._checkType = ''; this.showDropDown = false;
} }
get checkAll() { get checkAll() {
return this._checkAll; return this._checkAll;
} }
set checkAll(value) { set checkAll(value) {
this._checkAll = value; this._checkAll = value;
this.switchChecks();
} }
get checkType() { switchChecks() {
return this._checkType; this.models.forEach(
el => {
let checked;
if (this.type.id && this.type.id !== 'all' && this.type.id !== 'any') {
if (this.type.id.length > 3 && this.type.id.substr(0, 3) === 'no-') {
checked = el[this.type.id.replace('no-', '')] ? false : true;
} else if (this.type.id.length > 6 && this.type.id.substr(0, 6) === 'equal-') {
let label = this.type.id.replace('equal-', '');
checked = (el[label] && el[label] === this.type.name);
} else {
checked = el[this.type.id] ? true : false;
}
} else {
checked = this.checkAll === 1;
}
el.checked = checked;
}
);
} }
set checkType(value) { $onChanges() {
this._checkType = value; this.type = {};
this.checkAll = 0;
}
$doCheck() {
if (this.type && this.type.id) {
switch (this.type.id) {
case 'all':
this.checkAll = 1;
break;
case 'any':
this.checkAll = 0;
break;
default:
this.checkAll = 2;
break;
}
this.type = {};
}
} }
} }
MultiCheck.$inject = ['$element']; MultiCheck.$inject = [];
module.component('vnMultiCheck', { module.component('vnMultiCheck', {
template: require('./multi-check.html'), template: require('./multi-check.html'),
controller: MultiCheck, controller: MultiCheck,
bindings: { bindings: {
options: '<', options: '<',
container: '@', models: '=',
className: '@?' className: '@?'
} }
}); });

View File

@ -0,0 +1,28 @@
vn-multi-check {
vn-icon{
cursor: pointer;
}
&:focus, &:active, &:hover{
outline: none;
border: none;
}
.primaryCheckbox {
vn-icon{
font-size: 22px;
margin-left: -4px;
i{
color: rgba(0,0,0,.54);
}
}
&.color {
i{
color: rgb(255,152,0);
}
}
}
.arrow_down{
i{
padding-top: 8px;
}
}
}

View File

@ -53,7 +53,7 @@
<vn-grid-header on-order="$ctrl.onOrder(field, order)"> <vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-none min-none></vn-none> <vn-none min-none></vn-none>
<vn-colum-header vn-none min-none> <vn-colum-header vn-none min-none>
<vn-check model="$ctrl.checkAll"></vn-check> <vn-multi-check models="$ctrl.tickets" options="[{id:'all',name:'Todos'},{id:'any',name:'Ninguno'},{id:'problem',name:'Con incidencia'},{id:'no-problem',name:'Sin incidencia'}]"></vn-multi-check>
</vn-colum-header> </vn-colum-header>
<vn-colum-header vn-one pad-medium-h field="ticketFk" text="ID Ticket"></vn-colum-header> <vn-colum-header vn-one pad-medium-h field="ticketFk" text="ID Ticket"></vn-colum-header>
<vn-colum-header vn-two pad-medium-h field="agency" text="Agency"></vn-colum-header> <vn-colum-header vn-two pad-medium-h field="agency" text="Agency"></vn-colum-header>
@ -71,12 +71,12 @@
<vn-icon margin-small-left icon="report_problem" ng-if="ticket.problem" vn-tooltip="{{ticket.problem}}" tooltip-position="right"></vn-icon> <vn-icon margin-small-left icon="report_problem" ng-if="ticket.problem" vn-tooltip="{{ticket.problem}}" tooltip-position="right"></vn-icon>
</vn-none> </vn-none>
<vn-none> <vn-none>
<vn-check model="ticket.cheched"></vn-check> <vn-check model="ticket.checked"></vn-check>
</vn-none> </vn-none>
<vn-one pad-medium-h>{{::ticket.ticketFk}}</vn-one> <vn-one pad-medium-h>{{::ticket.ticketFk}}</vn-one>
<vn-two pad-medium-h>{{::ticket.agency}}</vn-two> <vn-two pad-medium-h>{{::ticket.agency}}</vn-two>
<vn-two pad-medium-h>{{::ticket.salesPerson | ucwords}} {{::ticket.salesPerson | ucwords}}</vn-two> <vn-two pad-medium-h>{{::ticket.salesPerson | ucwords}}</vn-two>
<vn-one pad-medium-h>{{::ticket.hour}}</vn-one> <vn-one pad-medium-h>{{ticket.hour}}</vn-one>
<vn-one pad-medium-h>{{ticket.state}}</vn-one> <vn-one pad-medium-h>{{ticket.state}}</vn-one>
<vn-one pad-medium-h>{{::ticket.lines}}</vn-one> <vn-one pad-medium-h>{{::ticket.lines}}</vn-one>
<vn-one pad-medium-h>{{::ticket.m3}}</vn-one> <vn-one pad-medium-h>{{::ticket.m3}}</vn-one>

View File

@ -18,7 +18,7 @@ export default class ProductionIndex {
this.order = {}; this.order = {};
this.filter = {}; this.filter = {};
this.order = {}; this.order = {};
this._checkAll = false;
this.tickets = []; this.tickets = [];
this.states = []; this.states = [];
this.lines = 0; this.lines = 0;
@ -36,22 +36,7 @@ export default class ProductionIndex {
name: "Silla FV" name: "Silla FV"
}; };
} }
get checkAll() {
return this._checkAll;
}
set checkAll(value) {
this._checkAll = value;
this.switchChecks();
}
switchChecks() {
let checks = this.$element[0].querySelectorAll('.list-body input[type="checkbox"]');
checks.forEach(
(el, i) => {
el.checked = this._checkAll;
this.tickets[i].cheched = this._checkAll;
}
);
}
// Actions Callbacks // Actions Callbacks
_changeState(ids, sateteId, stateName, index) { _changeState(ids, sateteId, stateName, index) {
this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then( this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then(
@ -72,6 +57,17 @@ export default class ProductionIndex {
} }
); );
} }
_changeTime(ids, time, index) {
this.$http.put(`/production/api/changeTime?time=${time}`, {tickets: ids}).then(
() => {
index.forEach(
val => {
this.tickets[val].hour = time;
}
);
}
);
}
// End Actions Callbacks // End Actions Callbacks
doAction(action) { doAction(action) {
@ -80,11 +76,13 @@ export default class ProductionIndex {
let ids = []; let ids = [];
let index = []; let index = [];
let tickets = []; let tickets = [];
checks.forEach( this.tickets.forEach(
(_, i) => { (val, i) => {
ids.push(this.tickets[i].ticketFk); if (val.checked) {
index.push(i); ids.push(val.ticketFk);
tickets.push({ticketFk: this.tickets[i].ticketFk, salesPersonFk: this.tickets[i].salesPersonFk}); index.push(i);
tickets.push({ticketFk: val.ticketFk, salesPersonFk: val.salesPersonFk});
}
} }
); );
switch (action) { switch (action) {
@ -97,6 +95,9 @@ export default class ProductionIndex {
case 'markPrinted': case 'markPrinted':
this._changeState(ids, 4, 'Impreso', index); this._changeState(ids, 4, 'Impreso', index);
break; break;
case 'changeTime':
this._changeTime(ids, this.actions.hours.name, index);
break;
} }
} else { } else {
this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!')); this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!'));
@ -160,6 +161,9 @@ export default class ProductionIndex {
if (this.actions.state) { if (this.actions.state) {
this.doAction('changeState'); this.doAction('changeState');
this.actions.state = null; this.actions.state = null;
} else if (this.actions.hours) {
this.doAction('changeTime');
this.actions.hours = null;
} }
} }
$onInit() { $onInit() {

View File

@ -20,7 +20,7 @@
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-one margin-medium-right field="$ctrl.filter.stateFk" data="$ctrl.data.states" label="State"></vn-autocomplete> <vn-autocomplete vn-one margin-medium-right field="$ctrl.filter.stateFk" data="$ctrl.data.states" label="State"></vn-autocomplete>
<vn-autocomplete vn-one margin-medium-right field="$ctrl.filter.agencyFk" url="/production/api/Agencies/list" label="Agency"></vn-autocomplete> <vn-autocomplete vn-one margin-medium-right field="$ctrl.filter.agencyFk" url="/production/api/Agencies" label="Agency"></vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal margin-large-top> <vn-horizontal margin-large-top>
<vn-submit vn-one label="Filter"></vn-submit> <vn-submit vn-one label="Filter"></vn-submit>

View File

@ -92,3 +92,6 @@ html [vn-center], .vn-center{
opacity: 0.7; opacity: 0.7;
} }
} }
.flatpickr-month, .flatpickr-weekdays, span.flatpickr-weekday {
background-color: $color-orange;
}