diff --git a/client/core/src/popover/popover.js b/client/core/src/popover/popover.js index 7abe382e3..5f2cc5cdb 100644 --- a/client/core/src/popover/popover.js +++ b/client/core/src/popover/popover.js @@ -96,9 +96,10 @@ export class Popover { this.lastEvent = null; this.docMouseDownHandler = null; this.docKeyDownHandler = null; - if (this.removeScope) { + if (this.removeScope && angular.element(this.childElement).scope()) { angular.element(this.childElement).scope().$destroy(); angular.element(this.childElement).remove(); + this.removeScope = false; } } onDocMouseDown(event) { diff --git a/client/production/src/index/index.html b/client/production/src/index/index.html index 7dd6b4dc4..f2a27a61d 100644 --- a/client/production/src/index/index.html +++ b/client/production/src/index/index.html @@ -4,42 +4,41 @@ - Localizador - + Finder - + - + - + + ng-click="$ctrl.moreFilters($event)"> - + + field="$ctrl.warehouseFk" url="/production/api/Warehouses/list" label="Store"> - - + + - + - - - - - + + + + + - + diff --git a/client/production/src/index/index.js b/client/production/src/index/index.js index cdd4f63c3..6e6b64325 100644 --- a/client/production/src/index/index.js +++ b/client/production/src/index/index.js @@ -2,11 +2,14 @@ import ngModule from '../module'; import './style.scss'; export default class ProductionIndex { - constructor($element, $scope, $http, vnPopover) { + constructor($element, $scope, $http, vnPopover, vnApp, $translate) { this.$element = $element; this.$ = $scope; this.$http = $http; this.vnPopover = vnPopover; + this.vnApp = vnApp; + this.$translate = $translate; + this.filter = {}; this._checkAll = false; this.tickets = []; @@ -19,6 +22,7 @@ export default class ProductionIndex { hour: null }; this.hourItems = []; + this.child = undefined; } get checkAll() { return this._checkAll; @@ -36,6 +40,7 @@ export default class ProductionIndex { } ); } + // Actions Callbacks _changeState(ids, sateteId, stateName, index) { this.$http.put(`/production/api/TicketStates/[${ids}]/${sateteId}/changeState`).then( () => { @@ -47,6 +52,10 @@ export default class ProductionIndex { } ); } + _publishComment(ids, comment) { + console.log("TODO: rest to publish comment", ids, comment); + } + // End Actions Callbacks doAction(action) { let checks = this.$element[0].querySelectorAll('.list-body input[type="checkbox"]:checked'); if (checks.length) { @@ -62,10 +71,12 @@ export default class ProductionIndex { case 'changeState' : this._changeState(ids, this.actions.state.id, this.actions.state.name, index); break; + case 'addComment': + this._openComment(ids); + break; } } else { - console.log("TODO: dialog with no items selected", action); - // TODO: dialog with no items selected + this.vnApp.showMessage(this.$translate.instant('Error: No tickets selected!')); } } sumTickets() { @@ -80,10 +91,43 @@ export default class ProductionIndex { this.lines = lines; this.meters = meters.toFixed(2); } - onSearch() { - this.$.index.filter = this.filter; - this.$.index.accept(); + // Start modals and actions modals + _openComment(ids) { + this.child = this.vnPopover.showComponent('vn-production-comment', this.$, this.$element[0].querySelector('.actionPanel')); + var childCtrl = angular.element(this.child).isolateScope().$ctrl; + childCtrl.ids = ids; + childCtrl.onComment = (ids, comment) => this.onChildComment(ids, comment); + childCtrl.onCancel = () => this.onChildCancel(); } + moreFilters(event) { + this.child = this.vnPopover.showComponent('vn-production-filter-panel', this.$, this.$element[0].querySelector('.filterPanel')); + var childCtrl = angular.element(this.child).isolateScope().$ctrl; + childCtrl.filter = Object.assign({}, this.filter); + childCtrl.onSubmit = filter => this.onChildSubmit(filter); + childCtrl.onCancel = () => this.onChildCancel(); + + event.preventDefault(); + } + onSearch(filter) { + let filters = filter || this.filter; + /* this.$.index.filter = filters; + this.$.index.accept(); */ + console.log('TODO: search with filters', filters); + } + onChildSubmit(filter) { + this.onSearch(filter); + this.onChildCancel(); + } + onChildComment(ids, comment) { + this.onChildCancel(); + this._publishComment(ids, comment); + } + onChildCancel() { + angular.element(this.child).scope().$destroy(); + angular.element(this.child).remove(); + delete this.child; + } + // END modals and actions modals $doCheck() { if (this.actions.state) { this.doAction('changeState'); @@ -100,16 +144,8 @@ export default class ProductionIndex { this.hourItems.push({id: i, name: hour}); } } - moreFilters(event) { - var child = this.vnPopover.showComponent('vn-production-filter-panel', this.$, this.$element[0].querySelector('.filterPanel')); - var childCtrl = angular.element(child).isolateScope().$ctrl; - childCtrl.filter = Object.assign({}, this.index.filter); - childCtrl.onSubmit = filter => this.onChildSubmit(filter); - - event.preventDefault(); - } } -ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover']; +ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'vnApp', '$translate']; ngModule.component('vnProductionIndex', { template: require('./index.html'), diff --git a/client/production/src/locale/es.json b/client/production/src/locale/es.json index 9e26dfeeb..faa95e5bf 100644 --- a/client/production/src/locale/es.json +++ b/client/production/src/locale/es.json @@ -1 +1,17 @@ -{} \ No newline at end of file +{ + "Finder" : "Localizador", + "Error: No tickets selected!" : "Error: ¡No hay tickets seleccionados!", + "State" : "Estado", + "Alarm" : "Alarma", + "Agencies": "Agencias", + "Agency": "Agencia", + "Store" : "Almacén", + "Printed": "Impreso", + "Commercial": "Comercial", + "Hour" : "Hora", + "Lines" : "Líneas", + "Boxes" : "Cajas", + "Comment" : "Comentario", + "Message" : "Mensaje", + "Send" : "Enviar" +} \ No newline at end of file diff --git a/client/production/src/production-comment/production-comment.html b/client/production/src/production-comment/production-comment.html new file mode 100644 index 000000000..14342ab00 --- /dev/null +++ b/client/production/src/production-comment/production-comment.html @@ -0,0 +1,4 @@ +
+ + +
\ No newline at end of file diff --git a/client/production/src/production-comment/production-comment.js b/client/production/src/production-comment/production-comment.js new file mode 100644 index 000000000..390de47c2 --- /dev/null +++ b/client/production/src/production-comment/production-comment.js @@ -0,0 +1,5 @@ +import ngModule from '../module'; + +ngModule.component('vnProductionComment', { + template: require('./production-comment.html') +}); diff --git a/client/production/src/production-filters/production-filters.html b/client/production/src/production-filters/production-filters.html index bbd638e04..2fd12511e 100644 --- a/client/production/src/production-filters/production-filters.html +++ b/client/production/src/production-filters/production-filters.html @@ -1,5 +1,5 @@ -
+ @@ -19,5 +19,8 @@ - + + + +
diff --git a/client/production/src/production-filters/production-filters.js b/client/production/src/production-filters/production-filters.js index b74136113..0e6143efc 100644 --- a/client/production/src/production-filters/production-filters.js +++ b/client/production/src/production-filters/production-filters.js @@ -1,13 +1,5 @@ import ngModule from '../module'; -export default class Controller { - constructor($window) { - this.$window = $window; - } -} -Controller.$inject = ['$window']; - ngModule.component('vnProductionFilterPanel', { - template: require('./production-filters.html'), - controller: Controller + template: require('./production-filters.html') }); diff --git a/client/production/src/production.js b/client/production/src/production.js index e7a270305..f9f4eeb08 100644 --- a/client/production/src/production.js +++ b/client/production/src/production.js @@ -4,3 +4,4 @@ export * from './module'; // import components import './index/index'; import './production-filters/production-filters'; +import './production-comment/production-comment';