[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,9 +235,9 @@ 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',
@ -304,10 +304,11 @@ define([
editable : false,
data : me.numFormatData,
dataHint : '1',
dataHintDirection: config.isEditDiagram ? 'bottom' : 'top',
dataHintOffset: config.isEditDiagram ? 'big' : undefined
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',
@ -341,29 +342,33 @@ define([
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
} else
}
if ( config.isEditMailMerge || config.isEditOle ) {
me.$layout = $(_.template(simple)(config));
me.btnSearch = new Common.UI.Button({
id : 'id-toolbar-btn-search',
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-menu-search',
lock : [_set.lostConnect]
lock : [_set.lostConnect],
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]
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.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]
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.btnSetAutofilter = new Common.UI.Button({
@ -371,17 +376,21 @@ define([
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
enableToggle: true,
dataHint : '1',
dataHintDirection: 'bottom'
});
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]
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 ) {
}
} else if ( config.isEdit ) {
Common.UI.Mixtbar.prototype.initialize.call(this, {
template: _.template(template),
tabs: [