From 76ec1fceaeb2d4bfb3c3d0b88067c4ebcd4a2828 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 21 Dec 2021 09:19:28 +0100 Subject: [PATCH] fear(smart-table): now shows the default order with the column arrows Refs: 3457 --- front/core/components/smart-table/index.js | 48 +++++++++++++++---- modules/entry/front/latest-buys/index.html | 5 +- .../monitor/front/index/tickets/index.html | 17 ++++--- .../monitor/front/index/tickets/style.scss | 2 +- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 93d5f9394..cb0304b34 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -44,16 +44,10 @@ export default class SmartTable extends Component { set model(value) { this._model = value; - if (value) + if (value) { this.$.model = value; - } - - get viewConfigId() { - return this._viewConfigId; - } - - set viewConfigId(value) { - this._viewConfigId = value; + this.defaultOrder(); + } } getDefaultViewConfig() { @@ -163,6 +157,40 @@ export default class SmartTable extends Component { } } + defaultOrder() { + const order = this.model.order; + if (!order) return; + + const orderFields = order.split(', '); + + for (const fieldString of orderFields) { + const field = fieldString.split(' '); + const fieldName = field[0]; + + let sortType = 'ASC'; + if (field.length === 2) + sortType = field[1]; + + const column = this.columns.find(column => column.field == fieldName); + if (column) { + this.sortCriteria.push({field: fieldName, sortType: sortType}); + + const isASC = sortType == 'ASC'; + const isDESC = sortType == 'DESC'; + + if (isDESC) { + column.element.classList.remove('asc'); + column.element.classList.add('desc'); + } + + if (isASC) { + column.element.classList.remove('desc'); + column.element.classList.add('asc'); + } + } + } + } + registerColumns() { const header = this.element.querySelector('thead > tr'); if (!header) return; @@ -175,7 +203,7 @@ export default class SmartTable extends Component { const columnElement = angular.element(column); const caption = columnElement.text().trim(); - this.columns.push({field, caption, index}); + this.columns.push({field, caption, index, element: column}); column.addEventListener('click', () => this.orderHandler(column)); } diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 32d26c3a4..4eeeeedce 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -1,6 +1,7 @@ @@ -34,8 +35,8 @@ Picture - - Identifier + + Item ID Packing diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 0d7f265f8..d1c18d52f 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -2,7 +2,7 @@ vn-id="model" url="SalesMonitors/salesFilter" limit="20" - order="shippedDate DESC, theoreticalhour, id"> + order="shipped DESC, theoreticalHour, id"> - - + + + + @@ -81,7 +83,8 @@ state: 'ticket.card.summary', params: {id: ticket.id}, target: '_blank' - }"> + }" + tabindex="2" vn-focus>