[SSE mobile] disable 'Add' and 'Edit' options for locked cell
This commit is contained in:
parent
4a95770c71
commit
0b5edaaee0
|
@ -52,6 +52,10 @@ define([
|
||||||
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
|
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend((function() {
|
||||||
// private
|
// private
|
||||||
var _backUrl;
|
var _backUrl;
|
||||||
|
var locked = {
|
||||||
|
book: false,
|
||||||
|
sheet: false
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
models: [],
|
models: [],
|
||||||
|
@ -78,6 +82,12 @@ define([
|
||||||
|
|
||||||
this.api.asc_registerCallback('asc_onCanUndoChanged', _.bind(this.onApiCanRevert, this, 'undo'));
|
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_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) {
|
setMode: function (mode) {
|
||||||
|
@ -134,6 +144,18 @@ define([
|
||||||
|
|
||||||
// API handlers
|
// 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) {
|
onApiCanRevert: function(which, can) {
|
||||||
if (which == 'undo') {
|
if (which == 'undo') {
|
||||||
$('#toolbar-undo').toggleClass('disabled', !can);
|
$('#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',
|
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.',
|
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',
|
leaveButtonText : 'Leave this Page',
|
||||||
|
|
|
@ -83,6 +83,9 @@ define([
|
||||||
|
|
||||||
$('.view-main .navbar').on('addClass removeClass', _.bind(me.onDisplayMainNavbar, me));
|
$('.view-main .navbar').on('addClass removeClass', _.bind(me.onDisplayMainNavbar, me));
|
||||||
|
|
||||||
|
this.$btnEdit = $el.find('#toolbar-edit');
|
||||||
|
this.$btnAdd = $el.find('#toolbar-add');
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -136,6 +139,14 @@ define([
|
||||||
// Settings
|
// Settings
|
||||||
showSettings: function () {
|
showSettings: function () {
|
||||||
SSE.getController('Settings').showModal();
|
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 || {}))
|
})(), SSE.Views.Toolbar || {}))
|
||||||
|
|
Loading…
Reference in a new issue