[SSE] Add Text to columns button to toolbar

This commit is contained in:
Julia Radzhabova 2019-05-30 15:52:25 +03:00
parent fe90c69ebe
commit b1ca425937
5 changed files with 69 additions and 7 deletions

View file

@ -60,9 +60,14 @@ define([
this.addListeners({
'DataTab': {
'data:group': this.onGroup,
'data:ungroup': this.onUngroup
'data:ungroup': this.onUngroup,
'data:tocolumns': this.onTextToColumn
}
});
this._state = {
CSVOptions: new Asc.asc_CCSVAdvancedOptions(0, 4, '')
};
},
onLaunch: function () {
},
@ -98,7 +103,11 @@ define([
},
onSelectionChanged: function(info) {
if (!this.toolbar.editMode || !this.view) return;
// special disable conditions
Common.Utils.lockControls(SSE.enumLock.multiselectCols, info.asc_getSelectedColsCount()>1, {array: [this.view.btnTextToColumns]});
Common.Utils.lockControls(SSE.enumLock.multiselect, info.asc_getFlags().asc_getMultiselect(), {array: [this.view.btnTextToColumns]});
},
onUngroup: function(type) {
@ -139,7 +148,35 @@ define([
})).show();
} else if (val!==undefined) //undefined - error, true - rows, false - columns
me.api.asc_group(val);
}
},
onTextToColumn: function() {
this.api.asc_TextImport(this._state.CSVOptions, _.bind(this.onTextToColumnCallback, this), false);
},
onTextToColumnCallback: function(data) {
if (!data || !data.length) return;
var me = this;
(new Common.Views.OpenDialog({
title: me.textWizard,
closable: true,
type: Common.Utils.importTextType.Columns,
preview: true,
previewData: data,
settings: me._state.CSVOptions,
api: me.api,
handler: function (result, encoding, delimiter, delimiterChar) {
if (result == 'ok') {
if (me && me.api) {
me.api.asc_TextToColumns(new Asc.asc_CCSVAdvancedOptions(encoding, delimiter, delimiterChar));
}
}
}
})).show();
},
textWizard: 'Text to Columns Wizard'
}, SSE.Controllers.DataTab || {}));
});

View file

@ -153,6 +153,10 @@
</div>
</section>
<section class="panel" data-tab="data">
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-text-column"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-group"></span>
<span class="btn-slot text x-huge" id="slot-btn-ungroup"></span>

View file

@ -58,6 +58,10 @@ define([
me.btnGroup.on('click', function (b, e) {
me.fireEvent('data:group');
});
me.btnTextToColumns.on('click', function (b, e) {
me.fireEvent('data:tocolumns');
});
}
return {
@ -102,7 +106,17 @@ define([
_injectComponent('#slot-btn-ungroup', this.btnUngroup);
this.lockedControls.push(this.btnUngroup);
this._state = {disabled: false};
this.btnTextToColumns = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-img-group',
caption: this.capBtnTextToCol,
split: false,
disabled: true,
lock: [_set.multiselect, _set.multiselectCols, _set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth]
});
_injectComponent('#slot-btn-text-column', this.btnTextToColumns);
this.lockedControls.push(this.btnTextToColumns);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -126,6 +140,7 @@ define([
me.btnUngroup.setMenu(_menu);
me.btnGroup.updateHint(me.tipGroup);
me.btnTextToColumns.updateHint(me.tipToColumns);
setEvents.call(me);
});
@ -154,7 +169,9 @@ define([
textColumns: 'Ungroup columns',
textClear: 'Clear outline',
tipGroup: 'Group range of cells',
tipUngroup: 'Ungroup range of cells'
tipUngroup: 'Ungroup range of cells',
capBtnTextToCol: 'Text to Columns',
tipToColumns: 'Separate cell text into columns'
}
}()), SSE.Views.DataTab || {}));
});

View file

@ -87,7 +87,8 @@ define([
cantGroupUngroup: 'cant-group-ungroup',
docPropsLock: 'doc-props-lock',
printAreaLock: 'print-area-lock',
namedRangeLock: 'named-range-lock'
namedRangeLock: 'named-range-lock',
multiselectCols:'is-multiselect-cols'
};
SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({

View file

@ -223,6 +223,7 @@
"Common.Views.SignSettingsDialog.textShowDate": "Show sign date in signature line",
"Common.Views.SignSettingsDialog.textTitle": "Signature Setup",
"Common.Views.SignSettingsDialog.txtEmpty": "This field is required",
"SSE.Controllers.DataTab.textWizard": "Text to Columns Wizard",
"SSE.Controllers.DocumentHolder.alignmentText": "Alignment",
"SSE.Controllers.DocumentHolder.centerText": "Center",
"SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column",
@ -1318,11 +1319,13 @@
"SSE.Views.ChartSettingsDlg.textZero": "Zero",
"SSE.Views.ChartSettingsDlg.txtEmpty": "This field is required",
"SSE.Views.DataTab.capBtnGroup": "Group",
"SSE.Views.DataTab.capBtnTextToCol": "Text to Columns",
"SSE.Views.DataTab.capBtnUngroup": "Ungroup",
"SSE.Views.DataTab.textRows": "Ungroup rows",
"SSE.Views.DataTab.textColumns": "Ungroup columns",
"SSE.Views.DataTab.textClear": "Clear outline",
"SSE.Views.DataTab.textColumns": "Ungroup columns",
"SSE.Views.DataTab.textRows": "Ungroup rows",
"SSE.Views.DataTab.tipGroup": "Group range of cells",
"SSE.Views.DataTab.tipToColumns": "Separate cell text into columns",
"SSE.Views.DataTab.tipUngroup": "Ungroup range of cells",
"SSE.Views.DigitalFilterDialog.cancelButtonText": "Cancel",
"SSE.Views.DigitalFilterDialog.capAnd": "And",