From 9b5e9a617dd9cb9ac7a17984d3eae499596de94d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 20 Jan 2022 08:31:30 +0100 Subject: [PATCH 1/4] feat(entry_basic-data): add new filter in travels --- modules/entry/front/basic-data/index.html | 99 ++++++++++++++++++++++- modules/entry/front/basic-data/index.js | 62 +++++++++++++- modules/entry/front/basic-data/style.scss | 3 + 3 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 modules/entry/front/basic-data/style.scss diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 4b7661a8f..f75834045 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -35,6 +35,13 @@ {{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) → {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}}) + + + + @@ -121,4 +128,94 @@ ng-click="watcher.loadOriginalData()"> - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Agency + Warehouse Out + Warehouse In + Shipped + Landed + + + + + + + {{::travel.id}} + + + {{::travel.agency.name}} + {{::travel.warehouseOut.name}} + {{::travel.warehouseIn.name}} + {{::travel.shipped | date: 'dd/MM/yyyy'}} + {{::travel.landed | date: 'dd/MM/yyyy'}} + + + + + + + + \ No newline at end of file diff --git a/modules/entry/front/basic-data/index.js b/modules/entry/front/basic-data/index.js index 141a365fa..80870c3f3 100644 --- a/modules/entry/front/basic-data/index.js +++ b/modules/entry/front/basic-data/index.js @@ -1,10 +1,68 @@ import ngModule from '../module'; import Section from 'salix/components/section'; +import './style.scss'; +class Controller extends Section { + showFilterDialog(travel) { + this.activeTravel = travel; + this.travelFilterParams = {}; + this.travelFilter = { + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + } + ] + }; + + this.$.filterDialog.show(); + } + + selectTravel(id) { + this.entry.travelFk = id; + this.$.filterDialog.hide(); + } + + filter() { + const filter = this.travelFilter; + const params = this.travelFilterParams; + const where = {}; + for (let key in params) { + const value = params[key]; + if (!value) continue; + + switch (key) { + case 'agencyFk': + case 'warehouseInFk': + case 'warehouseOutFk': + case 'shipped': + case 'landed': + where[key] = value; + } + } + + filter.where = where; + this.$.travelsModel.applyFilter(filter); + } +} ngModule.vnComponent('vnEntryBasicData', { template: require('./index.html'), - controller: Section, bindings: { entry: '<' - } + }, + controller: Controller }); diff --git a/modules/entry/front/basic-data/style.scss b/modules/entry/front/basic-data/style.scss new file mode 100644 index 000000000..508aa9091 --- /dev/null +++ b/modules/entry/front/basic-data/style.scss @@ -0,0 +1,3 @@ +.travelFilter{ + width: 950px; +} From 74b7b0592eae601da2d6a8b0df8bf693aea33351 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 20 Jan 2022 09:34:53 +0100 Subject: [PATCH 2/4] feat(smartTag): added sort priority between multiple sorting Refs: 3528 --- front/core/components/smart-table/index.js | 33 +++++++++++++++++-- front/core/components/smart-table/style.scss | 32 ++++++++++++------ .../monitor/front/index/tickets/index.html | 2 +- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index cb0304b34..8d96ffd79 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -171,9 +171,10 @@ export default class SmartTable extends Component { if (field.length === 2) sortType = field[1]; + const priority = this.sortCriteria.length + 1; const column = this.columns.find(column => column.field == fieldName); if (column) { - this.sortCriteria.push({field: fieldName, sortType: sortType}); + this.sortCriteria.push({field: fieldName, sortType: sortType, priority: priority}); const isASC = sortType == 'ASC'; const isDESC = sortType == 'DESC'; @@ -187,6 +188,8 @@ export default class SmartTable extends Component { column.element.classList.remove('desc'); column.element.classList.add('asc'); } + + this.setPriority(column.element, priority); } } } @@ -241,9 +244,13 @@ export default class SmartTable extends Component { const isDESC = existingCriteria && existingCriteria.sortType == 'DESC'; if (!existingCriteria) { - this.sortCriteria.push({field: field, sortType: 'ASC'}); + const priority = this.sortCriteria.length + 1; + + this.sortCriteria.push({field: field, sortType: 'ASC', priority: 1}); element.classList.remove('desc'); element.classList.add('asc'); + + this.setPriority(element, priority); } if (isDESC) { @@ -252,6 +259,8 @@ export default class SmartTable extends Component { }), 1); element.classList.remove('desc'); element.classList.remove('asc'); + + element.querySelector('sort-priority').remove(); } if (isASC) { @@ -260,9 +269,29 @@ export default class SmartTable extends Component { element.classList.add('desc'); } + let priority = 0; + for (const criteria of this.sortCriteria) { + const column = this.columns.find(column => column.field == criteria.field); + if (column) { + criteria.priority = priority; + priority++; + + column.element.querySelector('sort-priority').remove(); + + this.setPriority(column.element, priority); + } + } + this.applySort(); } + setPriority(column, priority) { + const sortPriority = document.createElement('sort-priority'); + sortPriority.setAttribute('class', 'sort-priority'); + sortPriority.innerHTML = priority; + column.appendChild(sortPriority); + } + displaySearch() { const header = this.element.querySelector('thead > tr'); if (!header) return; diff --git a/front/core/components/smart-table/style.scss b/front/core/components/smart-table/style.scss index 1e882f679..bf1c14082 100644 --- a/front/core/components/smart-table/style.scss +++ b/front/core/components/smart-table/style.scss @@ -9,7 +9,7 @@ smart-table { } th[field][number] { - & > :before { + & > span:before { vertical-align: middle; font-family: 'Material Icons'; content: 'arrow_downward'; @@ -19,26 +19,26 @@ smart-table { } - &.asc > :before, &.desc > :before { + &.asc > span:before, &.desc > span:before { color: $color-font; opacity: 1; } - &.asc > :before { + &.asc > span:before { content: 'arrow_upward'; } - &.desc > :before { + &.desc > span:before { content: 'arrow_downward'; } - &:hover > :before { + &:hover > span:before { opacity: 1; } } th[field]:not([number]) { - & > :after { + & > span:after { vertical-align: middle; font-family: 'Material Icons'; content: 'arrow_downward'; @@ -48,20 +48,20 @@ smart-table { } - &.asc > :after, &.desc > :after { + &.asc > span:after, &.desc > span:after { color: $color-font; opacity: 1; } - &.asc > :after { + &.asc > span:after { content: 'arrow_upward'; } - &.desc > :after { + &.desc > span:after { content: 'arrow_downward'; } - &:hover > :after { + &:hover > span:after { opacity: 1; } } @@ -143,4 +143,16 @@ smart-table { flex: initial; width: 33% } +} +.sort-priority { + background-color: $color-font-bg-marginal; + border-radius: 50%; + padding: 2px 5px; + display: inline-block; + text-align: center; + width: 7px; + height: 13px; + + font-size: 10px; + color: $color-font-bg } \ 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 065a591c3..52d5924de 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="shipped DESC, theoreticalHour, id"> + order="nickname"> Date: Thu, 20 Jan 2022 09:53:40 +0100 Subject: [PATCH 3/4] Updated unit tests --- front/core/components/smart-table/index.spec.js | 5 ++++- loopback/locale/en.json | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.spec.js b/front/core/components/smart-table/index.spec.js index 94edd45bb..b947f3ad1 100644 --- a/front/core/components/smart-table/index.spec.js +++ b/front/core/components/smart-table/index.spec.js @@ -96,9 +96,10 @@ describe('Component smartTable', () => { expect(firstSortCriteria.field).toEqual('id'); expect(firstSortCriteria.sortType).toEqual('ASC'); + expect(firstSortCriteria.priority).toEqual(1); }); - it('should insert two new objects to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => { + it('should add new entries to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => { const element = document.createElement('div'); controller.model = {order: 'test1, id DESC'}; controller.columns = [ @@ -114,8 +115,10 @@ describe('Component smartTable', () => { expect(firstSortCriteria.field).toEqual('test1'); expect(firstSortCriteria.sortType).toEqual('ASC'); + expect(firstSortCriteria.priority).toEqual(1); expect(secondSortCriteria.field).toEqual('id'); expect(secondSortCriteria.sortType).toEqual('DESC'); + expect(firstSortCriteria.priority).toEqual(2); }); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 15c65fd89..7d675cb13 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -119,5 +119,6 @@ "The PDF document does not exists": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", "This item is not available": "This item is not available", "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", - "The type of business must be filled in basic data": "The type of business must be filled in basic data" + "The type of business must be filled in basic data": "The type of business must be filled in basic data", + "The worker has hours recorded that day": "The worker has hours recorded that day" } \ No newline at end of file From 7a5e7b4c20869abbaf37de4ea944c18343ebe4b5 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 20 Jan 2022 10:43:03 +0100 Subject: [PATCH 4/4] Ammends --- front/core/components/smart-table/index.js | 2 +- front/core/components/smart-table/index.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 8d96ffd79..b0b4d90dc 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -246,7 +246,7 @@ export default class SmartTable extends Component { if (!existingCriteria) { const priority = this.sortCriteria.length + 1; - this.sortCriteria.push({field: field, sortType: 'ASC', priority: 1}); + this.sortCriteria.push({field: field, sortType: 'ASC', priority: priority}); element.classList.remove('desc'); element.classList.add('asc'); diff --git a/front/core/components/smart-table/index.spec.js b/front/core/components/smart-table/index.spec.js index b947f3ad1..720e24c7e 100644 --- a/front/core/components/smart-table/index.spec.js +++ b/front/core/components/smart-table/index.spec.js @@ -116,9 +116,10 @@ describe('Component smartTable', () => { expect(firstSortCriteria.field).toEqual('test1'); expect(firstSortCriteria.sortType).toEqual('ASC'); expect(firstSortCriteria.priority).toEqual(1); + expect(secondSortCriteria.field).toEqual('id'); expect(secondSortCriteria.sortType).toEqual('DESC'); - expect(firstSortCriteria.priority).toEqual(2); + expect(secondSortCriteria.priority).toEqual(2); }); });