mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Cleanup IdentityModel handling
This commit is contained in:
parent
bfffa750ca
commit
d495369688
5 changed files with 17 additions and 27 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import 'External/User/ko';
|
import 'External/User/ko';
|
||||||
|
|
||||||
import { SMAudio } from 'Common/Audio';
|
import { SMAudio } from 'Common/Audio';
|
||||||
import { isArray, pString, pInt } from 'Common/Utils';
|
import { isArray, pInt } from 'Common/Utils';
|
||||||
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
|
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -160,18 +160,7 @@ export class AppUser extends AbstractApp {
|
||||||
|
|
||||||
items = oData.Result.Identities;
|
items = oData.Result.Identities;
|
||||||
IdentityUserStore(isArray(items)
|
IdentityUserStore(isArray(items)
|
||||||
? items.map(identityData => {
|
? items.map(identityData => IdentityModel.reviveFromJson(identityData))
|
||||||
const identity = new IdentityModel(
|
|
||||||
pString(identityData.Id),
|
|
||||||
pString(identityData.Email)
|
|
||||||
);
|
|
||||||
identity.name(pString(identityData.Name));
|
|
||||||
identity.replyTo(pString(identityData.ReplyTo));
|
|
||||||
identity.bcc(pString(identityData.Bcc));
|
|
||||||
identity.signature(pString(identityData.Signature));
|
|
||||||
identity.signatureInsertBefore(!!identityData.SignatureInsertBefore);
|
|
||||||
return identity;
|
|
||||||
})
|
|
||||||
: []
|
: []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ export class IdentityModel extends AbstractModel {
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} email
|
* @param {string} email
|
||||||
*/
|
*/
|
||||||
constructor(id, email) {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
addObservablesTo(this, {
|
addObservablesTo(this, {
|
||||||
id: id || '',
|
id: '',
|
||||||
email: email,
|
email: '',
|
||||||
name: '',
|
name: '',
|
||||||
|
|
||||||
replyTo: '',
|
replyTo: '',
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ export class IdentityPopupView extends AbstractViewPopup {
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
data.set('Id', this.id);
|
data.set('Id', this.id);
|
||||||
data.set('Signature', this.signature());
|
data.set('Signature', this.signature());
|
||||||
data.set('SignatureInsertBefore', this.signatureInsertBefore() ? 1 : 0);
|
|
||||||
Remote.request('IdentityUpdate', iError => {
|
Remote.request('IdentityUpdate', iError => {
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
if (iError) {
|
if (iError) {
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,7 @@ class Identity implements \JsonSerializable
|
||||||
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
|
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
|
||||||
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
|
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
|
||||||
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
|
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
|
||||||
$this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ?
|
$this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']);
|
||||||
!empty($aData['SignatureInsertBefore']) : true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +111,7 @@ class Identity implements \JsonSerializable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to store
|
||||||
public function ToSimpleJSON(): array
|
public function ToSimpleJSON(): array
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
|
@ -129,13 +129,14 @@ class Identity implements \JsonSerializable
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'Id' => $this->sId,
|
'@Object' => 'Object/Identity',
|
||||||
'Email' => Utils::IdnToUtf8($this->sEmail),
|
'id' => $this->sId,
|
||||||
'Name' => $this->sName,
|
'email' => Utils::IdnToUtf8($this->sEmail),
|
||||||
'ReplyTo' => $this->sReplyTo,
|
'name' => $this->sName,
|
||||||
'Bcc' => $this->sBcc,
|
'replyTo' => $this->sReplyTo,
|
||||||
'Signature' => $this->sSignature,
|
'bcc' => $this->sBcc,
|
||||||
'SignatureInsertBefore' => $this->bSignatureInsertBefore
|
'signature' => $this->sSignature,
|
||||||
|
'signatureInsertBefore' => $this->bSignatureInsertBefore
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@
|
||||||
name: 'Checkbox',
|
name: 'Checkbox',
|
||||||
params: {
|
params: {
|
||||||
label: 'POPUPS_IDENTITY/LABEL_SIGNATURE_INSERT_BEFORE',
|
label: 'POPUPS_IDENTITY/LABEL_SIGNATURE_INSERT_BEFORE',
|
||||||
value: signatureInsertBefore
|
value: signatureInsertBefore,
|
||||||
|
name: 'SignatureInsertBefore'
|
||||||
}
|
}
|
||||||
}"></div>
|
}"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue