diff --git a/front/core/components/scroll-up/style.scss b/front/core/components/scroll-up/style.scss index 5f316e58c..c6dae16ef 100644 --- a/front/core/components/scroll-up/style.scss +++ b/front/core/components/scroll-up/style.scss @@ -6,4 +6,5 @@ vn-scroll-up { margin: $float-spacing; display: none; position: fixed; + z-index: 10 } \ No newline at end of file diff --git a/front/core/components/table/style.scss b/front/core/components/table/style.scss index 258061f1b..7da20fe82 100644 --- a/front/core/components/table/style.scss +++ b/front/core/components/table/style.scss @@ -25,10 +25,12 @@ vn-table { } } & > vn-tbody, + & > a.vn-tbody, & > tbody { display: table-row-group; } - & > vn-tfoot, + & > vn-tfoot, + & > .vn-tfoot, & > tfoot { border-top: 2px solid $color-spacer; display: table-footer-group @@ -39,7 +41,9 @@ vn-table { display: table-row; height: 48px; } - vn-thead, vn-tbody, vn-tfoot, + vn-thead, .vn-thead, + vn-tbody, .vn-tbody, + vn-tfoot, .vn-tfoot, thead, tbody, tfoot { & > * { display: table-row; @@ -126,7 +130,13 @@ vn-table { color: inherit; } } + a.vn-tbody { + &.clickable { + @extend %clickable; + } + } vn-tbody > *, + .vn-tbody > *, tbody > * { border-bottom: 1px solid $color-spacer-light; @@ -206,6 +216,7 @@ vn-table.scrollable > .vn-table, border-bottom: 2px solid $color-spacer; background-color: #FFF; position: sticky; + z-index: 9; top: 0 } } diff --git a/modules/monitor/back/methods/sales-monitor/deleteOrders.js b/modules/monitor/back/methods/sales-monitor/deleteOrders.js new file mode 100644 index 000000000..15a8d862a --- /dev/null +++ b/modules/monitor/back/methods/sales-monitor/deleteOrders.js @@ -0,0 +1,33 @@ +module.exports = Self => { + Self.remoteMethod('deleteOrders', { + description: 'Deletes the selected orders', + accessType: 'WRITE', + accepts: [{ + arg: 'deletes', + type: ['number'], + required: true, + description: 'The order ids to delete' + }], + returns: { + type: ['object'], + root: true + }, + http: { + path: `/deleteOrders`, + verb: 'POST' + } + }); + + Self.deleteOrders = async(deletes, options) => { + const models = Self.app.models; + + let myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + return models.Order.destroyAll({ + id: {inq: deletes} + }, myOptions); + }; +}; diff --git a/modules/monitor/back/methods/sales-monitor/specs/deleteOrders.spec.js b/modules/monitor/back/methods/sales-monitor/specs/deleteOrders.spec.js new file mode 100644 index 000000000..70394d082 --- /dev/null +++ b/modules/monitor/back/methods/sales-monitor/specs/deleteOrders.spec.js @@ -0,0 +1,21 @@ +const app = require('vn-loopback/server/server'); + +describe('SalesMonitor deleteOrders()', () => { + it('should return the deleted orders', async() => { + const tx = await app.models.Order.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const deletes = [1, 2]; + const result = await app.models.SalesMonitor.deleteOrders(deletes, options); + + expect(result.count).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/monitor/back/models/sales-monitor.js b/modules/monitor/back/models/sales-monitor.js index 63479cb9a..2750156de 100644 --- a/modules/monitor/back/models/sales-monitor.js +++ b/modules/monitor/back/models/sales-monitor.js @@ -2,4 +2,5 @@ module.exports = Self => { require('../methods/sales-monitor/salesFilter')(Self); require('../methods/sales-monitor/clientsFilter')(Self); require('../methods/sales-monitor/ordersFilter')(Self); + require('../methods/sales-monitor/deleteOrders')(Self); }; diff --git a/modules/monitor/front/index/clients/index.html b/modules/monitor/front/index/clients/index.html index bfa496199..f0c1b8f93 100644 --- a/modules/monitor/front/index/clients/index.html +++ b/modules/monitor/front/index/clients/index.html @@ -1,8 +1,9 @@ - + order="dated DESC" + auto-load="true"> diff --git a/modules/monitor/front/index/index.html b/modules/monitor/front/index/index.html index 937464891..e37dbd270 100644 --- a/modules/monitor/front/index/index.html +++ b/modules/monitor/front/index/index.html @@ -3,10 +3,8 @@ - - - + diff --git a/modules/monitor/front/index/locale/es.yml b/modules/monitor/front/index/locale/es.yml index b709d0922..1f69de222 100644 --- a/modules/monitor/front/index/locale/es.yml +++ b/modules/monitor/front/index/locale/es.yml @@ -1,4 +1,6 @@ Tickets monitor: Monitor de tickets Clients on website: Clientes activos en la web Recent order actions: Acciones recientes en pedidos -Search tickets: Buscar tickets \ No newline at end of file +Search tickets: Buscar tickets +Delete selected elements: Eliminar los elementos seleccionados +All the selected elements will be deleted. Are you sure you want to continue?: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? \ No newline at end of file diff --git a/modules/monitor/front/index/orders/index.html b/modules/monitor/front/index/orders/index.html index 9bb4d3608..3dd510dc8 100644 --- a/modules/monitor/front/index/orders/index.html +++ b/modules/monitor/front/index/orders/index.html @@ -9,6 +9,12 @@ Recent order actions + + - + + + + + Date Client Import - + + + + + {{::order.date_send | date: 'dd/MM/yyyy'}} @@ -42,7 +61,8 @@ {{::order.import | currency: 'EUR':2}} - + + {{::order.date_make | date: 'dd/MM/yyyy HH:mm'}} @@ -62,7 +82,7 @@ - +
+ + \ No newline at end of file diff --git a/modules/monitor/front/index/orders/index.js b/modules/monitor/front/index/orders/index.js index 0a4c8c04f..8b9489a9d 100644 --- a/modules/monitor/front/index/orders/index.js +++ b/modules/monitor/front/index/orders/index.js @@ -2,7 +2,31 @@ import ngModule from '../../module'; import Section from 'salix/components/section'; import './style.scss'; +export default class Controller extends Section { + get checked() { + const rows = this.$.model.data || []; + const checkedRows = []; + for (let row of rows) { + if (row.checked) + checkedRows.push(row.id); + } + + return checkedRows; + } + + get totalChecked() { + return this.checked.length; + } + + onDelete() { + const params = {deletes: this.checked}; + const query = `SalesMonitors/deleteOrders`; + this.$http.post(query, params).then( + () => this.$.model.refresh()); + } +} + ngModule.vnComponent('vnMonitorSalesOrders', { template: require('./index.html'), - controller: Section + controller: Controller }); diff --git a/modules/monitor/front/index/orders/index.spec.js b/modules/monitor/front/index/orders/index.spec.js new file mode 100644 index 000000000..109925358 --- /dev/null +++ b/modules/monitor/front/index/orders/index.spec.js @@ -0,0 +1,50 @@ +import './index.js'; +import crudModel from 'core/mocks/crud-model'; + +describe('Component vnMonitorSalesOrders', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('monitor')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + const $element = angular.element(''); + controller = $componentController('vnMonitorSalesOrders', {$element}); + controller.$.model = crudModel; + controller.$.model.data = [ + {id: 1, name: 'My item 1'}, + {id: 2, name: 'My item 2'}, + {id: 3, name: 'My item 3'} + ]; + })); + + describe('checked() getter', () => { + it('should return a the selected rows', () => { + const modelData = controller.$.model.data; + modelData[0].checked = true; + modelData[1].checked = true; + + const result = controller.checked; + + expect(result).toEqual(expect.arrayContaining([1, 2])); + }); + }); + + describe('onDelete()', () => { + it('should make a query and then call to the model refresh() method', () => { + jest.spyOn(controller.$.model, 'refresh'); + + const modelData = controller.$.model.data; + modelData[0].checked = true; + modelData[1].checked = true; + + const expectedParams = {deletes: [1, 2]}; + $httpBackend.expect('POST', 'SalesMonitors/deleteOrders', expectedParams).respond(200); + controller.onDelete(); + $httpBackend.flush(); + + expect(controller.$.model.refresh).toHaveBeenCalledWith(); + }); + }); +}); diff --git a/modules/monitor/front/index/orders/style.scss b/modules/monitor/front/index/orders/style.scss index 5f80472fe..f4d56010c 100644 --- a/modules/monitor/front/index/orders/style.scss +++ b/modules/monitor/front/index/orders/style.scss @@ -1,16 +1,18 @@ @import "variables"; vn-monitor-sales-orders { - .dark-row { - background-color: lighten($color-marginal, 15%); - color: gray; - - vn-td { - border-bottom: 2px solid $color-marginal + vn-table.scrollable { + height: 350px + } + + vn-table a.vn-tbody { + & > vn-tr:nth-child(2) { + color: gray; + + & > vn-td { + border-bottom: 2px solid $color-marginal; + font-size: 13px; + } } } - - vn-tbody vn-tr:nth-child(3) { - height: inherit - } } \ No newline at end of file diff --git a/modules/monitor/front/index/style.scss b/modules/monitor/front/index/style.scss index 4e0d9df2f..c020f60c7 100644 --- a/modules/monitor/front/index/style.scss +++ b/modules/monitor/front/index/style.scss @@ -17,4 +17,40 @@ vn-monitor-index { color: $color-font-secondary; text-align: center; } + + vn-vertical { + position: fixed; + width: 400px + } + + vn-horizontal { + flex-wrap: wrap + } +} + +@media (max-width:1500px) { + vn-monitor-index { + & > vn-horizontal { + flex-direction: column-reverse; + } + + & > vn-horizontal > vn-one { + flex: none; + width: 100%; + + & > vn-vertical { + position: initial; + flex-direction: row; + width: 100%; + + vn-monitor-sales-clients { + margin-right: 15px + } + + vn-table.scrollable { + height: 300px + } + } + } + } } \ No newline at end of file diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 8fc3e09d9..e410be4e5 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -30,7 +30,7 @@ - + @@ -49,7 +49,7 @@ + ui-sref="ticket.card.summary({id: {{::ticket.id}}})" target="_blank"> + class="vn-pt-xs">