[SSE mobile] disable 'Add' and 'Edit' options for locked cell

This commit is contained in:
Maxim Kadushkin 2017-01-09 11:56:40 +03:00
parent 4a95770c71
commit 0b5edaaee0
2 changed files with 56 additions and 0 deletions

View file

@ -52,6 +52,10 @@ define([
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
// private
var _backUrl;
var locked = {
book: false,
sheet: false
};
return {
models: [],
@ -78,6 +82,12 @@ define([
this.api.asc_registerCallback('asc_onCanUndoChanged', _.bind(this.onApiCanRevert, this, 'undo'));
this.api.asc_registerCallback('asc_onCanRedoChanged', _.bind(this.onApiCanRevert, this, 'redo'));
this.api.asc_registerCallback('asc_onSelectionChanged', this.onApiSelectionChanged.bind(this));
this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onApiWorkbookLocked, this));
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onApiWorksheetLocked, this));
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, this));
Common.NotificationCenter.on('sheet:active', this.onApiActiveSheetChanged.bind(this));
},
setMode: function (mode) {
@ -134,6 +144,18 @@ define([
// API handlers
onApiWorkbookLocked: function (l) {
locked.book = l;
},
onApiWorksheetLocked: function (l) {
locked.sheet = l;
},
onApiActiveSheetChanged: function (index) {
locked.sheet = this.api.asc_isWorksheetLockedOrDeleted(index);
},
onApiCanRevert: function(which, can) {
if (which == 'undo') {
$('#toolbar-undo').toggleClass('disabled', !can);
@ -142,6 +164,29 @@ define([
}
},
onApiSelectionChanged: function(info) {
var islocked = locked.book || locked.sheet;
if ( !islocked ) {
switch (info.asc_getFlags().asc_getSelectionType()) {
case Asc.c_oAscSelectionType.RangeCells:
islocked = info.asc_getLocked();
break;
case Asc.c_oAscSelectionType.RangeChart:
var objects = this.api.asc_getGraphicObjectProps();
for ( var i in objects ) {
if ( objects[i].asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image ) {
if ((islocked = objects[i].asc_getObjectValue().asc_getLocked()))
break;
}
}
break;
}
}
this.getView('Toolbar').disableControl(['add', 'edit'], islocked);
},
dlgLeaveTitleText : 'You leave the application',
dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.',
leaveButtonText : 'Leave this Page',

View file

@ -83,6 +83,9 @@ define([
$('.view-main .navbar').on('addClass removeClass', _.bind(me.onDisplayMainNavbar, me));
this.$btnEdit = $el.find('#toolbar-edit');
this.$btnAdd = $el.find('#toolbar-add');
return me;
},
@ -136,6 +139,14 @@ define([
// Settings
showSettings: function () {
SSE.getController('Settings').showModal();
},
disableControl: function (opts, val) {
if (!(opts.indexOf('add') < 0))
this.$btnAdd.toggleClass('disabled', val);
if (!(opts.indexOf('edit') < 0))
this.$btnEdit.toggleClass('disabled', val);
}
}
})(), SSE.Views.Toolbar || {}))