Merge pull request #1 from ONLYOFFICE/feature/cell-style-groups

Feature/cell style groups
This commit is contained in:
Alexei Koshelev 2022-08-14 17:26:42 +03:00 committed by GitHub
commit 20a25d1c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 643 additions and 9 deletions

View file

@ -328,6 +328,7 @@ define([
if (this.listenStoreEvents) {
this.listenTo(this.store, 'add', this.onAddItem);
this.listenTo(this.store, 'reset', this.onResetItems);
this.groups && this.listenTo(this.groups, 'add', this.onAddGroup);
}
this.onResetItems();
@ -510,6 +511,35 @@ define([
}
},
onAddGroup: function(group) {
var el = $(_.template([
'<% if (group.headername !== undefined) { %>',
'<div class="header-name"><%= group.headername %></div>',
'<% } %>',
'<div class="grouped-data <% if (group.inline) { %> group.inline <% } %> <% if (!_.isEmpty(group.caption)) { %> margin <% } %>" id="<%= group.id %>">',
'<% if (!_.isEmpty(group.caption)) { %>',
'<div class="group-description">',
'<span><%= group.caption %></span>',
'</div>',
'<% } %>',
'<div class="group-items-container">',
'</div>',
'</div>'
].join(''))({
group: group.toJSON()
}));
var innerEl = $(this.el).find('.inner').addBack().filter('.inner');
if (innerEl) {
var idx = _.indexOf(this.groups.models, group);
var innerDivs = innerEl.find('.grouped-data');
if (idx > 0)
$(innerDivs.get(idx - 1)).after(el);
else {
(innerDivs.length > 0) ? $(innerDivs[idx]).before(el) : innerEl.append(el);
}
}
},
onResetItems: function() {
_.each(this.dataViewItems, function(item) {
var tip = item.$el.data('bs.tooltip');

View file

@ -874,6 +874,10 @@
border: @scaled-one-px-value solid @border-regular-control;
.border-radius(@border-radius-small);
&.auto {
width: auto;
}
&.dropdown-toggle {
width: 13px;
}

View file

@ -422,6 +422,8 @@ define([
view.menuTableTOC.menu.on('item:click', _.bind(me.onTOCMenu, me));
view.menuParaTOCRefresh.menu.on('item:click', _.bind(me.onTOCMenu, me));
view.menuParaTOCSettings.on('click', _.bind(me.onParaTOCSettings, me));
view.menuTableEquation.menu.on('item:click', _.bind(me.convertEquation, me));
view.menuParagraphEquation.menu.on('item:click', _.bind(me.convertEquation, me));
},
getView: function (name) {
@ -2294,6 +2296,17 @@ define([
return false;
},
convertEquation: function(menu, item, e) {
if (this.api) {
if (item.options.type=='input')
this.api.asc_SetMathInputType(item.value);
else if (item.options.type=='view')
this.api.asc_ConvertMathView(item.value.linear, item.value.all);
else if (item.options.type=='mode')
this.api.asc_ConvertMathDisplayMode(item.checked);
}
},
editComplete: function() {
this.documentHolder && this.documentHolder.fireEvent('editcomplete', this.documentHolder);
}

View file

@ -1143,6 +1143,68 @@ define([
caption : '--'
});
me.menuTableEquation = new Common.UI.MenuItem({
caption : me.advancedEquationText,
menu : new Common.UI.Menu({
cls: 'ppm-toolbar shifted-right',
menuAlign: 'tl-tr',
items : [
new Common.UI.MenuItem({
caption : me.unicodeText,
iconCls : 'menu__icon unicode',
checkable : true,
checkmark : false,
checked : false,
toggleGroup : 'popupparaeqinput',
type : 'input',
value : Asc.c_oAscMathInputType.Unicode
}),
new Common.UI.MenuItem({
caption : me.latexText,
iconCls : 'menu__icon latex',
checkable : true,
checkmark : false,
checked : false,
toggleGroup : 'popupparaeqinput',
type : 'input',
value : Asc.c_oAscMathInputType.LaTeX
}),
{ caption : '--' },
new Common.UI.MenuItem({
caption : me.currProfText,
iconCls : 'menu__icon professional-equation',
type : 'view',
value : {all: false, linear: false}
}),
new Common.UI.MenuItem({
caption : me.currLinearText,
iconCls : 'menu__icon linear-equation',
type : 'view',
value : {all: false, linear: true}
}),
new Common.UI.MenuItem({
caption : me.allProfText,
iconCls : 'menu__icon professional-equation',
type : 'view',
value : {all: true, linear: false}
}),
new Common.UI.MenuItem({
caption : me.allLinearText,
iconCls : 'menu__icon linear-equation',
type : 'view',
value : {all: true, linear: true}
}),
{ caption : '--' },
new Common.UI.MenuItem({
caption : me.eqToInlineText,
checkable : true,
checked : false,
type : 'mode'
})
]
})
});
me.menuTableSelectText = new Common.UI.MenuItem({
caption : me.selectText,
menu : new Common.UI.Menu({
@ -1388,6 +1450,15 @@ define([
me.clearEquationMenu(false, 10);
menuEquationSeparatorInTable.setVisible(isEquation && eqlen>0);
me.menuTableEquation.setVisible(isEquation);
me.menuTableEquation.setDisabled(disabled);
if (isEquation) {
var eq = me.api.asc_GetMathInputType();
me.menuTableEquation.menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode);
me.menuTableEquation.menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX);
me.menuTableEquation.menu.items[8].setChecked(me.api.asc_IsInlineMath());
}
var control_lock = (value.paraProps) ? (!value.paraProps.value.can_DeleteBlockContentControl() || !value.paraProps.value.can_EditBlockContentControl() ||
!value.paraProps.value.can_DeleteInlineContentControl() || !value.paraProps.value.can_EditInlineContentControl()) : false;
var in_toc = me.api.asc_GetTableOfContentsPr(true),
@ -1470,7 +1541,8 @@ define([
me.menuTableRemoveForm,
menuTableControl,
me.menuTableTOC,
me.menuParagraphAdvancedInTable
me.menuParagraphAdvancedInTable,
me.menuTableEquation
]
}).on('hide:after', function(menu, e, isFromInputControl) {
if (me.suppressEditComplete) {
@ -1584,6 +1656,68 @@ define([
caption : me.advancedDropCapText
});
me.menuParagraphEquation = new Common.UI.MenuItem({
caption : me.advancedEquationText,
menu : new Common.UI.Menu({
cls: 'ppm-toolbar shifted-right',
menuAlign: 'tl-tr',
items : [
new Common.UI.MenuItem({
caption : me.unicodeText,
iconCls : 'menu__icon unicode',
checkable : true,
checkmark : false,
checked : false,
toggleGroup : 'popupparaeqinput',
type : 'input',
value : Asc.c_oAscMathInputType.Unicode
}),
new Common.UI.MenuItem({
caption : me.latexText,
iconCls : 'menu__icon latex',
checkable : true,
checkmark : false,
checked : false,
toggleGroup : 'popupparaeqinput',
type : 'input',
value : Asc.c_oAscMathInputType.LaTeX
}),
{ caption : '--' },
new Common.UI.MenuItem({
caption : me.currProfText,
iconCls : 'menu__icon professional-equation',
type : 'view',
value : {all: false, linear: false}
}),
new Common.UI.MenuItem({
caption : me.currLinearText,
iconCls : 'menu__icon linear-equation',
type : 'view',
value : {all: false, linear: true}
}),
new Common.UI.MenuItem({
caption : me.allProfText,
iconCls : 'menu__icon professional-equation',
type : 'view',
value : {all: true, linear: false}
}),
new Common.UI.MenuItem({
caption : me.allLinearText,
iconCls : 'menu__icon linear-equation',
type : 'view',
value : {all: true, linear: true}
}),
{ caption : '--' },
new Common.UI.MenuItem({
caption : me.eqToInlineText,
checkable : true,
checked : false,
type : 'mode'
})
]
})
});
/** coauthoring begin **/
var menuCommentSeparatorPara = new Common.UI.MenuItem({
caption : '--'
@ -1954,6 +2088,15 @@ define([
me.menuEquationInsertCaption.setVisible(isEquation);
menuEquationInsertCaptionSeparator.setVisible(isEquation);
me.menuParagraphEquation.setVisible(isEquation);
me.menuParagraphEquation.setDisabled(disabled);
if (isEquation) {
var eq = me.api.asc_GetMathInputType();
me.menuParagraphEquation.menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode);
me.menuParagraphEquation.menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX);
me.menuParagraphEquation.menu.items[8].setChecked(me.api.asc_IsInlineMath());
}
var frame_pr = value.paraProps.value.get_FramePr();
me.menuFrameAdvanced.setVisible(frame_pr !== undefined);
me.menuDropCapAdvanced.setVisible(frame_pr !== undefined);
@ -2057,6 +2200,7 @@ define([
me.menuParagraphAdvanced,
me.menuFrameAdvanced,
me.menuDropCapAdvanced,
me.menuParagraphEquation,
/** coauthoring begin **/
menuCommentSeparatorPara,
me.menuAddCommentPara,
@ -3077,7 +3221,15 @@ define([
txtWarnUrl: 'Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?',
textEditPoints: 'Edit Points',
textAccept: 'Accept Change',
textReject: 'Reject Change'
textReject: 'Reject Change',
advancedEquationText: 'Equation Settings',
unicodeText: 'Unicode',
latexText: 'LaTeX',
currProfText: 'Current - Professional',
currLinearText: 'Current - Linear',
allProfText: 'All - Professional',
allLinearText: 'All - Linear',
eqToInlineText: 'Change to Inline'
}, DE.Views.DocumentHolder || {}));
});

View file

@ -1657,6 +1657,14 @@
"DE.Views.DocumentHolder.txtWarnUrl": "Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?",
"DE.Views.DocumentHolder.updateStyleText": "Update %1 style",
"DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"DE.Views.DocumentHolder.advancedEquationText": "Equation Settings",
"DE.Views.DocumentHolder.unicodeText": "Unicode",
"DE.Views.DocumentHolder.latexText": "LaTeX",
"DE.Views.DocumentHolder.currProfText": "Current - Professional",
"DE.Views.DocumentHolder.currLinearText": "Current - Linear",
"DE.Views.DocumentHolder.allProfText": "All - Professional",
"DE.Views.DocumentHolder.allLinearText": "All - Linear",
"DE.Views.DocumentHolder.eqToInlineText": "Change to Inline",
"DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill",
"DE.Views.DropcapSettingsAdvanced.strDropcap": "Drop Cap",
"DE.Views.DropcapSettingsAdvanced.strMargins": "Margins",

View file

@ -408,6 +408,7 @@ define([
view.menuImgEditPoints.on('click', _.bind(me.onImgEditPoints, me));
view.menuShapeAdvanced.on('click', _.bind(me.onShapeAdvanced, me));
view.menuParagraphAdvanced.on('click', _.bind(me.onParagraphAdvanced, me));
view.menuChartAdvanced.on('click', _.bind(me.onChartAdvanced, me));
view.mnuGroupImg.on('click', _.bind(me.onGroupImg, me));
view.mnuUnGroupImg.on('click', _.bind(me.onUnGroupImg, me));
view.mnuArrangeFront.on('click', _.bind(me.onArrangeFront, me));
@ -1930,6 +1931,39 @@ define([
}
},
onChartAdvanced: function(item, e){
var me = this;
if (me.api) {
var selectedElements = me.api.getSelectedElements();
if (selectedElements && selectedElements.length > 0){
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].get_ObjectType();
elValue = selectedElements[i].get_ObjectValue();
if (Asc.c_oAscTypeSelectElement.Chart == elType) {
(new PE.Views.ChartSettingsAdvanced(
{
chartProps: elValue,
slideSize: PE.getController('Toolbar').currentPageSize,
handler: function(result, value) {
if (result == 'ok') {
if (me.api) {
me.api.ChartApply(value.chartProps);
}
}
me.editComplete();
Common.component.Analytics.trackEvent('DocumentHolder', 'Chart Settings Advanced');
}
})).show();
break;
}
}
}
}
},
onGroupImg: function(item) {
this.api && this.api.groupShapes();
this.editComplete();

View file

@ -1383,6 +1383,11 @@ define([
caption : me.advancedParagraphText
});
me.menuChartAdvanced = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-menu-chart',
caption : me.advancedChartText
});
var menuCommentParaSeparator = new Common.UI.MenuItem({
caption : '--'
});
@ -1542,7 +1547,6 @@ define([
});
me.menuChartEdit = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-menu-chart',
caption : me.editChartText
});
@ -2155,7 +2159,8 @@ define([
me.menuImageAdvanced.setVisible(isimage);
me.menuShapeAdvanced.setVisible(_.isUndefined(value.imgProps) && _.isUndefined(value.chartProps));
me.menuChartEdit.setVisible(_.isUndefined(value.imgProps) && !_.isUndefined(value.chartProps) && (_.isUndefined(value.shapeProps) || value.shapeProps.isChart));
menuImgShapeSeparator.setVisible(me.menuImageAdvanced.isVisible() || me.menuShapeAdvanced.isVisible() || me.menuChartEdit.isVisible());
me.menuChartAdvanced.setVisible(_.isUndefined(value.imgProps) && !_.isUndefined(value.chartProps) && (_.isUndefined(value.shapeProps) || value.shapeProps.isChart));
menuImgShapeSeparator.setVisible(me.menuImageAdvanced.isVisible() || me.menuShapeAdvanced.isVisible() || me.menuChartEdit.isVisible() || me.menuChartAdvanced.isVisible());
/** coauthoring begin **/
me.menuAddCommentImg.setVisible(me.api.can_AddQuotedComment()!==false && me.mode.canCoAuthoring && me.mode.canComments);
menuCommentSeparatorImg.setVisible(me.menuAddCommentImg.isVisible());
@ -2170,6 +2175,7 @@ define([
}
me.menuImageAdvanced.setDisabled(disabled);
me.menuShapeAdvanced.setDisabled(disabled);
me.menuChartAdvanced.setDisabled(disabled);
if (me.menuChartEdit.isVisible())
me.menuChartEdit.setDisabled(disabled);
@ -2195,6 +2201,7 @@ define([
me.menuImageAdvanced,
me.menuShapeAdvanced
,me.menuChartEdit
,me.menuChartAdvanced
/** coauthoring begin **/
,menuCommentSeparatorImg,
me.menuAddCommentImg,
@ -2434,7 +2441,8 @@ define([
txtWarnUrl: 'Clicking this link can be harmful to your device and data.<br>Are you sure you want to continue?',
textEditPoints: 'Edit Points',
txtMoveSlidesToEnd: 'Move Slide to End',
txtMoveSlidesToStart: 'Move Slide to Beginning'
txtMoveSlidesToStart: 'Move Slide to Beginning',
advancedChartText : 'Chart Advanced Settings'
}, PE.Views.DocumentHolder || {}));
});

View file

@ -1401,6 +1401,7 @@
"PE.Views.DocumentHolder.advancedParagraphText": "Paragraph Advanced Settings",
"PE.Views.DocumentHolder.advancedShapeText": "Shape Advanced Settings",
"PE.Views.DocumentHolder.advancedTableText": "Table Advanced Settings",
"PE.Views.DocumentHolder.advancedChartText": "Chart Advanced Settings",
"PE.Views.DocumentHolder.alignmentText": "Alignment",
"PE.Views.DocumentHolder.belowText": "Below",
"PE.Views.DocumentHolder.cellAlignText": "Cell Vertical Alignment",

View file

@ -45,7 +45,8 @@ define([
'spreadsheeteditor/main/app/collection/FormulaGroups',
'spreadsheeteditor/main/app/view/FormulaDialog',
'spreadsheeteditor/main/app/view/FormulaTab',
'spreadsheeteditor/main/app/view/FormulaWizard'
'spreadsheeteditor/main/app/view/FormulaWizard',
'spreadsheeteditor/main/app/view/WatchDialog'
], function () {
'use strict';
@ -80,7 +81,8 @@ define([
},
'FormulaTab': {
'function:apply': this.applyFunction,
'function:calculate': this.onCalculate
'function:calculate': this.onCalculate,
'function:watch': this.onWatch
},
'Toolbar': {
'function:apply': this.applyFunction,
@ -409,6 +411,24 @@ define([
}
},
onWatch: function(state) {
if (state) {
var me = this;
this._watchDlg = new SSE.Views.WatchDialog({
api: this.api,
handler: function(result) {
Common.NotificationCenter.trigger('edit:complete');
}
});
this._watchDlg.on('close', function(win){
me.formulaTab.btnWatch.toggle(false, true);
me._watchDlg = null;
}).show();
} else if (this._watchDlg)
this._watchDlg.close();
},
sCategoryAll: 'All',
sCategoryLast10: '10 last used',
sCategoryLogical: 'Logical',

View file

@ -2344,6 +2344,18 @@ define([
}
});
win.show();
} else if (id == Asc.c_oAscConfirm.ConfirmAddCellWatches) {
Common.UI.warning({
title: this.notcriticalErrorTitle,
msg: (data>Asc.c_nAscMaxAddCellWatchesCount) ? Common.Utils.String.format(this.confirmAddCellWatchesMax, Asc.c_nAscMaxAddCellWatchesCount) : Common.Utils.String.format(this.confirmAddCellWatches, data),
buttons: ['yes', 'no'],
primary: 'yes',
callback: _.bind(function(btn) {
if (apiCallback) {
apiCallback(btn === 'yes');
}
}, this)
});
}
},
@ -3598,7 +3610,10 @@ define([
textReconnect: 'Connection is restored',
errorCannotUseCommandProtectedSheet: 'You cannot use this command on a protected sheet. To use this command, unprotect the sheet.<br>You might be requested to enter a password.',
textRequestMacros: 'A macro makes a request to URL. Do you want to allow the request to the %1?',
textRememberMacros: 'Remember my choice for all macros'
textRememberMacros: 'Remember my choice for all macros',
confirmAddCellWatches: 'This action will add {0} cell watches.<br>Do you want to continue?',
confirmAddCellWatchesMax: 'This action will add only {0} cell watches by memory save reason.<br>Do you want to continue?'
}
})(), SSE.Controllers.Main || {}))
});

View file

@ -203,6 +203,10 @@
<span class="btn-slot text x-huge" id="slot-btn-named-range-huge"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-watch-window"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-calculate"></span>
</div>

View file

@ -0,0 +1,27 @@
<div class="settings-panel active">
<div class="inner-content">
<table cols="1" style="width: 100%;">
<tr>
<td class="padding-large">
<button type="button" class="btn btn-text-default auto sort-dialog-btn-text" id="watch-dialog-btn-add"><%= scope.textAdd %></button>
<div id="watch-dialog-btn-delete" style="display: inline-block;"></div>
</td>
</tr>
<tr>
<td>
<label class="header" style="width: 76px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textBook %></label><!--
--><label class="header" style="width: 70px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textSheet %></label><!--
--><label class="header" style="width: 70px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textName %></label><!--
--><label class="header" style="width: 70px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textCell %></label><!--
--><label class="header" style="width: 110px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textValue %></label><!--
--><label class="header" style="width: 140px;overflow: hidden;text-overflow: ellipsis;vertical-align: middle;"><%= scope.textFormula %></label>
</td>
</tr>
<tr>
<td class="padding-small">
<div id="watch-dialog-list" class="range-tableview" style="width:100%; height: 143px;"></div>
</td>
</tr>
</table>
</div>
</div>

View file

@ -69,6 +69,9 @@ define([
me.btnNamedRange.menu.on('item:click', function (menu, item, e) {
me.fireEvent('function:namedrange', [menu, item, e]);
});
me.btnWatch.on('click', function(b, e){
me.fireEvent('function:watch', [b.pressed]);
});
}
return {
options: {},
@ -318,6 +321,21 @@ define([
});
this.lockedControls.push(this.btnNamedRange);
this.btnWatch = new Common.UI.Button({
parentEl: $host.find('#slot-btn-watch-window'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon watch-window',
caption: this.txtWatch,
hint: this.tipWatch,
disabled: true,
enableToggle: true,
lock: [_set.editCell, _set.lostConnect, _set.coAuth],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.lockedControls.push(this.btnWatch);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -577,7 +595,9 @@ define([
textCalculateCurrentSheet: 'Calculate current sheet',
textAutomatic: 'Automatic',
textManual: 'Manual',
tipCalculateTheEntireWorkbook: 'Calculate the entire workbook'
tipCalculateTheEntireWorkbook: 'Calculate the entire workbook',
txtWatch: 'Watch Window',
tipWatch: 'Add cells to the Watch Window list'
}
}()), SSE.Views.FormulaTab || {}));
});

View file

@ -0,0 +1,280 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2022
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
/**
*
* WatchDialogDialog.js
*
* Created by Julia.Radzhabova on 24.06.22
* Copyright (c) 2022 Ascensio System SIA. All rights reserved.
*
*/
define([ 'text!spreadsheeteditor/main/app/template/WatchDialog.template',
'common/main/lib/view/AdvancedSettingsWindow',
'common/main/lib/component/ListView'
], function (contentTemplate) {
'use strict';
SSE.Views = SSE.Views || {};
SSE.Views.WatchDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
alias: 'WatchDialog',
contentWidth: 560,
height: 294,
modal: false,
buttons: null
},
initialize: function (options) {
var me = this;
_.extend(this.options, {
title: this.txtTitle,
template: [
'<div class="box" style="height:' + (this.options.height-85) + 'px;">',
'<div class="content-panel" style="padding: 0;">' + _.template(contentTemplate)({scope: this}) + '</div>',
'</div>',
'<div class="footer center">',
'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">' + this.closeButtonText + '</button>',
'</div>'
].join('')
}, options);
this.api = options.api;
this.handler = options.handler;
this.wrapEvents = {
onRefreshWatchList: _.bind(this.refreshList, this)
};
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
},
render: function () {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
var me = this;
this.watchList = new Common.UI.ListView({
el: $('#watch-dialog-list', this.$window),
store: new Common.UI.DataViewStore(),
simpleAddMode: true,
itemTemplate: _.template([
'<div id="<%= id %>" class="list-item" style="width: 100%;display:inline-block;pointer-events:none;">',
'<div style="width:70px;padding-right: 5px;"><%= Common.Utils.String.htmlEncode(book) %></div>',
'<div style="width:70px;padding-right: 5px;"><%= Common.Utils.String.htmlEncode(sheet) %></div>',
'<div style="width:70px;padding-right: 5px;"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div style="width:70px;padding-right: 5px;"><%= cell %></div>',
'<div style="width:110px;padding-right: 5px;"><%= value %></div>',
'<div style="width:135px;"><%= formula %></div>',
'</div>'
].join('')),
tabindex: 1
});
this.watchList.on('item:select', _.bind(this.onSelectWatch, this))
.on('item:keydown', _.bind(this.onKeyDown, this));
this.btnAdd = new Common.UI.Button({
el: $('#watch-dialog-btn-add', this.$window)
});
this.btnAdd.on('click', _.bind(this.onAddWatch, this, false));
this.btnDelete = new Common.UI.Button({
parentEl: $('#watch-dialog-btn-delete', this.$window),
cls: 'btn-text-split-default auto',
caption: this.textDelete,
split: true,
menu : new Common.UI.Menu({
style: 'min-width:100px;',
items: [
{
caption: this.textDelete,
value: 0
},
{
caption: this.textDeleteAll,
value: 1
}]
})
});
$(this.btnDelete.cmpEl.find('button')[0]).css('min-width', '87px');
this.btnDelete.on('click', _.bind(this.onDeleteWatch, this));
this.btnDelete.menu.on('item:click', _.bind(this.onDeleteMenu, this));
this.afterRender();
},
afterRender: function() {
this._setDefaults();
},
getFocusedComponents: function() {
return [ this.btnAdd, this.btnDelete, this.watchList ];
},
getDefaultFocusableComponent: function () {
return this.watchList;
},
_setDefaults: function (props) {
this.refreshList();
this.api.asc_registerCallback('asc_onUpdateCellWatches', this.wrapEvents.onRefreshWatchList);
},
refreshList: function(watches) {
if (watches) { // change existing watches
for (var idx in watches) {
if (watches.hasOwnProperty(idx)) {
var index = parseInt(idx),
item = watches[idx],
store = this.watchList.store;
if (index>=0 && index<store.length) {
var rec = store.at(index);
rec.set({
book: item.asc_getWorkbook(),
sheet: item.asc_getSheet(),
name: item.asc_getName(),
cell: item.asc_getCell(),
value: item.asc_getValue(),
formula: item.asc_getFormula(),
props: item
});
}
}
}
} else { // get list of watches
var arr = [];
watches = this.api.asc_getCellWatches();
if (watches) {
for (var i=0; i<watches.length; i++) {
var watch = watches[i];
arr.push({
book: watch.asc_getWorkbook(),
sheet: watch.asc_getSheet(),
name: watch.asc_getName(),
cell: watch.asc_getCell(),
value: watch.asc_getValue(),
formula: watch.asc_getFormula(),
props: watch
});
}
}
this.watchList.store.reset(arr);
if (this._deletedIndex!==undefined) {
var store = this.watchList.store;
(store.length>0) && this.watchList.selectByIndex(this._deletedIndex<store.length ? this._deletedIndex : store.length-1);
this.watchList.scrollToRecord(this.watchList.getSelectedRec());
this._fromKeyDown && this.watchList.focus();
this._fromKeyDown = false;
this._deletedIndex=undefined;
}
this.updateButtons();
}
},
onAddWatch: function() {
var range = '';
var me = this;
if (me.api) {
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
me.api.asc_addCellWatches(dlg.getSettings());
}
};
var win = new SSE.Views.CellRangeDialog({
handler: handlerDlg
}).on('close', function() {
me.show();
});
var xy = me.$window.offset();
me.hide();
win.show(xy.left + 65, xy.top + 77);
win.setSettings({
api : me.api,
range : me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()) + '!' + me.api.asc_getActiveRangeStr(Asc.referenceType.A),
type : Asc.c_oAscSelectionDialogType.Chart
});
}
},
onDeleteWatch: function() {
var rec = this.watchList.getSelectedRec();
if (rec) {
this._deletedIndex = this.watchList.store.indexOf(rec);
this.api.asc_deleteCellWatches([rec.get('props')]);
}
},
onDeleteMenu: function(menu, item) {
if (item.value == 1) {
this.api.asc_deleteCellWatches(undefined, true);
} else
this.onDeleteWatch();
},
onSelectWatch: function(lisvView, itemView, record) {
this.updateButtons();
},
onKeyDown: function (lisvView, record, e) {
if (e.keyCode==Common.UI.Keys.DELETE && !this.btnDelete.isDisabled()) {
this._fromKeyDown = true;
this.onDeleteWatch();
}
},
updateButtons: function() {
this.btnDelete.setDisabled(this.watchList.store.length<1 || !this.watchList.getSelectedRec());
this.watchList.scroller && this.watchList.scroller.update({alwaysVisibleY: true});
},
close: function () {
this.api.asc_unregisterCallback('asc_onUpdateCellWatches', this.wrapEvents.onRefreshWatchList);
Common.Views.AdvancedSettingsWindow.prototype.close.call(this);
},
txtTitle: 'Watch Window',
textAdd: 'Add watch',
textDelete: 'Delete watch',
textDeleteAll: 'Delete all',
closeButtonText: 'Close',
textBook: 'Book',
textSheet: 'Sheet',
textName: 'Name',
textCell: 'Cell',
textValue: 'Value',
textFormula: 'Formula'
}, SSE.Views.WatchDialog || {}));
});

View file

@ -1105,6 +1105,8 @@
"SSE.Controllers.Main.warnNoLicense": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only.<br>Contact %1 sales team for personal upgrade terms.",
"SSE.Controllers.Main.warnNoLicenseUsers": "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.",
"SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.",
"SSE.Controllers.Main.confirmAddCellWatches": "This action will add {0} cell watches.<br>Do you want to continue?",
"SSE.Controllers.Main.confirmAddCellWatchesMax": "This action will add only {0} cell watches by memory save reason.<br>Do you want to continue?",
"SSE.Controllers.Print.strAllSheets": "All Sheets",
"SSE.Controllers.Print.textFirstCol": "First column",
"SSE.Controllers.Print.textFirstRow": "First row",
@ -2419,6 +2421,8 @@
"SSE.Views.FormulaTab.txtFormulaTip": "Insert function",
"SSE.Views.FormulaTab.txtMore": "More functions",
"SSE.Views.FormulaTab.txtRecent": "Recently used",
"SSE.Views.FormulaTab.txtWatch": "Watch Window",
"SSE.Views.FormulaTab.tipWatch": "Add cells to the Watch Window list",
"SSE.Views.FormulaWizard.textAny": "any",
"SSE.Views.FormulaWizard.textArgument": "Argument",
"SSE.Views.FormulaWizard.textFunction": "Function",
@ -3693,6 +3697,17 @@
"SSE.Views.ViewTab.tipCreate": "Create sheet view",
"SSE.Views.ViewTab.tipFreeze": "Freeze panes",
"SSE.Views.ViewTab.tipSheetView": "Sheet view",
"SSE.Views.WatchDialog.txtTitle": "Watch Window",
"SSE.Views.WatchDialog.textAdd": "Add watch",
"SSE.Views.WatchDialog.textDelete": "Delete watch",
"SSE.Views.WatchDialog.textDeleteAll": "Delete all",
"SSE.Views.WatchDialog.closeButtonText": "Close",
"SSE.Views.WatchDialog.textBook": "Book",
"SSE.Views.WatchDialog.textSheet": "Sheet",
"SSE.Views.WatchDialog.textName": "Name",
"SSE.Views.WatchDialog.textCell": "Cell",
"SSE.Views.WatchDialog.textValue": "Value",
"SSE.Views.WatchDialog.textFormula": "Formula",
"SSE.Views.WBProtection.hintAllowRanges": "Allow edit ranges",
"SSE.Views.WBProtection.hintProtectSheet": "Protect sheet",
"SSE.Views.WBProtection.hintProtectWB": "Protect workbook",

View file

@ -3689,6 +3689,9 @@
"SSE.Views.ViewTab.tipCreate": "Создать представление листа",
"SSE.Views.ViewTab.tipFreeze": "Закрепить области",
"SSE.Views.ViewTab.tipSheetView": "Представление листа",
"SSE.Views.WatchDialog.textAdd": "Добавить контрольное значение",
"SSE.Views.WatchDialog.textDelete": "Удалить контрольное значение",
"SSE.Views.WatchDialog.textDeleteAll": "Удалить все",
"SSE.Views.WBProtection.hintAllowRanges": "Разрешить редактировать диапазоны",
"SSE.Views.WBProtection.hintProtectSheet": "Защитить лист",
"SSE.Views.WBProtection.hintProtectWB": "Защитить книгу",

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B