From 8b6e7fdc40fb718db68873319837b1e9550c7429 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Mon, 26 Jun 2017 13:53:52 +0200 Subject: [PATCH 1/4] nuevo componente vnMultiCheck --- client/core/src/components.js | 1 + client/core/src/multi-check/multi-check.html | 11 +++-- client/core/src/multi-check/multi-check.js | 52 +++++++++++++++++--- client/core/src/multi-check/multi-check.scss | 12 +++++ client/production/src/index/index.html | 6 +-- client/production/src/index/index.js | 31 ++++-------- 6 files changed, 77 insertions(+), 36 deletions(-) diff --git a/client/core/src/components.js b/client/core/src/components.js index ecece02d9..9e7b27ede 100644 --- a/client/core/src/components.js +++ b/client/core/src/components.js @@ -19,6 +19,7 @@ import './icon-menu/icon-menu'; import './drop-down/drop-down'; import './colum-header/colum-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_MDL, factory as buttonMdl} from './button/button.mdl'; diff --git a/client/core/src/multi-check/multi-check.html b/client/core/src/multi-check/multi-check.html index 8d7568fb0..720eec2ae 100644 --- a/client/core/src/multi-check/multi-check.html +++ b/client/core/src/multi-check/multi-check.html @@ -1,4 +1,7 @@ -
- - -
\ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/multi-check/multi-check.js index bad51b7e3..dc548cf34 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/multi-check/multi-check.js @@ -2,25 +2,62 @@ import {module} from '../module'; import './multi-check.scss'; export default class MultiCheck { - constructor($element) { + constructor($element, $document, $timeout) { this.$element = $element; + this.$document = $document; + this.$timeout = $timeout; this._checkAll = false; - this._checkType = ''; + this.type = {}; + this.labelType = null; + this.showDropDown = false; } get checkAll() { return this._checkAll; } set checkAll(value) { this._checkAll = value; + this.switchChecks(); } - get checkType() { - return this._checkType; + + switchChecks() { + this.models.forEach( + el => { + let checked; + if (this.labelType) { + if (this.labelType.length > 3 && this.labelType.substr(0, 3) === 'no-') { + checked = el[this.labelType.replace('no-', '')] ? false : true; + } else { + checked = el[this.labelType] ? true : false; + } + } else { + checked = this.checkAll; + } + el.checked = checked; + } + ); } - set checkType(value) { - this._checkType = value; + + $doCheck() { + if (this.type && this.type.id) { + switch (this.type.id) { + case 'all': + this.labelType = null; + this.checkAll = true; + break; + case 'any': + this.labelType = null; + this.checkAll = false; + break; + default: + this.labelType = this.type.id; + this.checkAll = false; + break; + } + this.type = {}; + } } } -MultiCheck.$inject = ['$element']; +MultiCheck.$inject = ['$element', '$document', '$timeout']; module.component('vnMultiCheck', { template: require('./multi-check.html'), @@ -28,6 +65,7 @@ module.component('vnMultiCheck', { bindings: { options: '<', container: '@', + models: '=', className: '@?' } }); diff --git a/client/core/src/multi-check/multi-check.scss b/client/core/src/multi-check/multi-check.scss index e69de29bb..65925e54c 100644 --- a/client/core/src/multi-check/multi-check.scss +++ b/client/core/src/multi-check/multi-check.scss @@ -0,0 +1,12 @@ +vn-multi-check { + vn-drop-down{ + margin-top: 23px; + } + vn-icon{ + cursor: pointer; + } + &:focus, &:active, &:hover{ + outline: none; + border: none; + } +} \ No newline at end of file diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 244166713..4403e434c 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -49,11 +49,11 @@ - + - + @@ -71,7 +71,7 @@ - + {{::ticket.ticketFk}} {{::ticket.agency}} diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index f56052679..2d65d2474 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -18,7 +18,7 @@ export default class ProductionIndex { this.order = {}; this.filter = {}; this.order = {}; - this._checkAll = false; + this.tickets = []; this.states = []; this.lines = 0; @@ -36,22 +36,7 @@ export default class ProductionIndex { 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 _changeState(ids, sateteId, stateName, index) { this.$http.put(`/production/api/TicketStates/${sateteId}/changeState`, {tickets: ids}).then( @@ -80,11 +65,13 @@ export default class ProductionIndex { let ids = []; let index = []; let tickets = []; - checks.forEach( - (_, i) => { - ids.push(this.tickets[i].ticketFk); - index.push(i); - tickets.push({ticketFk: this.tickets[i].ticketFk, salesPersonFk: this.tickets[i].salesPersonFk}); + this.tickets.forEach( + (val, i) => { + if (val.checked) { + ids.push(val.ticketFk); + index.push(i); + tickets.push({ticketFk: val.ticketFk, salesPersonFk: val.salesPersonFk}); + } } ); switch (action) { From 4480431a08e219a63f737ed04829cc7f2b84af84 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Mon, 26 Jun 2017 14:41:08 +0200 Subject: [PATCH 2/4] estilos en vnMultiCheck --- client/core/src/multi-check/multi-check.html | 24 +++++++++++++++----- client/core/src/multi-check/multi-check.js | 18 ++++++--------- client/core/src/multi-check/multi-check.scss | 22 +++++++++++++++--- client/production/src/index/index.html | 2 +- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/client/core/src/multi-check/multi-check.html b/client/core/src/multi-check/multi-check.html index 720eec2ae..0dce98a8a 100644 --- a/client/core/src/multi-check/multi-check.html +++ b/client/core/src/multi-check/multi-check.html @@ -1,7 +1,19 @@ - - - - + + + + + + + + + + + + + + + + - - \ No newline at end of file + + \ No newline at end of file diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/multi-check/multi-check.js index dc548cf34..43d65ba89 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/multi-check/multi-check.js @@ -2,11 +2,8 @@ import {module} from '../module'; import './multi-check.scss'; export default class MultiCheck { - constructor($element, $document, $timeout) { - this.$element = $element; - this.$document = $document; - this.$timeout = $timeout; - this._checkAll = false; + constructor() { + this._checkAll = 0; this.type = {}; this.labelType = null; this.showDropDown = false; @@ -30,7 +27,7 @@ export default class MultiCheck { checked = el[this.labelType] ? true : false; } } else { - checked = this.checkAll; + checked = this.checkAll === 1; } el.checked = checked; } @@ -42,29 +39,28 @@ export default class MultiCheck { switch (this.type.id) { case 'all': this.labelType = null; - this.checkAll = true; + this.checkAll = 1; break; case 'any': this.labelType = null; - this.checkAll = false; + this.checkAll = 0; break; default: this.labelType = this.type.id; - this.checkAll = false; + this.checkAll = 2; break; } this.type = {}; } } } -MultiCheck.$inject = ['$element', '$document', '$timeout']; +MultiCheck.$inject = []; module.component('vnMultiCheck', { template: require('./multi-check.html'), controller: MultiCheck, bindings: { options: '<', - container: '@', models: '=', className: '@?' } diff --git a/client/core/src/multi-check/multi-check.scss b/client/core/src/multi-check/multi-check.scss index 65925e54c..420816487 100644 --- a/client/core/src/multi-check/multi-check.scss +++ b/client/core/src/multi-check/multi-check.scss @@ -1,7 +1,4 @@ vn-multi-check { - vn-drop-down{ - margin-top: 23px; - } vn-icon{ cursor: pointer; } @@ -9,4 +6,23 @@ vn-multi-check { 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; + } + } } \ No newline at end of file diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 4403e434c..6c3612a7e 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -53,7 +53,7 @@ - + From b9704a2b919d7c19166a912e00cb3bb2c61be3f6 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Mon, 26 Jun 2017 14:52:43 +0200 Subject: [PATCH 3/4] corregido fallo en vnMultiCheck --- client/core/src/multi-check/multi-check.js | 1 + client/production/src/index/index.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/multi-check/multi-check.js index 43d65ba89..675216f5a 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/multi-check/multi-check.js @@ -51,6 +51,7 @@ export default class MultiCheck { break; } this.type = {}; + this.labelType = null; } } } diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index 2d65d2474..ea64fa42f 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -18,7 +18,7 @@ export default class ProductionIndex { this.order = {}; this.filter = {}; this.order = {}; - + this.tickets = []; this.states = []; this.lines = 0; From c2b351a777356043a1b0fc80d309ccfb7e9988a3 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Wed, 28 Jun 2017 08:55:01 +0200 Subject: [PATCH 4/4] Cambio de hora y refactorizacion del vnMultiCheck --- client/core/src/multi-check/multi-check.js | 29 +++++++++++-------- client/production/src/index/index.html | 4 +-- client/production/src/index/index.js | 17 +++++++++++ .../production-filters.html | 2 +- client/salix/src/styles/misc.scss | 3 ++ 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/client/core/src/multi-check/multi-check.js b/client/core/src/multi-check/multi-check.js index 675216f5a..52761d898 100644 --- a/client/core/src/multi-check/multi-check.js +++ b/client/core/src/multi-check/multi-check.js @@ -1,11 +1,15 @@ import {module} from '../module'; 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 { constructor() { this._checkAll = 0; this.type = {}; - this.labelType = null; this.showDropDown = false; } get checkAll() { @@ -15,16 +19,18 @@ export default class MultiCheck { this._checkAll = value; this.switchChecks(); } - switchChecks() { this.models.forEach( el => { let checked; - if (this.labelType) { - if (this.labelType.length > 3 && this.labelType.substr(0, 3) === 'no-') { - checked = el[this.labelType.replace('no-', '')] ? false : true; + 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.labelType] ? true : false; + checked = el[this.type.id] ? true : false; } } else { checked = this.checkAll === 1; @@ -33,25 +39,24 @@ export default class MultiCheck { } ); } - + $onChanges() { + this.type = {}; + this.checkAll = 0; + } $doCheck() { if (this.type && this.type.id) { switch (this.type.id) { case 'all': - this.labelType = null; this.checkAll = 1; break; case 'any': - this.labelType = null; this.checkAll = 0; break; default: - this.labelType = this.type.id; this.checkAll = 2; break; } this.type = {}; - this.labelType = null; } } } diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 6c3612a7e..fd3953930 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -75,8 +75,8 @@ {{::ticket.ticketFk}} {{::ticket.agency}} - {{::ticket.salesPerson | ucwords}} {{::ticket.salesPerson | ucwords}} - {{::ticket.hour}} + {{::ticket.salesPerson | ucwords}} + {{ticket.hour}} {{ticket.state}} {{::ticket.lines}} {{::ticket.m3}} diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index ea64fa42f..264f8ae3a 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -57,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 doAction(action) { @@ -84,6 +95,9 @@ export default class ProductionIndex { case 'markPrinted': this._changeState(ids, 4, 'Impreso', index); break; + case 'changeTime': + this._changeTime(ids, this.actions.hours.name, index); + break; } } else { this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!')); @@ -147,6 +161,9 @@ export default class ProductionIndex { if (this.actions.state) { this.doAction('changeState'); this.actions.state = null; + } else if (this.actions.hours) { + this.doAction('changeTime'); + this.actions.hours = null; } } $onInit() { diff --git a/client/production/src/production-filters/production-filters.html b/client/production/src/production-filters/production-filters.html index f89f3d27a..77deef6cd 100644 --- a/client/production/src/production-filters/production-filters.html +++ b/client/production/src/production-filters/production-filters.html @@ -20,7 +20,7 @@ - + diff --git a/client/salix/src/styles/misc.scss b/client/salix/src/styles/misc.scss index 6e85a1bf0..6c2ca8eb7 100644 --- a/client/salix/src/styles/misc.scss +++ b/client/salix/src/styles/misc.scss @@ -91,4 +91,7 @@ html [vn-center], .vn-center{ &:hover{ opacity: 0.7; } +} +.flatpickr-month, .flatpickr-weekdays, span.flatpickr-weekday { + background-color: $color-orange; } \ No newline at end of file