[SSE] Refactoring ole editor: add toolbar buttons

This commit is contained in:
Julia Radzhabova 2022-03-16 14:17:25 +03:00
parent 7a282063ef
commit fc47f0f167
6 changed files with 205 additions and 145 deletions

View file

@ -647,7 +647,7 @@ Common.UI.HintManager = new(function() {
};
var _setMode = function (mode) {
_isEditDiagram = mode.isEditDiagram;
_isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle;
};
return {

View file

@ -468,7 +468,7 @@ define([
this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle);
Common.Controllers.Desktop.init(this.appOptions);
if (this.appOptions.isEditDiagram) {
if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) {
Common.UI.HintManager.setMode(this.appOptions);
}
},
@ -1437,7 +1437,7 @@ define([
application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api);
if (statusbarController) {
statusbarController.getView('Statusbar').changeViewMode(!me.appOptions.isEditOle);
statusbarController.getView('Statusbar').changeViewMode(me.appOptions);
me.appOptions.isEditOle && statusbarController.onChangeViewMode(null, true, true); // set compact status bar for ole editing mode
}

View file

@ -312,6 +312,14 @@ define([
toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this));
toolbar.btnInsertFormula.on('click', _.bind(this.onInsertFormulaMenu, this));
toolbar.btnInsertFormula.menu.on('item:click', _.bind(this.onInsertFormulaMenu, this));
toolbar.btnDecDecimal.on('click', _.bind(this.onDecrement, this));
toolbar.btnIncDecimal.on('click', _.bind(this.onIncrement, this));
toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this));
toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true));
if (toolbar.cmbNumberFormat.cmpEl)
toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this));
} else {
toolbar.btnPrint.on('click', _.bind(this.onPrint, this));
toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled'));
@ -3105,12 +3113,28 @@ define([
});
}
var _set = Common.enumLock;
var type = seltype;
switch ( seltype ) {
case Asc.c_oAscSelectionType.RangeSlicer:
case Asc.c_oAscSelectionType.RangeImage: type = _set.selImage; break;
case Asc.c_oAscSelectionType.RangeShape: type = _set.selShape; break;
case Asc.c_oAscSelectionType.RangeShapeText: type = _set.selShapeText; break;
case Asc.c_oAscSelectionType.RangeChart: type = _set.selChart; break;
case Asc.c_oAscSelectionType.RangeChartText: type = _set.selChartText; break;
}
me.toolbar.lockToolbar(type, type != seltype, {
clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth]
});
me.toolbar.lockToolbar(Common.enumLock.coAuthText, is_objLocked);
return is_image;
};
var selectionType = info.asc_getSelectionType(),
xfs = info.asc_getXfs(),
coauth_disable = false,
editOptionsDisabled = _disableEditOptions(selectionType, coauth_disable),
val, need_disable = false;
@ -3135,6 +3159,17 @@ define([
need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true);
me.toolbar.lockToolbar(Common.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]});
}
var val = xfs.asc_getNumFormatInfo();
if ( val ) {
this._state.numformat = xfs.asc_getNumFormat();
this._state.numformatinfo = val;
val = val.asc_getType();
if (this._state.numformattype !== val) {
me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom);
this._state.numformattype = val;
}
}
},
onApiStyleChange: function() {
@ -3793,7 +3828,7 @@ define([
var me = this;
me.appConfig = config;
var compactview = !config.isEdit || config.isEditOle;
var compactview = !config.isEdit;
if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) {
if ( Common.localStorage.itemExists("sse-compact-toolbar") ) {
compactview = Common.localStorage.getBool("sse-compact-toolbar");

View file

@ -85,6 +85,12 @@
</div>
</div>
<div class="separator short"></div>
<div class="group small">
<div class="elset">
<span class="btn-slot split" id="slot-btn-formula"></span>
</div>
</div>
<div class="separator short"></div>
<div class="group small">
<div class="elset">
<span class="btn-slot split" id="slot-btn-sortdesc"></span>
@ -99,6 +105,14 @@
</div>
</div>
<div class="separator short"></div>
<div class="group small">
<div class="elset">
<span class="btn-slot split" id="slot-btn-digit-dec"></span>
<span class="btn-slot split" id="slot-btn-digit-inc"></span>
<span class="btn-slot" id="slot-btn-format" style="width: 84px; vertical-align: middle;"></span>
</div>
</div>
<div class="separator short"></div>
<div class="group small">
<div class="elset">
<span class="btn-slot" id="slot-btn-search"></span>

View file

@ -516,7 +516,8 @@ define([
this.mode = _.extend({}, this.mode, mode);
// this.$el.find('.el-edit')[mode.isEdit?'show':'hide']();
//this.btnAddWorksheet.setVisible(this.mode.isEdit);
$('#status-addtabs-box')[(this.mode.isEdit && !this.mode.isEditOle ) ? 'show' : 'hide']();
$('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide']();
this.btnAddWorksheet.setVisible(!this.mode.isEditOle);
this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None);
this.updateTabbarBorders();
},
@ -890,11 +891,12 @@ define([
}
},
changeViewMode: function (edit) {
changeViewMode: function (mode) {
var edit = mode.isEdit && !mode.isEditOle;
if (edit) {
this.tabBarBox.css('left', '175px');
} else {
this.tabBarBox.css('left', '');
this.tabBarBox.css('left', mode.isEditOle ? '152px' : '');
}
this.tabbar.options.draggable = edit;

View file

@ -197,7 +197,7 @@ define([
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-copy',
dataHint: '1',
dataHintDirection: config.isEditDiagram ? 'bottom' : 'top',
dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top',
dataHintTitle: 'C'
});
@ -207,7 +207,7 @@ define([
iconCls : 'toolbar__icon btn-paste',
lock : [/*_set.editCell,*/ _set.coAuth, _set.lostConnect],
dataHint : '1',
dataHintDirection: config.isEditDiagram ? 'bottom' : 'top',
dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top',
dataHintTitle: 'V'
});
@ -235,153 +235,162 @@ define([
dataHintTitle: 'Y'
});
if ( config.isEditDiagram ) {
if (config.isEditDiagram || config.isEditMailMerge || config.isEditOle ) {
me.$layout = $(_.template(simple)(config));
if ( config.isEditDiagram || config.isEditOle ) {
me.btnInsertFormula = new Common.UI.Button({
id : 'id-toolbar-btn-insertformula',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-formula',
split : true,
lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth],
menu : new Common.UI.Menu({
style : 'min-width: 110px',
items : [
{caption: 'SUM', value: 'SUM'},
{caption: 'AVERAGE', value: 'AVERAGE'},
{caption: 'MIN', value: 'MIN'},
{caption: 'MAX', value: 'MAX'},
{caption: 'COUNT', value: 'COUNT'},
{caption: '--'},
{
caption: me.txtAdditional,
value: 'more',
hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3')
}
]
}),
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
me.btnInsertFormula = new Common.UI.Button({
id : 'id-toolbar-btn-insertformula',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-formula',
split : true,
lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth],
menu : new Common.UI.Menu({
style : 'min-width: 110px',
items : [
{caption: 'SUM', value: 'SUM'},
{caption: 'AVERAGE', value: 'AVERAGE'},
{caption: 'MIN', value: 'MIN'},
{caption: 'MAX', value: 'MAX'},
{caption: 'COUNT', value: 'COUNT'},
{caption: '--'},
{
caption: me.txtAdditional,
value: 'more',
hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3')
}
]
}),
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
me.btnDecDecimal = new Common.UI.Button({
id : 'id-toolbar-btn-decdecimal',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-decdecimal',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnDecDecimal = new Common.UI.Button({
id : 'id-toolbar-btn-decdecimal',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-decdecimal',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnIncDecimal = new Common.UI.Button({
id : 'id-toolbar-btn-incdecimal',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-incdecimal',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnIncDecimal = new Common.UI.Button({
id : 'id-toolbar-btn-incdecimal',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-incdecimal',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth],
dataHint : '1',
dataHintDirection: 'bottom'
});
var formatTemplate =
_.template([
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">',
'<div style="position: relative;"><div style="position: absolute; left: 0; width: 100px;"><%= scope.getDisplayValue(item) %></div>',
'<div style="display: inline-block; width: 100%; max-width: 300px; overflow: hidden; text-overflow: ellipsis; text-align: right; vertical-align: bottom; padding-left: 100px; color: silver;white-space: nowrap;"><%= item.exampleval ? item.exampleval : "" %></div>',
'</div></a></li>',
'<% }); %>',
'<li class="divider">',
'<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem">' + me.textMoreFormats + '</a></li>'
].join(''));
var formatTemplate =
_.template([
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">',
'<div style="position: relative;"><div style="position: absolute; left: 0; width: 100px;"><%= scope.getDisplayValue(item) %></div>',
'<div style="display: inline-block; width: 100%; max-width: 300px; overflow: hidden; text-overflow: ellipsis; text-align: right; vertical-align: bottom; padding-left: 100px; color: silver;white-space: nowrap;"><%= item.exampleval ? item.exampleval : "" %></div>',
'</div></a></li>',
'<% }); %>',
'<li class="divider">',
'<li id="id-toolbar-mnu-item-more-formats" data-value="-1"><a tabindex="-1" type="menuitem">' + me.textMoreFormats + '</a></li>'
].join(''));
me.cmbNumberFormat = new Common.UI.ComboBox({
cls : 'input-group-nr',
menuStyle : 'min-width: 180px;',
hint : me.tipNumFormat,
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth],
itemsTemplate: formatTemplate,
editable : false,
data : me.numFormatData,
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
}
if ( config.isEditDiagram ) {
me.btnEditChart = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart',
cls : 'btn-toolbar btn-text-default auto',
caption : me.tipEditChart,
lock : [_set.lostConnect],
style : 'min-width: 120px;',
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
me.cmbNumberFormat = new Common.UI.ComboBox({
cls : 'input-group-nr',
menuStyle : 'min-width: 180px;',
hint : me.tipNumFormat,
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth],
itemsTemplate: formatTemplate,
editable : false,
data : me.numFormatData,
dataHint : '1',
dataHintDirection: config.isEditDiagram ? 'bottom' : 'top',
dataHintOffset: config.isEditDiagram ? 'big' : undefined
});
me.btnEditChartData = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart-data',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-select-range',
caption : me.tipEditChartData,
lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
me.btnEditChart = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart',
cls : 'btn-toolbar btn-text-default auto',
caption : me.tipEditChart,
lock : [_set.lostConnect],
style : 'min-width: 120px;',
dataHint : '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
});
me.btnEditChartType = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart-type',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-chart',
caption : me.tipEditChartType,
lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect],
style : 'min-width: 120px;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
}
if ( config.isEditMailMerge || config.isEditOle ) {
me.btnSearch = new Common.UI.Button({
id : 'id-toolbar-btn-search',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-search',
lock : [_set.lostConnect],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnEditChartData = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart-data',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-select-range',
caption : me.tipEditChartData,
lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
me.btnSortDown = new Common.UI.Button({
id : 'id-toolbar-btn-sort-down',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-sort-down',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnEditChartType = new Common.UI.Button({
id : 'id-toolbar-rtn-edit-chart-type',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-chart',
caption : me.tipEditChartType,
lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect],
style : 'min-width: 120px;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
} else
if ( config.isEditMailMerge || config.isEditOle ) {
me.$layout = $(_.template(simple)(config));
me.btnSortUp = new Common.UI.Button({
id : 'id-toolbar-btn-sort-up',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-sort-up',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot],
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnSearch = new Common.UI.Button({
id : 'id-toolbar-btn-search',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-search',
lock : [_set.lostConnect]
});
me.btnSetAutofilter = new Common.UI.Button({
id : 'id-toolbar-btn-setautofilter',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-autofilter',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot],
enableToggle: true,
dataHint : '1',
dataHintDirection: 'bottom'
});
me.btnSortDown = new Common.UI.Button({
id : 'id-toolbar-btn-sort-down',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-sort-down',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot]
});
me.btnSortUp = new Common.UI.Button({
id : 'id-toolbar-btn-sort-up',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-sort-up',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot]
});
me.btnSetAutofilter = new Common.UI.Button({
id : 'id-toolbar-btn-setautofilter',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-autofilter',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot],
enableToggle: true
});
me.btnClearAutofilter = new Common.UI.Button({
id : 'id-toolbar-btn-clearfilter',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-clear-filter',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot]
});
} else
if ( config.isEdit ) {
me.btnClearAutofilter = new Common.UI.Button({
id : 'id-toolbar-btn-clearfilter',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-clear-filter',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot],
dataHint : '1',
dataHintDirection: 'bottom'
});
}
} else if ( config.isEdit ) {
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template),
tabs: [