mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,24 +1,22 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, isNormal} from 'Common/Utils';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
import {HtmlEditor} from 'Common/HtmlEditor';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { trim, isNormal } from 'Common/Utils';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { HtmlEditor } from 'Common/HtmlEditor';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
import { popup, command } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
@popup({
|
||||
name: 'View/Popup/Template',
|
||||
templateID: 'PopupsTemplate'
|
||||
})
|
||||
class TemplatePopupView extends AbstractViewNext
|
||||
{
|
||||
class TemplatePopupView extends AbstractViewNext {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
|
@ -49,40 +47,35 @@ class TemplatePopupView extends AbstractViewNext
|
|||
|
||||
@command((self) => !self.submitRequest())
|
||||
addTemplateCommand() {
|
||||
|
||||
this.populateBodyFromEditor();
|
||||
|
||||
this.name.error('' === trim(this.name()));
|
||||
this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body()));
|
||||
|
||||
if (this.name.error() || this.body.error())
|
||||
{
|
||||
if (this.name.error() || this.body.error()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.templateSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().templates();
|
||||
this.cancelCommand();
|
||||
Remote.templateSetup(
|
||||
(result, data) => {
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data) {
|
||||
if (data.Result) {
|
||||
getApp().templates();
|
||||
this.cancelCommand();
|
||||
} else if (data.ErrorCode) {
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
} else {
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
else if (data.ErrorCode)
|
||||
{
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this.id(), this.name(), this.body());
|
||||
},
|
||||
this.id(),
|
||||
this.name(),
|
||||
this.body()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -100,79 +93,71 @@ class TemplatePopupView extends AbstractViewNext
|
|||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
this.editor.setPlain('', false);
|
||||
}
|
||||
}
|
||||
|
||||
populateBodyFromEditor() {
|
||||
if (this.editor)
|
||||
{
|
||||
if (this.editor) {
|
||||
this.body(this.editor.getDataWithHtmlMark());
|
||||
}
|
||||
}
|
||||
|
||||
editorSetBody(sBody) {
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
this.editor = new HtmlEditor(this.signatureDom(), () => {
|
||||
this.populateBodyFromEditor();
|
||||
}, () => {
|
||||
this.editor.setHtmlOrPlain(sBody);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.editor && this.signatureDom()) {
|
||||
this.editor = new HtmlEditor(
|
||||
this.signatureDom(),
|
||||
() => {
|
||||
this.populateBodyFromEditor();
|
||||
},
|
||||
() => {
|
||||
this.editor.setHtmlOrPlain(sBody);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.editor.setHtmlOrPlain(sBody);
|
||||
}
|
||||
}
|
||||
|
||||
onShow(template) {
|
||||
|
||||
this.clearPopup();
|
||||
|
||||
if (template && template.id)
|
||||
{
|
||||
if (template && template.id) {
|
||||
this.id(template.id);
|
||||
this.name(template.name);
|
||||
this.body(template.body);
|
||||
|
||||
if (template.populated)
|
||||
{
|
||||
if (template.populated) {
|
||||
this.editorSetBody(this.body());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.body.loading(true);
|
||||
this.body.error(false);
|
||||
|
||||
Remote.templateGetById((result, data) => {
|
||||
|
||||
this.body.loading(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result &&
|
||||
'Object/Template' === data.Result['@Object'] && isNormal(data.Result.Body))
|
||||
{
|
||||
if (
|
||||
StorageResultType.Success === result &&
|
||||
data &&
|
||||
data.Result &&
|
||||
'Object/Template' === data.Result['@Object'] &&
|
||||
isNormal(data.Result.Body)
|
||||
) {
|
||||
template.body = data.Result.Body;
|
||||
template.populated = true;
|
||||
|
||||
this.body(template.body);
|
||||
this.body.error(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.body('');
|
||||
this.body.error(true);
|
||||
}
|
||||
|
||||
this.editorSetBody(this.body());
|
||||
|
||||
}, this.id());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.editorSetBody('');
|
||||
}
|
||||
}
|
||||
|
|
@ -182,4 +167,4 @@ class TemplatePopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
export {TemplatePopupView, TemplatePopupView as default};
|
||||
export { TemplatePopupView, TemplatePopupView as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue