From e09f60a53a550cc03a0504efaa0f1191f3fa91e0 Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Tue, 13 Jun 2017 13:08:06 +0200 Subject: [PATCH] =?UTF-8?q?Nuevos=20componentes:=20drop-down,=20icon-menu.?= =?UTF-8?q?=20Refactorizaci=C3=B3n=20de=20icon=20e=20icon-button=20(pasado?= =?UTF-8?q?s=20a=20componentes=20sin=20template=20manager)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/core/src/components.js | 2 + client/core/src/drop-down/drop-down.html | 3 ++ client/core/src/drop-down/drop-down.js | 16 ++++++ client/core/src/drop-down/style.scss | 20 +++++++ client/core/src/filters/index.js | 1 + client/core/src/filters/ucwords.js | 20 +++++++ client/core/src/icon-button/icon-button.html | 3 ++ client/core/src/icon-button/icon-button.js | 18 +++++-- client/core/src/icon-menu/icon-menu.html | 4 ++ client/core/src/icon-menu/icon-menu.js | 54 +++++++++++++++++++ client/core/src/icon/icon.js | 16 ++++-- client/core/src/icon/icon.mdl.js | 2 +- client/production/src/index/index.html | 55 ++++++++++---------- client/production/src/index/index.js | 19 ++++++- client/production/src/index/style.scss | 3 ++ 15 files changed, 199 insertions(+), 37 deletions(-) create mode 100644 client/core/src/drop-down/drop-down.html create mode 100644 client/core/src/drop-down/drop-down.js create mode 100644 client/core/src/drop-down/style.scss create mode 100644 client/core/src/filters/ucwords.js create mode 100644 client/core/src/icon-button/icon-button.html create mode 100644 client/core/src/icon-menu/icon-menu.html create mode 100644 client/core/src/icon-menu/icon-menu.js diff --git a/client/core/src/components.js b/client/core/src/components.js index fc5c92d344..f0303ebe21 100644 --- a/client/core/src/components.js +++ b/client/core/src/components.js @@ -15,6 +15,8 @@ import './subtitle/subtitle'; import './spinner/spinner'; import './snackbar/snackbar'; import './tooltip/tooltip'; +import './icon-menu/icon-menu'; +import './drop-down/drop-down'; 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/drop-down/drop-down.html b/client/core/src/drop-down/drop-down.html new file mode 100644 index 0000000000..4b354ae623 --- /dev/null +++ b/client/core/src/drop-down/drop-down.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/drop-down/drop-down.js new file mode 100644 index 0000000000..c33aea7b5e --- /dev/null +++ b/client/core/src/drop-down/drop-down.js @@ -0,0 +1,16 @@ +import {module} from '../module'; +import './style.scss'; + +/* export default class DropDown { +}*/ + +module.component('vnDropDown', { + template: require('./drop-down.html'), + // controller: DropDown, + bindings: { + items: '<', + show: '<', + selected: '=' + }, + controllerAs: 'dd' +}); diff --git a/client/core/src/drop-down/style.scss b/client/core/src/drop-down/style.scss new file mode 100644 index 0000000000..07cf592d9c --- /dev/null +++ b/client/core/src/drop-down/style.scss @@ -0,0 +1,20 @@ +vn-drop-down { + position: absolute; + z-index: 9999; + + ul{ + padding: 0; + margin: 10px 0 0 0; + background: white; + border: 1px solid #A7A7A7; + li { + list-style-type: none; + padding: 5px 20px 5px 5px; + cursor: pointer; + } + li:hover{ + background-color: #3D3A3B; + color: white; + } + } +} \ No newline at end of file diff --git a/client/core/src/filters/index.js b/client/core/src/filters/index.js index de0560b2f8..885f3cd666 100644 --- a/client/core/src/filters/index.js +++ b/client/core/src/filters/index.js @@ -1 +1,2 @@ import './phone'; +import './ucwords'; diff --git a/client/core/src/filters/ucwords.js b/client/core/src/filters/ucwords.js new file mode 100644 index 0000000000..08ca725ebf --- /dev/null +++ b/client/core/src/filters/ucwords.js @@ -0,0 +1,20 @@ +import {module} from '../module'; + +/** + * Uppercase the first character of each word in a string + * + * @return {String} The formated string + */ +export default function ucwords() { + return function(input) { + input = input || ''; + let out = ''; + let aux = input.split(' '); + for (let i = 0; i < aux.length; i++) { + out += (aux[i]) ? aux[i].charAt(0).toUpperCase() + aux[i].substr(1).toLowerCase() : ''; + out += ' '; + } + return out.trim(); + }; +} +module.filter('ucwords', ucwords); diff --git a/client/core/src/icon-button/icon-button.html b/client/core/src/icon-button/icon-button.html new file mode 100644 index 0000000000..4f80d96b58 --- /dev/null +++ b/client/core/src/icon-button/icon-button.html @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/client/core/src/icon-button/icon-button.js b/client/core/src/icon-button/icon-button.js index 62ce9a2a4d..806b86d83f 100644 --- a/client/core/src/icon-button/icon-button.js +++ b/client/core/src/icon-button/icon-button.js @@ -1,10 +1,10 @@ import {module as _module} from '../module'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; +// import * as resolveFactory from '../lib/resolveDefaultComponents'; import * as util from '../lib/util'; const _NAME = 'iconButton'; export const NAME = util.getName(_NAME); - +/* directive.$inject = [resolveFactory.NAME]; export function directive(resolve) { return { @@ -14,4 +14,16 @@ export function directive(resolve) { } }; } -_module.directive(NAME, directive); +_module.directive(NAME, directive); */ + +_module.component(NAME, { + template: require('./icon-button.html'), + bindings: { + icon: '@', + className: ' + + + \ No newline at end of file diff --git a/client/core/src/icon-menu/icon-menu.js b/client/core/src/icon-menu/icon-menu.js new file mode 100644 index 0000000000..d1119bedbc --- /dev/null +++ b/client/core/src/icon-menu/icon-menu.js @@ -0,0 +1,54 @@ +import {module} from '../module'; + +export default class IconMenu { + constructor($element, $http, $timeout) { + this.$element = $element; + this.$http = $http; + this.$timeout = $timeout; + this._showDropDown = false; + } + get showDropDown() { + return this._showDropDown; + } + set showDropDown(value) { + this._showDropDown = value; + } + + getItems() { + this.$http.get(this.url).then( + json => { + this.items = json.data; + } + ); + } + $onInit() { + if (!this.items && this.url) { + this.getItems(); + } + + this.$element.bind('mouseover', () => { + this.$timeout(() => { + this.showDropDown = true; + }); + }); + + this.$element.bind('mouseout', () => { + this.$timeout(() => { + this.showDropDown = false; + }); + }); + } +} +IconMenu.$inject = ['$element', '$http', '$timeout']; + +module.component('vnIconMenu', { + template: require('./icon-menu.html'), + bindings: { + url: '@?', + items: '=?', + icon: '@', + selected: '=' + }, + controller: IconMenu, + controllerAs: 'im' +}); diff --git a/client/core/src/icon/icon.js b/client/core/src/icon/icon.js index 31e9ca5658..29f3d0747d 100644 --- a/client/core/src/icon/icon.js +++ b/client/core/src/icon/icon.js @@ -1,12 +1,12 @@ import {module} from '../module'; import './icon.mdl'; import './style.css'; -import * as resolveFactory from '../lib/resolveDefaultComponents'; +// import * as resolveFactory from '../lib/resolveDefaultComponents'; -const _NAME = 'icon'; +// const _NAME = 'icon'; export const NAME = 'vnIcon'; -export function directive(resolver) { +/* export function directive(resolver) { return { restrict: 'E', template: function(_, attrs) { @@ -16,4 +16,12 @@ export function directive(resolver) { } directive.$inject = [resolveFactory.NAME]; -module.directive(NAME, directive); +module.directive(NAME, directive);*/ + +module.component(NAME, { + template: '{{i.icon}}', + bindings: { + icon: '@' + }, + controllerAs: 'i' +}); diff --git a/client/core/src/icon/icon.mdl.js b/client/core/src/icon/icon.mdl.js index ce3f82856d..6a558285cb 100644 --- a/client/core/src/icon/icon.mdl.js +++ b/client/core/src/icon/icon.mdl.js @@ -6,7 +6,7 @@ export function factory() { return { template: template, default: {} - } + }; } module.factory(NAME, factory); diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index b768aab801..cc1b7511af 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -1,4 +1,4 @@ - + @@ -25,7 +25,10 @@ - + + + + @@ -34,51 +37,49 @@ - - + + - + - - + + - + - - + + - - + + - - {{ticket.id}} - {{ticket.agency.name}} - {{ticket.employee.name}} + + {{ticket.ticket}} + {{ticket.agency}} + {{ticket.worker | ucwords}} {{ticket.hour}} - {{ticket.state.name}} + {{ticket.state}} {{ticket.lines}} - {{ticket.meters}} + {{ticket.m3}} {{ticket.boxes}} - + - + + + : {{$ctrl.tickets.length}} - - - - - - + + {{$ctrl.lines}} {{$ctrl.meters}} - + \ No newline at end of file diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index 97c5c1d5c0..8fed9a431b 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -10,6 +10,7 @@ export default class ProductionIndex { this.tickets = []; this.lines = 0; this.meters = 0; + this.state = null; } get checkAll() { return this._checkAll; @@ -18,6 +19,12 @@ export default class ProductionIndex { this._checkAll = value; this.switchChecks(); } + /*get state() { + return this._state; + } + set state(value) { + this._state = value; + }*/ switchChecks() { let checks = this.$element[0].querySelectorAll('.list-body input[type="checkbox"]'); checks.forEach( @@ -33,11 +40,13 @@ export default class ProductionIndex { let ids = []; checks.forEach( (_, i) => { - ids.push(this.tickets[i].id); + ids.push(this.tickets[i].ticket); } ); + console.log("TODO: call action -> endPoint with tickets's Ids", action, ids, arguments[1]); // TODO: call action -> endPoint with tickets's Ids } else { + console.log("TODO: dialog with no items selected", action); // TODO: dialog with no items selected } } @@ -47,7 +56,7 @@ export default class ProductionIndex { this.tickets.forEach( val => { lines += parseFloat(val.lines); - meters += parseFloat(val.meters); + meters += parseFloat(val.m3); } ); this.lines = lines; @@ -57,6 +66,12 @@ export default class ProductionIndex { this.$.index.filter = this.filter; this.$.index.accept(); } + $doCheck() { + if (this.state) { + this.doAction('changeState', Object.assign({}, this.state)); + this.state = null; + } + } } ProductionIndex.$inject = ['$element', '$scope']; diff --git a/client/production/src/index/style.scss b/client/production/src/index/style.scss index 13bd38bbfb..cafeb13cb9 100644 --- a/client/production/src/index/style.scss +++ b/client/production/src/index/style.scss @@ -29,6 +29,9 @@ vn-production-index { .list > vn-one, .list > [vn-one], .list > [vn-two], .list > vn-two{ text-align: center; } + .list > vn-none{ + min-width: 60px; + } .list-body{ padding: 4px 0px; border-bottom: 1px solid #9D9D9D;