salix/modules/account/front/aliases/index.js

52 lines
1.3 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
$onInit() {
this.refresh();
}
refresh() {
let filter = {
where: {account: this.$params.id},
include: {
relation: 'alias',
scope: {
fields: ['id', 'alias', 'description']
}
}
};
return this.$http.get(`MailAliasAccounts`, {filter})
.then(res => this.$.data = res.data);
}
onAddClick() {
this.$.dialog.show();
}
onAddSave() {
return this.$http.post(`MailAliasAccounts/${this.$params.id}/addAlias`, this.addData)
.then(() => this.refresh())
.then(() => this.vnApp.showSuccess(
this.$t('Subscribed to alias!'))
);
}
onRemove(row) {
2023-07-11 10:33:44 +00:00
const params = {
mailAlias: row.mailAlias
};
return this.$http.post(`MailAliasAccounts/${this.$params.id}/removeAlias`, params)
2023-07-11 10:33:44 +00:00
.then(() => this.refresh())
2023-07-11 11:22:54 +00:00
.then(() => this.vnApp.showSuccess(this.$t('Data saved!')));
}
}
ngModule.component('vnUserAliases', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnUserCard'
}
});