prettier --write

This commit is contained in:
RainLoop Team 2019-07-04 22:19:24 +03:00
parent 450528ff00
commit 8a0be3212d
164 changed files with 7053 additions and 9008 deletions

View file

@ -1,18 +1,15 @@
import $ from '$';
import ko from 'ko';
import {isUnd} from 'Common/Utils';
import {i18nToNodes} from 'Common/Translator';
import { isUnd } from 'Common/Utils';
import { i18nToNodes } from 'Common/Translator';
class AbstractComponent
{
class AbstractComponent {
disposable = [];
dispose() {
this.disposable.forEach((funcToDispose) => {
if (funcToDispose && funcToDispose.dispose)
{
if (funcToDispose && funcToDispose.dispose) {
funcToDispose.dispose();
}
});
@ -25,22 +22,19 @@ class AbstractComponent
* @returns {Object}
*/
const componentExportHelper = (ClassObject, templateID = '') => ({
template: templateID ? {element: templateID} : '<b></b>',
template: templateID ? { element: templateID } : '<b></b>',
viewModel: {
createViewModel: (params, componentInfo) => {
params = params || {};
params.element = null;
if (componentInfo && componentInfo.element)
{
if (componentInfo && componentInfo.element) {
params.component = componentInfo;
params.element = $(componentInfo.element);
i18nToNodes(params.element);
if (!isUnd(params.inline) && ko.unwrap(params.inline))
{
if (!isUnd(params.inline) && ko.unwrap(params.inline)) {
params.element.css('display', 'inline-block');
}
}
@ -50,4 +44,4 @@ const componentExportHelper = (ClassObject, templateID = '') => ({
}
});
export {AbstractComponent, componentExportHelper};
export { AbstractComponent, componentExportHelper };

View file

@ -1,16 +1,13 @@
import ko from 'ko';
import {isUnd, trim, pInt} from 'Common/Utils';
import {SaveSettingsStep} from 'Common/Enums';
import {AbstractComponent} from 'Component/Abstract';
import { isUnd, trim, pInt } from 'Common/Utils';
import { SaveSettingsStep } from 'Common/Enums';
import { AbstractComponent } from 'Component/Abstract';
class AbstractInput extends AbstractComponent
{
class AbstractInput extends AbstractComponent {
/**
* @param {Object} params
*/
constructor(params) {
super();
this.value = params.value || '';
@ -28,32 +25,26 @@ class AbstractInput extends AbstractComponent
this.classForTrigger = ko.observable('');
this.className = ko.computed(() => {
const
size = ko.unwrap(this.size),
const size = ko.unwrap(this.size),
suffixValue = this.trigger ? ' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
return (0 < size ? 'span' + size : '') + suffixValue;
});
if (!isUnd(params.width) && params.element)
{
if (!isUnd(params.width) && params.element) {
params.element.find('input,select,textarea').css('width', params.width);
}
this.disposable.push(this.className);
if (this.trigger)
{
if (this.trigger) {
this.setTriggerState(this.trigger());
this.disposable.push(
this.trigger.subscribe(this.setTriggerState, this)
);
this.disposable.push(this.trigger.subscribe(this.setTriggerState, this));
}
}
setTriggerState(value) {
switch (pInt(value))
{
switch (pInt(value)) {
case SaveSettingsStep.TrueResult:
this.classForTrigger('success');
break;
@ -67,4 +58,4 @@ class AbstractInput extends AbstractComponent
}
}
export {AbstractInput, AbstractInput as default};
export { AbstractInput, AbstractInput as default };

View file

@ -1,6 +1,5 @@
import {componentExportHelper} from 'Component/Abstract';
import {AbstractCheckbox} from 'Component/AbstractCheckbox';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractCheckbox } from 'Component/AbstractCheckbox';
class CheckboxComponent extends AbstractCheckbox {}

View file

@ -1,6 +1,5 @@
import {componentExportHelper} from 'Component/Abstract';
import {AbstractCheckbox} from 'Component/AbstractCheckbox';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractCheckbox } from 'Component/AbstractCheckbox';
class ClassicCheckboxComponent extends AbstractCheckbox {}

View file

@ -1,6 +1,5 @@
import {componentExportHelper} from 'Component/Abstract';
import {AbstractInput} from 'Component/AbstractInput';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractInput } from 'Component/AbstractInput';
class DateComponent extends AbstractInput {}

View file

@ -1,6 +1,5 @@
import {componentExportHelper} from 'Component/Abstract';
import {AbstractInput} from 'Component/AbstractInput';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractInput } from 'Component/AbstractInput';
class InputComponent extends AbstractInput {}

View file

@ -1,20 +1,17 @@
import _ from '_';
import ko from 'ko';
import {componentExportHelper} from 'Component/Abstract';
import {AbstractCheckbox} from 'Component/AbstractCheckbox';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractCheckbox } from 'Component/AbstractCheckbox';
class CheckboxMaterialDesignComponent extends AbstractCheckbox
{
class CheckboxMaterialDesignComponent extends AbstractCheckbox {
/**
* @param {Object} params
*/
constructor(params) {
super(params);
this.animationBox = ko.observable(false).extend({falseTimeout: 200});
this.animationCheckmark = ko.observable(false).extend({falseTimeout: 200});
this.animationBox = ko.observable(false).extend({ falseTimeout: 200 });
this.animationCheckmark = ko.observable(false).extend({ falseTimeout: 200 });
this.animationBoxSetTrue = _.bind(this.animationBoxSetTrue, this);
this.animationCheckmarkSetTrue = _.bind(this.animationCheckmarkSetTrue, this);
@ -38,8 +35,7 @@ class CheckboxMaterialDesignComponent extends AbstractCheckbox
if (box) {
this.animationBoxSetTrue();
_.delay(this.animationCheckmarkSetTrue, 200);
}
else {
} else {
this.animationCheckmarkSetTrue();
_.delay(this.animationBoxSetTrue, 200);
}

View file

@ -1,6 +1,5 @@
import {componentExportHelper} from 'Component/Abstract';
import {AbstractRadio} from 'Component/AbstractRadio';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractRadio } from 'Component/AbstractRadio';
class RadioComponent extends AbstractRadio {}

View file

@ -1,72 +1,74 @@
import { pInt } from 'Common/Utils';
import { SaveSettingsStep } from 'Common/Enums';
import { AbstractComponent, componentExportHelper } from 'Component/Abstract';
import {pInt} from 'Common/Utils';
import {SaveSettingsStep} from 'Common/Enums';
import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
class SaveTriggerComponent extends AbstractComponent
{
class SaveTriggerComponent extends AbstractComponent {
/**
* @param {Object} params
*/
constructor(params) {
super();
this.element = params.element || null;
this.value = params.value && params.value.subscribe ? params.value : null;
if (this.element)
{
if (this.value)
{
if (this.element) {
if (this.value) {
this.element.css('display', 'inline-block');
if (params.verticalAlign)
{
if (params.verticalAlign) {
this.element.css('vertical-align', params.verticalAlign);
}
this.setState(this.value());
this.disposable.push(
this.value.subscribe(this.setState, this)
);
}
else
{
this.disposable.push(this.value.subscribe(this.setState, this));
} else {
this.element.hide();
}
}
}
setState(value) {
switch (pInt(value))
{
switch (pInt(value)) {
case SaveSettingsStep.TrueResult:
this.element
.find('.animated,.error').hide().removeClass('visible')
.find('.animated,.error')
.hide()
.removeClass('visible')
.end()
.find('.success').show().addClass('visible');
.find('.success')
.show()
.addClass('visible');
break;
case SaveSettingsStep.FalseResult:
this.element
.find('.animated,.success').hide().removeClass('visible')
.find('.animated,.success')
.hide()
.removeClass('visible')
.end()
.find('.error').show().addClass('visible');
.find('.error')
.show()
.addClass('visible');
break;
case SaveSettingsStep.Animate:
this.element
.find('.error,.success').hide().removeClass('visible')
.find('.error,.success')
.hide()
.removeClass('visible')
.end()
.find('.animated').show().addClass('visible');
.find('.animated')
.show()
.addClass('visible');
break;
case SaveSettingsStep.Idle:
default:
this.element
.find('.animated').hide()
.find('.animated')
.hide()
.end()
.find('.error,.success').removeClass('visible');
.find('.error,.success')
.removeClass('visible');
break;
}
}

View file

@ -1,36 +1,33 @@
import $ from '$';
import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
import { AbstractComponent, componentExportHelper } from 'Component/Abstract';
class ScriptComponent extends AbstractComponent
{
class ScriptComponent extends AbstractComponent {
/**
* @param {Object} params
*/
constructor(params) {
super();
if (params.component && params.component.templateNodes && params.element &&
params.element[0] && params.element[0].outerHTML)
{
if (
params.component &&
params.component.templateNodes &&
params.element &&
params.element[0] &&
params.element[0].outerHTML
) {
let script = params.element[0].outerHTML;
script = !script ? '' : script
.replace(/<x-script/i, '<script')
.replace(/<b><\/b><\/x-script>/i, '</script>');
script = !script ? '' : script.replace(/<x-script/i, '<script').replace(/<b><\/b><\/x-script>/i, '</script>');
if (script)
{
if (script) {
params.element.text('');
params.element.replaceWith(
$(script).text(
params.component.templateNodes[0] && params.component.templateNodes[0].nodeValue ?
params.component.templateNodes[0].nodeValue : ''
params.component.templateNodes[0] && params.component.templateNodes[0].nodeValue
? params.component.templateNodes[0].nodeValue
: ''
)
);
}
else
{
} else {
params.element.remove();
}
}

View file

@ -1,16 +1,13 @@
import { i18n } from 'Common/Translator';
import { defautOptionsAfterRender } from 'Common/Utils';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractInput } from 'Component/AbstractInput';
import {i18n} from 'Common/Translator';
import {defautOptionsAfterRender} from 'Common/Utils';
import {componentExportHelper} from 'Component/Abstract';
import {AbstractInput} from 'Component/AbstractInput';
class SelectComponent extends AbstractInput
{
class SelectComponent extends AbstractInput {
/**
* @param {Object} params
*/
constructor(params) {
super(params);
this.options = params.options || '';
@ -19,8 +16,7 @@ class SelectComponent extends AbstractInput
this.optionsValue = params.optionsValue || null;
this.optionsCaption = params.optionsCaption || null;
if (this.optionsCaption)
{
if (this.optionsCaption) {
this.optionsCaption = i18n(this.optionsCaption);
}

View file

@ -1,10 +1,8 @@
import $ from '$';
let cachedUrl = null;
const getUrl = () => {
if (!cachedUrl)
{
if (!cachedUrl) {
const version = $('#rlAppVersion').attr('content') || '0.0.0';
cachedUrl = `rainloop/v/${version}/static/css/svg/icons.svg`;
}
@ -15,9 +13,8 @@ const getUrl = () => {
export default {
template: '<b></b>',
viewModel: {
createViewModel: ({icon = 'null'}, componentInfo) => {
if (componentInfo && componentInfo.element)
{
createViewModel: ({ icon = 'null' }, componentInfo) => {
if (componentInfo && componentInfo.element) {
$(componentInfo.element).replaceWith(
`<svg class="svg-icon svg-icon-${icon}"><use xlink:href="${getUrl()}#svg-icon-${icon}"></use></svg>`
);

View file

@ -1,17 +1,14 @@
import {isUnd} from 'Common/Utils';
import {componentExportHelper} from 'Component/Abstract';
import {AbstractInput} from 'Component/AbstractInput';
import { isUnd } from 'Common/Utils';
import { componentExportHelper } from 'Component/Abstract';
import { AbstractInput } from 'Component/AbstractInput';
const DEFAULT_ROWS = 5;
class TextAreaComponent extends AbstractInput
{
class TextAreaComponent extends AbstractInput {
/**
* @param {Object} params
*/
constructor(params) {
super(params);
this.rows = params.rows || DEFAULT_ROWS;