2022-10-31 05:19:52 +08:00
|
|
|
import { addObservablesTo } from 'External/ko';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { getNotification } from 'Common/Translator';
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|
|
|
|
2022-02-24 21:01:41 +08:00
|
|
|
export class AccountPopupView extends AbstractViewPopup {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('Account');
|
2014-08-22 23:08:56 +08:00
|
|
|
|
2022-10-31 05:19:52 +08:00
|
|
|
addObservablesTo(this, {
|
2020-10-26 19:54:03 +08:00
|
|
|
isNew: true,
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2022-11-09 00:40:12 +08:00
|
|
|
name: '',
|
2020-10-26 19:54:03 +08:00
|
|
|
email: '',
|
|
|
|
password: '',
|
2014-10-22 00:49:15 +08:00
|
|
|
|
2020-10-26 19:54:03 +08:00
|
|
|
submitRequest: false,
|
|
|
|
submitError: '',
|
2021-03-24 05:57:40 +08:00
|
|
|
submitErrorAdditional: ''
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
2016-09-10 06:38:16 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2022-09-24 07:20:02 +08:00
|
|
|
submitForm(form) {
|
|
|
|
if (!this.submitRequest() && form.reportValidity()) {
|
|
|
|
const data = new FormData(form);
|
|
|
|
data.set('New', this.isNew() ? 1 : 0);
|
|
|
|
this.submitRequest(true);
|
|
|
|
Remote.request('AccountSetup', (iError, data) => {
|
|
|
|
this.submitRequest(false);
|
|
|
|
if (iError) {
|
|
|
|
this.submitError(getNotification(iError));
|
|
|
|
this.submitErrorAdditional(data?.ErrorMessageAdditional);
|
|
|
|
} else {
|
|
|
|
rl.app.accountsAndIdentities();
|
|
|
|
this.close();
|
2022-02-25 20:12:44 +08:00
|
|
|
}
|
2022-09-24 07:20:02 +08:00
|
|
|
}, data
|
|
|
|
);
|
2022-02-25 20:12:44 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2022-11-09 00:40:12 +08:00
|
|
|
onHide() {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.password('');
|
|
|
|
this.submitRequest(false);
|
|
|
|
this.submitError('');
|
|
|
|
this.submitErrorAdditional('');
|
|
|
|
}
|
2022-11-09 00:40:12 +08:00
|
|
|
|
|
|
|
onShow(account) {
|
|
|
|
let edit = account?.isAdditional();
|
|
|
|
this.isNew(!edit);
|
|
|
|
this.name(edit ? account.name : '');
|
|
|
|
this.email(edit ? account.email : '');
|
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|