Refactoring open dialog

This commit is contained in:
Julia Radzhabova 2021-03-23 16:55:20 +03:00
parent 1f62dbf053
commit 7311cd0c8c
6 changed files with 26 additions and 34 deletions

View file

@ -264,7 +264,7 @@ define([
_handleInput: function(state) {
if (this.handler) {
if (this.type == Common.Utils.importTextType.DRM) {
this.handler.call(this, state, this.inputPwd.getValue());
this.handler.call(this, state, {drmOptions: new Asc.asc_CDRMAdvancedOptions(this.inputPwd.getValue())});
} else {
if ( this.type == Common.Utils.importTextType.Data && state == 'ok' && !this.isRangeValid() ) {
return;
@ -281,7 +281,14 @@ define([
var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined,
thousands = this.separatorOptions ? this.separatorOptions.thousands : undefined;
this.handler.call(this, state, encoding, delimiter, delimiterChar, decimal, thousands, this.txtDestRange ? this.txtDestRange.getValue() : '');
var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar);
decimal && options.asc_setNumberDecimalSeparator(decimal);
thousands && options.asc_setNumberGroupSeparator(thousands);
this.handler.call(this, state, {
textOptions: options,
range: this.txtDestRange ? this.txtDestRange.getValue() : '',
data: this.data
});
}
}

View file

@ -2147,15 +2147,15 @@ define([
codepages: advOptions.asc_getCodePages(),
settings: advOptions.asc_getRecommendedSettings(),
api: me.api,
handler: function (result, encoding) {
handler: function (result, settings) {
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me && me.api) {
if (mode==2) {
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding));
formatOptions && formatOptions.asc_setAdvancedOptions(settings.textOptions);
me.api.asc_DownloadAs(formatOptions);
} else
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding));
me.api.asc_setAdvancedOptions(type, settings.textOptions);
me.loadMask && me.loadMask.show();
}
}
@ -2174,7 +2174,7 @@ define([
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me.api) {
me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value));
me.api.asc_setAdvancedOptions(type, value.drmOptions);
me.loadMask && me.loadMask.show();
}
} else {

View file

@ -1978,7 +1978,7 @@ define([
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me.api) {
me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value));
me.api.asc_setAdvancedOptions(type, value.drmOptions);
me.loadMask && me.loadMask.show();
}
} else {

View file

@ -209,14 +209,9 @@ define([
previewData: data,
settings: me._state.CSVOptions,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands) {
if (result == 'ok') {
if (me && me.api) {
var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar);
decimal && options.asc_setNumberDecimalSeparator(decimal);
thousands && options.asc_setNumberGroupSeparator(thousands);
me.api.asc_TextToColumns(options);
}
handler: function (result, settings) {
if (result == 'ok' && me.api) {
me.api.asc_TextToColumns(settings.textOptions);
}
}
})).show();
@ -263,17 +258,11 @@ define([
settings: advOptions ? advOptions.asc_getRecommendedSettings() : me._state.CSVOptions,
codepages: advOptions ? advOptions.asc_getCodePages() : null,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands, range) {
if (result == 'ok') {
if (me && me.api) {
var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar);
decimal && options.asc_setNumberDecimalSeparator(decimal);
thousands && options.asc_setNumberGroupSeparator(thousands);
me.api.asc_TextToColumns(options, me.api.asc_getTextFromFileOrUrl(), range);
handler: function (result, settings) {
if (result == 'ok' && me.api) {
me.api.asc_TextToColumns(settings.textOptions, settings.data, settings.range);
}
}
me.api.asc_cleanTextFromFileOrUrl();
}
})).show();
},

View file

@ -2557,16 +2557,12 @@ define([
type: Common.Utils.importTextType.Paste,
preview: true,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar, decimal, thousands) {
handler: function (result, settings) {
if (result == 'ok') {
if (me && me.api) {
var props = new Asc.SpecialPasteProps();
props.asc_setProps(Asc.c_oSpecialPasteProps.useTextImport);
var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar);
decimal && options.asc_setNumberDecimalSeparator(decimal);
thousands && options.asc_setNumberGroupSeparator(thousands);
props.asc_setAdvancedOptions(options);
props.asc_setAdvancedOptions(settings.textOptions);
me.api.asc_SpecialPaste(props);
}
me._state.lastSpecPasteChecked = item;

View file

@ -1869,15 +1869,15 @@ define([
codepages: advOptions.asc_getCodePages(),
settings: advOptions.asc_getRecommendedSettings(),
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar) {
handler: function (result, settings) {
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me && me.api) {
if (mode==2) {
formatOptions && formatOptions.asc_setAdvancedOptions(new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
formatOptions && formatOptions.asc_setAdvancedOptions(settings.textOptions);
me.api.asc_DownloadAs(formatOptions);
} else
me.api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar));
me.api.asc_setAdvancedOptions(type, settings.textOptions);
me.loadMask && me.loadMask.show();
}
}
@ -1896,7 +1896,7 @@ define([
me.isShowOpenDialog = false;
if (result == 'ok') {
if (me && me.api) {
me.api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(value));
me.api.asc_setAdvancedOptions(type, value.drmOptions);
me.loadMask && me.loadMask.show();
}
} else {