diff --git a/client/order/src/catalogue/index.html b/client/order/src/catalogue/index.html index 5dd1f681a..6e41c1f6e 100644 --- a/client/order/src/catalogue/index.html +++ b/client/order/src/catalogue/index.html @@ -18,10 +18,7 @@ ng-repeat="item in items" item="::item"> - - - No results - + No results @@ -31,3 +28,7 @@ + + + diff --git a/client/order/src/catalogue/index.js b/client/order/src/catalogue/index.js index 0a3d97485..cee1972a5 100644 --- a/client/order/src/catalogue/index.js +++ b/client/order/src/catalogue/index.js @@ -27,6 +27,14 @@ class Controller { get order() { return this._order; } + + openPricePopover(event, item) { + this.$scope.pricesPopover.show(event, item); + } + + onDescriptorLoad() { + this.$scope.popover.relocate(); + } } Controller.$inject = ['$scope', '$stateParams']; diff --git a/client/order/src/catalogue/product.html b/client/order/src/catalogue/product.html index 3bbb473b8..6cd775f4f 100644 --- a/client/order/src/catalogue/product.html +++ b/client/order/src/catalogue/product.html @@ -40,7 +40,7 @@ - + diff --git a/client/order/src/catalogue/product.js b/client/order/src/catalogue/product.js index 1b75eaf39..ca2e4e1cb 100644 --- a/client/order/src/catalogue/product.js +++ b/client/order/src/catalogue/product.js @@ -1,7 +1,20 @@ import ngModule from '../module'; +class Controller { + onClick(event) { + if (event.defaultPrevented) + event.stopImmediatePropagation(); + } + + preview(event) { + event.preventDefault(); + this.index.openPricePopover(event, this.item); + } +} + ngModule.component('vnOrderProduct', { template: require('./product.html'), + controller: Controller, bindings: { item: '<' }, diff --git a/client/order/src/index.js b/client/order/src/index.js index 15adc056e..4e58591ce 100644 --- a/client/order/src/index.js +++ b/client/order/src/index.js @@ -8,7 +8,7 @@ import './summary'; import './catalogue'; import './catalogue/product'; import './line'; -//import './prices-popover'; +import './prices-popover'; import './volume'; import './create'; import './create/card'; diff --git a/client/order/src/prices-popover/index.html b/client/order/src/prices-popover/index.html new file mode 100644 index 000000000..709d251e3 --- /dev/null +++ b/client/order/src/prices-popover/index.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + {{$ctrl.item.id}} + + + + + + + + + + + + + + + + {{::price.warehouseName}} + + {{::price.grouping}} x {{::price.price | currency: ' €': 2}} + + + + + + + + + + + + + + + + + + + + diff --git a/client/order/src/prices-popover/index.js b/client/order/src/prices-popover/index.js new file mode 100644 index 000000000..010fd94fa --- /dev/null +++ b/client/order/src/prices-popover/index.js @@ -0,0 +1,62 @@ +import ngModule from '../module'; +import './style.scss'; + +class Controller { + constructor($scope, $http) { + this.$ = $scope; + this.$http = $http; + this.totalBasquet = 0; + } + + getTags() { + let filter = { + where: {itemFk: this.item.id, + priority: {gte: 4}}, + order: 'priority ASC', + include: {relation: 'tag'} + }; + this.$http.get(`/item/api/ItemTags?filter=${JSON.stringify(filter)}`).then(response => { + this.tags = response.data; + }); + } + + show(event, item) { + this.item = JSON.parse(JSON.stringify(item)); + this.prices = this.item.prices; + this.getTags(); + this.$.popover.parent = event.target; + this.$.popover.relocate(); + this.$.popover.show(); + } + + clear() { + this.item = {}; + this.tags = {}; + this.prices = {}; + this.totalBasquet = 0; + } + addQuantity(price) { + if (this.totalBasquet + price.grouping <= this.item.disponible) { + price.quantity += price.grouping; + this.totalBasquet = this.totalBasquet + price.grouping; + } + } + save() { + let params = { + warehouseFk: warehouseFk, + itemFk: itemFk, + quantity: quantity + }; + + this.$http.post(`/order/api/OrderRows/new`, params).then(response => { + this.tags = response.data; + }); + } +} + +Controller.$inject = ['$scope', '$http']; + +ngModule.component('vnOrderPricesPopover', { + template: require('./index.html'), + controller: Controller +}); diff --git a/client/order/src/prices-popover/locale/es.yml b/client/order/src/prices-popover/locale/es.yml new file mode 100644 index 000000000..c151537ba --- /dev/null +++ b/client/order/src/prices-popover/locale/es.yml @@ -0,0 +1,2 @@ +Last entries: Últimas entradas +Qty.: Cant. \ No newline at end of file diff --git a/client/order/src/prices-popover/style.scss b/client/order/src/prices-popover/style.scss new file mode 100644 index 000000000..d9d590661 --- /dev/null +++ b/client/order/src/prices-popover/style.scss @@ -0,0 +1,40 @@ +@import 'colors'; + +vn-order-prices-popover { + width: 150px; + display: block; + img[ng-src] { + height: 100%; + width: 100%; + } + + .prices, .data{ + width: 18em; + } + + vn-vertical.data{ + padding-right: 16px; + border-right: 1px solid $main-01; + } + + vn-vertical.prices{ + padding-left: 16px; + } + + vn-textfield{ + margin: 0!important; + } + + vn-one.number { + text-align: right; + padding-right: 8px; + } + vn-one.text{ + padding-top:10px!important; + } + + vn-horizontal.buttons-bar{ + padding-top: 16px; + text-align: center; + } +} \ No newline at end of file