[SSE] Disable workbook actions when workbook is protected
This commit is contained in:
parent
56200c7987
commit
be22bc97a5
|
@ -71,6 +71,7 @@ define([
|
|||
this.api = api;
|
||||
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this));
|
||||
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this));
|
||||
this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this));
|
||||
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
|
||||
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
||||
}
|
||||
|
@ -408,6 +409,10 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onChangeProtectWorkbook: function() {
|
||||
Common.Utils.lockControls(SSE.enumLock.wbLock, this.api.asc_isProtectedWorkbook(), {array: [this.view.btnDataFromText]});
|
||||
},
|
||||
|
||||
onApiSheetChanged: function() {
|
||||
if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return;
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ define([
|
|||
/** coauthoring begin **/
|
||||
this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onWorkbookLocked, this));
|
||||
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this));
|
||||
this.api.asc_registerCallback('asc_onChangeProtectWorkbook',_.bind(this.onChangeProtectWorkbook, this));
|
||||
/** coauthoring end **/
|
||||
this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this));
|
||||
this.api.asc_registerCallback('asc_onFilterInfo', _.bind(this.onApiFilterInfo , this));
|
||||
|
@ -154,7 +155,8 @@ define([
|
|||
this.statusbar.tabbar[locked?'addClass':'removeClass']('coauth-locked');
|
||||
this.statusbar.btnAddWorksheet.setDisabled(locked || this.api.isCellEdited || this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.Chart ||
|
||||
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable||
|
||||
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
|
||||
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles ||
|
||||
this.api.asc_isProtectedWorkbook());
|
||||
var item, i = this.statusbar.tabbar.getCount();
|
||||
while (i-- > 0) {
|
||||
item = this.statusbar.tabbar.getAt(i);
|
||||
|
@ -170,16 +172,30 @@ define([
|
|||
|
||||
onWorksheetLocked: function(index,locked) {
|
||||
var count = this.statusbar.tabbar.getCount(), tab;
|
||||
var wbprotected = this.api.asc_isProtectedWorkbook();
|
||||
for (var i = count; i-- > 0; ) {
|
||||
tab = this.statusbar.tabbar.getAt(i);
|
||||
if (index == tab.sheetindex) {
|
||||
tab[locked?'addClass':'removeClass']('coauth-locked');
|
||||
tab.isLockTheDrag = locked || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
|
||||
tab.isLockTheDrag = locked || wbprotected || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
|
||||
tab.$el.children(':first-child').attr('draggable', tab.isLockTheDrag?'false':'true');
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onChangeProtectWorkbook: function() {
|
||||
this.statusbar.btnAddWorksheet.setDisabled(this.api.isCellEdited || this.api.asc_isWorkbookLocked() || this.api.asc_isProtectedWorkbook() || this.statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None);
|
||||
var count = this.statusbar.tabbar.getCount(), tab;
|
||||
var wbprotected = this.api.asc_isProtectedWorkbook();
|
||||
for (var i = count; i-- > 0; ) {
|
||||
tab = this.statusbar.tabbar.getAt(i);
|
||||
var islocked = tab.hasClass('coauth-locked');
|
||||
tab.isLockTheDrag = islocked || wbprotected || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
|
||||
tab.$el.children(':first-child').attr('draggable', tab.isLockTheDrag?'false':'true');
|
||||
}
|
||||
},
|
||||
|
||||
/** coauthoring end **/
|
||||
|
||||
onApiMathChanged: function(info) {
|
||||
|
@ -213,7 +229,7 @@ define([
|
|||
statusbar.btnZoomUp.setDisabled(disable);
|
||||
statusbar.btnZoomDown.setDisabled(disable);
|
||||
statusbar.labelZoom[disable?'addClass':'removeClass']('disabled');
|
||||
statusbar.btnAddWorksheet.setDisabled(disable || this.api.asc_isWorkbookLocked() || statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None);
|
||||
statusbar.btnAddWorksheet.setDisabled(disable || this.api.asc_isWorkbookLocked() || this.api.asc_isProtectedWorkbook() || statusbar.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None);
|
||||
|
||||
statusbar.$el.find('#statusbar_bottom li span').attr('oo_editor_input', !disableAdd);
|
||||
|
||||
|
@ -244,15 +260,16 @@ define([
|
|||
onRangeDialogMode: function (mode) {
|
||||
var islocked = this.statusbar.tabbar.hasClass('coauth-locked'),
|
||||
currentIdx = this.api.asc_getActiveWorksheetIndex();
|
||||
this.statusbar.btnAddWorksheet.setDisabled(islocked || this.api.isCellEdited || mode!=Asc.c_oAscSelectionDialogType.None);
|
||||
this.statusbar.btnAddWorksheet.setDisabled(islocked || this.api.isCellEdited || this.api.asc_isProtectedWorkbook() || mode!=Asc.c_oAscSelectionDialogType.None);
|
||||
|
||||
var item, i = this.statusbar.tabbar.getCount();
|
||||
var wbprotected = this.api.asc_isProtectedWorkbook();
|
||||
while (i-- > 0) {
|
||||
item = this.statusbar.tabbar.getAt(i);
|
||||
if (item.sheetindex !== currentIdx) {
|
||||
item.disable(mode==Asc.c_oAscSelectionDialogType.FormatTable || mode==Asc.c_oAscSelectionDialogType.PrintTitles);
|
||||
}
|
||||
item.isLockTheDrag = (item.hasClass('coauth-locked') || (mode!=Asc.c_oAscSelectionDialogType.None));
|
||||
item.isLockTheDrag = (item.hasClass('coauth-locked') || wbprotected || (mode!=Asc.c_oAscSelectionDialogType.None));
|
||||
}
|
||||
this.statusbar.rangeSelectionMode = mode;
|
||||
},
|
||||
|
|
|
@ -130,7 +130,7 @@ define([
|
|||
caption: this.capDataFromText,
|
||||
menu: !this.toolbar.mode.isDesktopApp,
|
||||
disabled: true,
|
||||
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.lostConnect, _set.coAuth]
|
||||
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.sheetLock, _set.wbLock, _set.lostConnect, _set.coAuth]
|
||||
});
|
||||
this.lockedControls.push(this.btnDataFromText);
|
||||
|
||||
|
|
|
@ -498,6 +498,7 @@ define([
|
|||
var wc = this.api.asc_getWorksheetsCount(), i = -1;
|
||||
var hidentems = [], items = [], tab, locked, name;
|
||||
var sindex = this.api.asc_getActiveWorksheetIndex();
|
||||
var wbprotected = this.api.asc_isProtectedWorkbook();
|
||||
|
||||
while (++i < wc) {
|
||||
locked = me.api.asc_isWorksheetLockedOrDeleted(i);
|
||||
|
@ -509,7 +510,7 @@ define([
|
|||
label : me.api.asc_getWorksheetName(i),
|
||||
// reorderable : !locked,
|
||||
cls : locked ? 'coauth-locked':'',
|
||||
isLockTheDrag : locked || me.mode.isDisconnected,
|
||||
isLockTheDrag : locked || me.mode.isDisconnected || wbprotected,
|
||||
iconCls : 'btn-sheet-view',
|
||||
iconTitle : name,
|
||||
iconVisible : name!==''
|
||||
|
@ -538,7 +539,7 @@ define([
|
|||
if (!this.tabbar.isTabVisible(sindex))
|
||||
this.tabbar.setTabVisible(sindex);
|
||||
|
||||
this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || me.api.isCellEdited);
|
||||
this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || me.api.asc_isProtectedWorkbook() || me.api.isCellEdited);
|
||||
$('#status-label-zoom').text(Common.Utils.String.format(this.zoomText, Math.floor((this.api.asc_getZoom() +.005)*100)));
|
||||
|
||||
me.fireEvent('sheet:changed', [me, sindex]);
|
||||
|
@ -647,15 +648,16 @@ define([
|
|||
}
|
||||
|
||||
var isdoclocked = this.api.asc_isWorkbookLocked();
|
||||
var isdocprotected = this.api.asc_isProtectedWorkbook();
|
||||
|
||||
this.tabMenu.items[0].setDisabled(isdoclocked);
|
||||
this.tabMenu.items[1].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[2].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[3].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[4].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[5].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[6].setDisabled(isdoclocked);
|
||||
this.tabMenu.items[7].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[0].setDisabled(isdoclocked || isdocprotected);
|
||||
this.tabMenu.items[1].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[2].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[3].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected);
|
||||
this.tabMenu.items[7].setDisabled(issheetlocked || isdocprotected);
|
||||
|
||||
if (select.length === 1) {
|
||||
this.tabMenu.items[10].hide();
|
||||
|
@ -663,8 +665,8 @@ define([
|
|||
this.tabMenu.items[10].show();
|
||||
}
|
||||
|
||||
this.tabMenu.items[9].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[10].setDisabled(issheetlocked);
|
||||
this.tabMenu.items[9].setDisabled(issheetlocked || isdocprotected);
|
||||
this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected);
|
||||
|
||||
this.api.asc_closeCellEditor();
|
||||
this.api.asc_enableKeyEvents(false);
|
||||
|
|
|
@ -98,7 +98,8 @@ define([
|
|||
cantSort: 'cant-sort',
|
||||
pivotLock: 'pivot-lock',
|
||||
tableHasSlicer: 'table-has-slicer',
|
||||
sheetView: 'sheet-view'
|
||||
sheetView: 'sheet-view',
|
||||
wbLock: 'workbook-lock'
|
||||
};
|
||||
|
||||
SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({
|
||||
|
|
Loading…
Reference in a new issue