mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
Cleanup Identity edit window
This commit is contained in:
parent
d495369688
commit
0f82ad1109
2 changed files with 27 additions and 49 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
|
|
@ -6,49 +7,34 @@ import Remote from 'Remote/User/Fetch';
|
|||
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
import { IdentityModel } from 'Model/Identity';
|
||||
|
||||
export class IdentityPopupView extends AbstractViewPopup {
|
||||
constructor() {
|
||||
super('Identity');
|
||||
|
||||
this.id = '';
|
||||
addObservablesTo(this, {
|
||||
id: '',
|
||||
edit: false,
|
||||
owner: false,
|
||||
|
||||
email: '',
|
||||
emailFocused: false,
|
||||
|
||||
name: '',
|
||||
nameFocused: false,
|
||||
|
||||
replyTo: '',
|
||||
replyToFocused: false,
|
||||
showReplyTo: false,
|
||||
|
||||
bcc: '',
|
||||
bccFocused: false,
|
||||
bccHasError: false,
|
||||
showBcc: false,
|
||||
|
||||
signature: '',
|
||||
signatureInsertBefore: false,
|
||||
|
||||
showBcc: false,
|
||||
showReplyTo: false,
|
||||
|
||||
submitRequest: false,
|
||||
submitError: ''
|
||||
});
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
replyTo: value => {
|
||||
if (false === this.showReplyTo() && value.length) {
|
||||
this.showReplyTo(true);
|
||||
}
|
||||
},
|
||||
bcc: value => {
|
||||
if (false === this.showBcc() && value.length) {
|
||||
this.showBcc(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
this.email.valueHasMutated();
|
||||
this.replyTo.valueHasMutated();
|
||||
|
|
@ -61,8 +47,9 @@ export class IdentityPopupView extends AbstractViewPopup {
|
|||
this.signature?.__fetchEditorValue?.();
|
||||
this.submitRequest(true);
|
||||
const data = new FormData(form);
|
||||
data.set('Id', this.id);
|
||||
data.set('Id', this.id());
|
||||
data.set('Signature', this.signature());
|
||||
data.set('SignatureInsertBefore', this.signatureInsertBefore() ? 1 : 0);
|
||||
Remote.request('IdentityUpdate', iError => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
|
|
@ -88,32 +75,23 @@ export class IdentityPopupView extends AbstractViewPopup {
|
|||
|
||||
if (identity) {
|
||||
this.edit(true);
|
||||
|
||||
this.id = identity.id() || '';
|
||||
this.name(identity.name());
|
||||
this.email(identity.email());
|
||||
this.replyTo(identity.replyTo());
|
||||
this.bcc(identity.bcc());
|
||||
this.signature(identity.signature());
|
||||
this.signatureInsertBefore(identity.signatureInsertBefore());
|
||||
|
||||
this.owner(!this.id);
|
||||
} else {
|
||||
this.edit(false);
|
||||
|
||||
this.id = Jua.randomId();
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
this.signature('');
|
||||
this.signatureInsertBefore(false);
|
||||
|
||||
this.owner(false);
|
||||
identity = new IdentityModel;
|
||||
identity.id(Jua.randomId());
|
||||
}
|
||||
this.id(identity.id() || '');
|
||||
this.name(identity.name());
|
||||
this.email(identity.email());
|
||||
this.replyTo(identity.replyTo());
|
||||
this.showReplyTo(0 < identity.replyTo().length);
|
||||
this.bcc(identity.bcc());
|
||||
this.showBcc(0 < identity.bcc().length);
|
||||
this.signature(identity.signature());
|
||||
this.signatureInsertBefore(identity.signatureInsertBefore());
|
||||
}
|
||||
|
||||
afterShow() {
|
||||
this.owner() || this.emailFocused(true);
|
||||
this.id() ? this.emailFocused(true) : this.nameFocused(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,29 +12,29 @@
|
|||
<div class="control-group">
|
||||
<label data-i18n="GLOBAL/EMAIL"></label>
|
||||
<div>
|
||||
<div class="textEmail" data-bind="text: email, visible: owner"></div>
|
||||
<div class="textEmail" data-bind="text: email, visible: !id()"></div>
|
||||
<input name="Email" type="email" class="input-xlarge" autofocus=""
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off"
|
||||
data-bind="visible: !owner(), value: email, hasfocus: emailFocused, attr: {required: !owner()}">
|
||||
data-bind="visible: id, value: email, hasfocus: emailFocused, attr: {required: id}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="GLOBAL/NAME"></label>
|
||||
<input name="Name" type="text" class="input-xlarge"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off"
|
||||
data-bind="value: name">
|
||||
data-bind="value: name, hasfocus: nameFocused">
|
||||
</div>
|
||||
<div class="control-group" data-bind="visible: showReplyTo">
|
||||
<label data-i18n="GLOBAL/REPLY_TO"></label>
|
||||
<input name="ReplyTo" type="email" class="inputReplyTo input-xlarge"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off"
|
||||
data-bind="value: replyTo, hasfocus: replyToFocused">
|
||||
data-bind="value: replyTo">
|
||||
</div>
|
||||
<div class="control-group" data-bind="visible: showBcc">
|
||||
<label data-i18n="GLOBAL/BCC"></label>
|
||||
<input name="Bcc" type="email" class="inputBcc input-xlarge"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off"
|
||||
data-bind="value: bcc, hasfocus: bccFocused">
|
||||
data-bind="value: bcc">
|
||||
</div>
|
||||
<div class="control-group" data-bind="visible: !showReplyTo() || !showBcc()">
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue