refs #6033 feat(VnLog): can use accountDescriptor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-09-25 13:06:28 +02:00
parent d43b70c971
commit eb0e6dd985
6 changed files with 44 additions and 2 deletions

View File

@ -28,7 +28,7 @@
<vn-avatar
ng-class="::{system: !userLog.user}"
val="{{::userLog.user ? userLog.user.nickname : $ctrl.$t('System')}}"
ng-click="$ctrl.showWorkerDescriptor($event, userLog)">
ng-click="$ctrl.showDescriptor($event, userLog)">
<img
ng-if="::userLog.user.image"
ng-src="/api/Images/user/160x160/{{::userLog.userFk}}/download?access_token={{::$ctrl.vnToken.token}}">
@ -260,3 +260,6 @@
<vn-worker-descriptor-popover
vn-id="worker-descriptor">
</vn-worker-descriptor-popover>
<vn-account-descriptor-popover
vn-id="account-descriptor">
</vn-account-descriptor-popover>

View File

@ -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);
}

View File

@ -0,0 +1,4 @@
<slot-descriptor>
<vn-user-descriptor>
</vn-user-descriptor>
</slot-descriptor>

View File

@ -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
});

View File

@ -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'))

View File

@ -9,6 +9,7 @@ import './acl';
import './summary';
import './card';
import './descriptor';
import './descriptor-popover';
import './search-panel';
import './create';
import './basic-data';