mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
153 changed files with 21193 additions and 21115 deletions
|
|
@ -1,110 +1,99 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainAliasPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/DomainAlias',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsDomainAlias'
|
||||
})
|
||||
class DomainAliasPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.alias = ko.observable('');
|
||||
this.alias = ko.observable('');
|
||||
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(function() {
|
||||
return _.map(this.domains(), function(item) {
|
||||
return {
|
||||
optValue: item.name,
|
||||
optText: item.name
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function() {
|
||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
||||
}, this);
|
||||
|
||||
this.createCommand = Utils.createCommand(this, function() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
||||
this.name(),
|
||||
this.alias()
|
||||
this.domainsOptions = ko.computed(
|
||||
() => _.map(this.domains(), (item) => ({optValue: item.name, optText: item.name}))
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias());
|
||||
|
||||
this.createCommand = createCommand(() => {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
this.onDomainAliasCreateOrSaveResponse,
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.onDomainAliasCreateOrSaveResponse = _.bind(this.onDomainAliasCreateOrSaveResponse, this);
|
||||
}
|
||||
|
||||
onDomainAliasCreateOrSaveResponse(result, data) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Notification.DomainAlreadyExists === data.ErrorCode)
|
||||
{
|
||||
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.clearForm();
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if ('' === this.name() && !bMobileDevice)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
}
|
||||
|
||||
clearForm() {
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.alias('');
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function(sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearForm();
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.clearForm = function()
|
||||
{
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.alias('');
|
||||
};
|
||||
|
||||
module.exports = DomainAliasPopupView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue