From 120aa3e16941199683e65164822358a297038ee4 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 3 Oct 2024 07:48:41 +0200 Subject: [PATCH] fix: recover entry descriptor and deleted code --- front/core/services/app.js | 11 + .../entry/front/descriptor-popover/index.html | 3 + .../entry/front/descriptor-popover/index.js | 9 + modules/entry/front/descriptor/index.html | 65 ++++++ modules/entry/front/descriptor/index.js | 99 +++++++++ modules/entry/front/index.js | 3 + modules/entry/front/routes.json | 90 ++++++++ modules/entry/front/summary/index.html | 195 ++++++++++++++++++ modules/entry/front/summary/index.js | 33 +++ modules/entry/front/summary/style.scss | 30 +++ modules/item/front/routes.json | 2 +- modules/travel/front/routes.json | 2 +- 12 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 modules/entry/front/descriptor-popover/index.html create mode 100644 modules/entry/front/descriptor-popover/index.js create mode 100644 modules/entry/front/descriptor/index.html create mode 100644 modules/entry/front/descriptor/index.js create mode 100644 modules/entry/front/summary/index.html create mode 100644 modules/entry/front/summary/index.js create mode 100644 modules/entry/front/summary/style.scss diff --git a/front/core/services/app.js b/front/core/services/app.js index cec7bea7f..210b307d6 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,6 +66,17 @@ export default class App { ]} }; + if (this.logger.$params.q) { + let tableValue = this.logger.$params.q; + const q = JSON.parse(tableValue); + if (typeof q === 'number') + tableValue = JSON.stringify({id: tableValue}); + newRoute = newRoute.concat(`?table=${tableValue}`); + } + + if (this.logger.$params.id) + newRoute = newRoute.concat(`${this.logger.$params.id}`); + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) diff --git a/modules/entry/front/descriptor-popover/index.html b/modules/entry/front/descriptor-popover/index.html new file mode 100644 index 000000000..23f641632 --- /dev/null +++ b/modules/entry/front/descriptor-popover/index.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/entry/front/descriptor-popover/index.js b/modules/entry/front/descriptor-popover/index.js new file mode 100644 index 000000000..d79aed03e --- /dev/null +++ b/modules/entry/front/descriptor-popover/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import DescriptorPopover from 'salix/components/descriptor-popover'; + +class Controller extends DescriptorPopover {} + +ngModule.vnComponent('vnEntryDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html new file mode 100644 index 000000000..3354d4155 --- /dev/null +++ b/modules/entry/front/descriptor/index.html @@ -0,0 +1,65 @@ + + + + Show entry report + + + +
+ + + + + + +
+
+ + + + +
+ +
+
+ + + \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js new file mode 100644 index 000000000..3452a6d34 --- /dev/null +++ b/modules/entry/front/descriptor/index.js @@ -0,0 +1,99 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + get entry() { + return this.entity; + } + + set entry(value) { + this.entity = value; + } + + get travelFilter() { + let travelFilter; + const entryTravel = this.entry && this.entry.travel; + + if (entryTravel && entryTravel.agencyModeFk) { + travelFilter = this.entry && JSON.stringify({ + agencyModeFk: entryTravel.agencyModeFk + }); + } + return travelFilter; + } + + get entryFilter() { + let entryTravel = this.entry && this.entry.travel; + + if (!entryTravel || !entryTravel.landed) return null; + + const date = new Date(entryTravel.landed); + date.setHours(0, 0, 0, 0); + + const from = new Date(date.getTime()); + from.setDate(from.getDate() - 10); + + const to = new Date(date.getTime()); + to.setDate(to.getDate() + 10); + + return JSON.stringify({ + supplierFk: this.entry.supplierFk, + from, + to + }); + } + + loadData() { + const filter = { + include: [ + { + relation: 'travel', + scope: { + fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], + include: [ + { + relation: 'agency', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseOut', + scope: { + fields: ['name'] + } + }, + { + relation: 'warehouseIn', + scope: { + fields: ['name'] + } + } + ] + } + }, + { + relation: 'supplier', + scope: { + fields: ['id', 'nickname'] + } + } + ] + }; + + return this.getData(`Entries/${this.id}`, {filter}) + .then(res => this.entity = res.data); + } + + showEntryReport() { + this.vnReport.show(`Entries/${this.id}/entry-order-pdf`); + } +} + +ngModule.vnComponent('vnEntryDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index a7209a0bd..0f2208862 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -1,3 +1,6 @@ export * from './module'; import './main'; +import './descriptor'; +import './descriptor-popover'; +import './summary'; diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 53c599cf1..a2e70e37d 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -8,6 +8,12 @@ "main": [ {"state": "entry.index", "icon": "icon-entry"}, {"state": "entry.latestBuys", "icon": "contact_support"} + ], + "card": [ + {"state": "entry.card.basicData", "icon": "settings"}, + {"state": "entry.card.buy.index", "icon": "icon-lines"}, + {"state": "entry.card.observation", "icon": "insert_drive_file"}, + {"state": "entry.card.log", "icon": "history"} ] }, "keybindings": [ @@ -27,6 +33,90 @@ "component": "vn-entry-index", "description": "Entries", "acl": ["buyer", "administrative"] + }, + { + "url": "/latest-buys?q", + "state": "entry.latestBuys", + "component": "vn-entry-latest-buys", + "description": "Latest buys", + "acl": ["buyer", "administrative"] + }, + { + "url": "/create?supplierFk&travelFk&companyFk", + "state": "entry.create", + "component": "vn-entry-create", + "description": "New entry", + "acl": ["buyer", "administrative"] + }, + { + "url": "/:id", + "state": "entry.card", + "abstract": true, + "component": "vn-entry-card" + }, + { + "url": "/summary", + "state": "entry.card.summary", + "component": "vn-entry-summary", + "description": "Summary", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url": "/basic-data", + "state": "entry.card.basicData", + "component": "vn-entry-basic-data", + "description": "Basic data", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url": "/observation", + "state": "entry.card.observation", + "component": "vn-entry-observation", + "description": "Notes", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url" : "/log", + "state": "entry.card.log", + "component": "vn-entry-log", + "description": "Log", + "acl": ["buyer", "administrative"] + }, + { + "url": "/buy", + "state": "entry.card.buy", + "abstract": true, + "component": "ui-view", + "acl": ["buyer"] + }, + { + "url" : "/index", + "state": "entry.card.buy.index", + "component": "vn-entry-buy-index", + "description": "Buys", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer", "administrative"] + }, + { + "url" : "/import", + "state": "entry.card.buy.import", + "component": "vn-entry-buy-import", + "description": "Import buys", + "params": { + "entry": "$ctrl.entry" + }, + "acl": ["buyer"] } ] } diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html new file mode 100644 index 000000000..22ea87bdf --- /dev/null +++ b/modules/entry/front/summary/index.html @@ -0,0 +1,195 @@ + + + +
+ + + + #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}} +
+ + + + + + + + + + + + + + + + + {{$ctrl.entryData.travel.ref}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Buys

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
QuantityStickersPackageWeightPackingGroupingBuying valueImportPVP
{{::line.quantity}}{{::line.stickers | dashIfEmpty}}{{::line.packagingFk | dashIfEmpty}}{{::line.weight}} + + {{::line.packing | dashIfEmpty}} + + + + {{::line.grouping | dashIfEmpty}} + + + {{::line.buyingValue | currency: 'EUR':2}}{{::line.quantity * line.buyingValue | currency: 'EUR':2}}{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}
+ + {{::line.item.itemType.code}} + + + + {{::line.item.id}} + + + + {{::line.item.size}} + + + + {{::line.item.minPrice | currency: 'EUR':2}} + + +
+ {{::line.item.name}} + +

{{::line.item.subName}}

+
+
+ + +
+ + +
+
+
+ + + + diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js new file mode 100644 index 000000000..6e18bc959 --- /dev/null +++ b/modules/entry/front/summary/index.js @@ -0,0 +1,33 @@ +import ngModule from '../module'; +import './style.scss'; +import Summary from 'salix/components/summary'; + +class Controller extends Summary { + get entry() { + if (!this._entry) + return this.$params; + + return this._entry; + } + + set entry(value) { + this._entry = value; + + if (value && value.id) + this.getEntryData(); + } + + getEntryData() { + return this.$http.get(`Entries/${this.entry.id}/getEntry`).then(response => { + this.entryData = response.data; + }); + } +} + +ngModule.vnComponent('vnEntrySummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss new file mode 100644 index 000000000..1d5b22e30 --- /dev/null +++ b/modules/entry/front/summary/style.scss @@ -0,0 +1,30 @@ +@import "variables"; + + +vn-entry-summary .summary { + max-width: $width-lg; + + .dark-row { + background-color: lighten($color-marginal, 10%); + } + + tbody tr:nth-child(1) { + border-top: $border-thin; + } + + tbody tr:nth-child(1), + tbody tr:nth-child(2) { + border-left: $border-thin; + border-right: $border-thin + } + + tbody tr:nth-child(3) { + height: inherit + } + + tr { + margin-bottom: 10px; + } +} + +$color-font-link-medium: lighten($color-font-link, 20%) \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 4b7cd1490..05b887a96 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "icon-item", "validations" : true, - "dependencies": ["worker", "client", "ticket"], + "dependencies": ["worker", "client", "ticket", "entry"], "menus": { "main": [ {"state": "item.index", "icon": "icon-item"}, diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index 5a63620d4..ccdc657d9 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -3,7 +3,7 @@ "name": "Travels", "icon": "local_airport", "validations": true, - "dependencies": ["worker"], + "dependencies": ["worker", "entry"], "menus": { "main": [ {"state": "travel.index", "icon": "local_airport"},