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() {
2023-07-12 13:07:06 +00:00
this.addData = {account: this.$params.id};
this.$.dialog.show();
}
onAddSave() {
2023-07-12 13:07:06 +00:00
return this.$http.post(`MailAliasAccounts`, this.addData)
.then(() => this.refresh())
.then(() => this.vnApp.showSuccess(
this.$t('Subscribed to alias!'))
);
}
onRemove(row) {
2023-07-12 13:07:06 +00:00
return this.$http.delete(`MailAliasAccounts/${row.id}`)
.then(() => {
this.$.data.splice(this.$.data.indexOf(row), 1);
this.vnApp.showSuccess(this.$t('Unsubscribed from alias!'));
});
}
}
ngModule.component('vnUserAliases', {
template: require('./index.html'),
controller: Controller,
require: {
card: '^vnUserCard'
}
});