From eb0e6dd985b433f2a41a3d99f07f1761440cbcca Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Sep 2023 13:06:28 +0200 Subject: [PATCH 1/4] refs #6033 feat(VnLog): can use accountDescriptor --- front/salix/components/log/index.html | 5 ++++- front/salix/components/log/index.js | 5 ++++- .../front/descriptor-popover/index.html | 4 ++++ .../account/front/descriptor-popover/index.js | 9 ++++++++ modules/account/front/descriptor/index.js | 22 +++++++++++++++++++ modules/account/front/index.js | 1 + 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 modules/account/front/descriptor-popover/index.html create mode 100644 modules/account/front/descriptor-popover/index.js diff --git a/front/salix/components/log/index.html b/front/salix/components/log/index.html index 6a1367e28..c75030100 100644 --- a/front/salix/components/log/index.html +++ b/front/salix/components/log/index.html @@ -28,7 +28,7 @@ + ng-click="$ctrl.showDescriptor($event, userLog)"> @@ -260,3 +260,6 @@ + + diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index 176815eef..a77f0b984 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -362,7 +362,10 @@ export default class Controller extends Section { } } - showWorkerDescriptor(event, userLog) { + showDescriptor(event, userLog) { + if (this.$state.current.name.split('.')[0] == 'account') + return this.$.accountDescriptor.show(event.target, userLog.userFk); + if (userLog.user?.worker) this.$.workerDescriptor.show(event.target, userLog.userFk); } diff --git a/modules/account/front/descriptor-popover/index.html b/modules/account/front/descriptor-popover/index.html new file mode 100644 index 000000000..f3131a84b --- /dev/null +++ b/modules/account/front/descriptor-popover/index.html @@ -0,0 +1,4 @@ + + + + diff --git a/modules/account/front/descriptor-popover/index.js b/modules/account/front/descriptor-popover/index.js new file mode 100644 index 000000000..d7b052473 --- /dev/null +++ b/modules/account/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('vnAccountDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/account/front/descriptor/index.js b/modules/account/front/descriptor/index.js index 150c9d660..786870d36 100644 --- a/modules/account/front/descriptor/index.js +++ b/modules/account/front/descriptor/index.js @@ -24,6 +24,28 @@ class Controller extends Descriptor { .then(res => this.hasAccount = res.data.exists); } + loadData() { + const filter = { + where: {id: this.$params.id}, + include: { + relation: 'role', + scope: { + fields: ['id', 'name'] + } + } + }; + + return Promise.all([ + this.$http.get(`VnUsers/preview`, {filter}) + .then(res => { + const [user] = res.data; + this.user = user; + }), + this.$http.get(`Accounts/${this.$params.id}/exists`) + .then(res => this.hasAccount = res.data.exists) + ]); + } + onDelete() { return this.$http.delete(`VnUsers/${this.id}`) .then(() => this.$state.go('account.index')) diff --git a/modules/account/front/index.js b/modules/account/front/index.js index 695f36967..4d6aedcae 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -9,6 +9,7 @@ import './acl'; import './summary'; import './card'; import './descriptor'; +import './descriptor-popover'; import './search-panel'; import './create'; import './basic-data'; From 5a3094cd7021ca3b8c8ed3c8931136a4f04f1a40 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Sep 2023 13:24:30 +0200 Subject: [PATCH 2/4] refs #6033 feat(VnLog): better if --- front/salix/components/log/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/front/salix/components/log/index.js b/front/salix/components/log/index.js index a77f0b984..1edaa72ae 100644 --- a/front/salix/components/log/index.js +++ b/front/salix/components/log/index.js @@ -363,11 +363,10 @@ export default class Controller extends Section { } showDescriptor(event, userLog) { - if (this.$state.current.name.split('.')[0] == 'account') - return this.$.accountDescriptor.show(event.target, userLog.userFk); + if (userLog.user?.worker && this.$state.current.name.split('.')[0] != 'account') + return this.$.workerDescriptor.show(event.target, userLog.userFk); - if (userLog.user?.worker) - this.$.workerDescriptor.show(event.target, userLog.userFk); + this.$.accountDescriptor.show(event.target, userLog.userFk); } } From e36f98195c413f65c67486ae4df02ca06354cccc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 26 Sep 2023 08:15:19 +0200 Subject: [PATCH 3/4] refs #6033 feat: create user-photo component for worker and user descriptor --- front/salix/components/index.js | 1 + front/salix/components/user-photo/index.html | 15 +++++++++ front/salix/components/user-photo/index.js | 31 +++++++++++++++++++ .../salix/components/user-photo/locale/es.yml | 6 ++++ modules/account/front/descriptor/index.html | 3 ++ modules/worker/front/descriptor/index.html | 16 +--------- modules/worker/front/descriptor/index.js | 11 ------- 7 files changed, 57 insertions(+), 26 deletions(-) create mode 100644 front/salix/components/user-photo/index.html create mode 100644 front/salix/components/user-photo/index.js create mode 100644 front/salix/components/user-photo/locale/es.yml diff --git a/front/salix/components/index.js b/front/salix/components/index.js index 555a18450..f632904c4 100644 --- a/front/salix/components/index.js +++ b/front/salix/components/index.js @@ -18,6 +18,7 @@ import './section'; import './summary'; import './topbar/topbar'; import './user-popover'; +import './user-photo'; import './upload-photo'; import './bank-entity'; import './log'; diff --git a/front/salix/components/user-photo/index.html b/front/salix/components/user-photo/index.html new file mode 100644 index 000000000..2d7bbcb82 --- /dev/null +++ b/front/salix/components/user-photo/index.html @@ -0,0 +1,15 @@ +
+ + + +
+ + + diff --git a/front/salix/components/user-photo/index.js b/front/salix/components/user-photo/index.js new file mode 100644 index 000000000..23190c1b6 --- /dev/null +++ b/front/salix/components/user-photo/index.js @@ -0,0 +1,31 @@ +import ngModule from '../../module'; + +export default class Controller { + constructor($element, $, $rootScope) { + Object.assign(this, { + $element, + $, + $rootScope, + }); + } + + onUploadResponse() { + const timestamp = Date.vnNew().getTime(); + const src = this.$rootScope.imagePath('user', '520x520', this.userId); + const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.userId); + const newSrc = `${src}&t=${timestamp}`; + const newZoomSrc = `${zoomSrc}&t=${timestamp}`; + + this.$.photo.setAttribute('src', newSrc); + this.$.photo.setAttribute('zoom-image', newZoomSrc); + } +} +Controller.$inject = ['$element', '$scope', '$rootScope']; + +ngModule.vnComponent('vnUserPhoto', { + template: require('./index.html'), + controller: Controller, + bindings: { + userId: '@?', + } +}); diff --git a/front/salix/components/user-photo/locale/es.yml b/front/salix/components/user-photo/locale/es.yml new file mode 100644 index 000000000..7518a98bc --- /dev/null +++ b/front/salix/components/user-photo/locale/es.yml @@ -0,0 +1,6 @@ +My account: Mi cuenta +Local warehouse: Almacén local +Local bank: Banco local +Local company: Empresa local +User warehouse: Almacén del usuario +User company: Empresa del usuario \ No newline at end of file diff --git a/modules/account/front/descriptor/index.html b/modules/account/front/descriptor/index.html index 381b2991c..94497aaa9 100644 --- a/modules/account/front/descriptor/index.html +++ b/modules/account/front/descriptor/index.html @@ -2,6 +2,9 @@ module="account" description="$ctrl.user.nickname" summary="$ctrl.$.summary"> + + + -
- - - -
+
@@ -76,8 +67,3 @@ - - - diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index a53528ef2..0214f8500 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -71,17 +71,6 @@ class Controller extends Descriptor { return this.getData(`Workers/${this.id}`, {filter}) .then(res => this.entity = res.data); } - - onUploadResponse() { - const timestamp = Date.vnNew().getTime(); - const src = this.$rootScope.imagePath('user', '520x520', this.worker.id); - const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id); - const newSrc = `${src}&t=${timestamp}`; - const newZoomSrc = `${zoomSrc}&t=${timestamp}`; - - this.$.photo.setAttribute('src', newSrc); - this.$.photo.setAttribute('zoom-image', newZoomSrc); - } } Controller.$inject = ['$element', '$scope', '$rootScope']; From 3ffc4e39f1d214e5f94f3fa7c4cf0fe15bdb0c7e Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 26 Sep 2023 08:19:17 +0200 Subject: [PATCH 4/4] refs #6033 add changeLog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79688cb56..373a6ec71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2340.01] - 2023-10-05 ### Added +- (Usuarios -> Foto) Se muestra la foto del trabajador + ### Changed ### Fixed +- (Usuarios -> Historial) Abre el descriptor del usuario correctamente ## [2338.01] - 2023-09-21