[SSE] Fix protected ranges
This commit is contained in:
parent
897c3ca1ac
commit
a429b83a3d
|
@ -179,8 +179,6 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
var me = this,
|
var me = this,
|
||||||
store = this.rangeList.store,
|
store = this.rangeList.store,
|
||||||
val = store.length;
|
val = store.length;
|
||||||
this.btnEditRange.setDisabled(!val);
|
|
||||||
this.btnDeleteRange.setDisabled(!val);
|
|
||||||
if (val>0) {
|
if (val>0) {
|
||||||
if (selectedItem===undefined || selectedItem===null) selectedItem = 0;
|
if (selectedItem===undefined || selectedItem===null) selectedItem = 0;
|
||||||
if (_.isNumber(selectedItem)) {
|
if (_.isNumber(selectedItem)) {
|
||||||
|
@ -191,7 +189,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
} else if (selectedItem){ // object
|
} else if (selectedItem){ // object
|
||||||
var rec = store.findWhere({name: selectedItem.asc_getName(true), scope: selectedItem.asc_getScope()});
|
var rec = store.findWhere({name: selectedItem.asc_getName(true)});
|
||||||
if (rec) {
|
if (rec) {
|
||||||
this.rangeList.selectRecord(rec);
|
this.rangeList.selectRecord(rec);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -203,6 +201,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0)
|
if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0)
|
||||||
this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me));
|
this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me));
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
_.delay(function () {
|
_.delay(function () {
|
||||||
me.rangeList.scroller.update({alwaysVisibleY: true});
|
me.rangeList.scroller.update({alwaysVisibleY: true});
|
||||||
}, 100, this);
|
}, 100, this);
|
||||||
|
@ -243,7 +242,13 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
var me = this,
|
var me = this,
|
||||||
xy = me.$window.offset(),
|
xy = me.$window.offset(),
|
||||||
rec = this.rangeList.getSelectedRec(),
|
rec = this.rangeList.getSelectedRec(),
|
||||||
props = isEdit ? rec.get('props') : new Asc.CProtectedRange();
|
props;
|
||||||
|
if (isEdit)
|
||||||
|
props = rec.get('props')
|
||||||
|
else {
|
||||||
|
props = new Asc.CProtectedRange();
|
||||||
|
props.asc_setSqref(me.api.asc_getActiveRangeStr(Asc.referenceType.A));
|
||||||
|
}
|
||||||
|
|
||||||
var win = new SSE.Views.ProtectDialog({
|
var win = new SSE.Views.ProtectDialog({
|
||||||
title : isEdit ? me.txtEditRange : me.txtNewRange,
|
title : isEdit ? me.txtEditRange : me.txtNewRange,
|
||||||
|
@ -267,9 +272,13 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
pwd: props.asc_isPassword(),
|
pwd: props.asc_isPassword(),
|
||||||
range: props.asc_getSqref(),
|
range: props.asc_getSqref(),
|
||||||
props: props,
|
props: props,
|
||||||
|
isNew: true,
|
||||||
lock: false,
|
lock: false,
|
||||||
lockuser: this.guestText
|
lockuser: this.guestText
|
||||||
});
|
});
|
||||||
|
me.rangeList.selectByIndex(me.rangeList.store.length-1);
|
||||||
|
me.rangeList.scrollToRecord(me.rangeList.getSelectedRec());
|
||||||
|
me.updateButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,16 +295,21 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
var store = this.rangeList.store,
|
var store = this.rangeList.store,
|
||||||
rec = this.rangeList.getSelectedRec();
|
rec = this.rangeList.getSelectedRec();
|
||||||
if (rec) {
|
if (rec) {
|
||||||
this.deletedArr.push(rec.get('props'));
|
!rec.get('isNew') && this.deletedArr.push(rec.get('props'));
|
||||||
var index = store.indexOf(rec);
|
var index = store.indexOf(rec);
|
||||||
store.remove(rec);
|
store.remove(rec);
|
||||||
(this.rangeList.length>0) && this.rangeList.selectByIndex(index);
|
(this.rangeList.length>0) && this.rangeList.selectByIndex(index);
|
||||||
this.rangeList.scrollToRecord(this.rangeList.getSelectedRec());
|
this.rangeList.scrollToRecord(this.rangeList.getSelectedRec());
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
getSettings: function() {
|
getSettings: function() {
|
||||||
return {arr: [], deletedArr: this.deletedArr};
|
var arr = [];
|
||||||
|
this.rangeList.store.each(function(item){
|
||||||
|
arr.push(item.get('props'));
|
||||||
|
});
|
||||||
|
return {arr: arr, deletedArr: this.deletedArr};
|
||||||
},
|
},
|
||||||
|
|
||||||
onPrimary: function() {
|
onPrimary: function() {
|
||||||
|
@ -331,9 +345,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.currentNamedRange = _.indexOf(this.rangeList.store.models, record);
|
this.currentNamedRange = _.indexOf(this.rangeList.store.models, record);
|
||||||
this.btnEditRange.setDisabled(rawData.lock);
|
|
||||||
this.btnDeleteRange.setDisabled(rawData.lock);
|
|
||||||
}
|
}
|
||||||
|
this.updateButtons();
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function () {
|
hide: function () {
|
||||||
|
@ -397,7 +410,15 @@ define([ 'text!spreadsheeteditor/main/app/template/ProtectRangesDlg.template',
|
||||||
this.updateButtons();
|
this.updateButtons();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateButtons: function() {
|
||||||
|
var rec = this.rangeList.getSelectedRec(),
|
||||||
|
lock = rec ? rec.get('lock') : false,
|
||||||
|
length = this.rangeList.store.length;
|
||||||
|
this.btnDeleteRange.setDisabled(length<1 || lock);
|
||||||
|
this.btnEditRange.setDisabled(length<1 || lock);
|
||||||
|
},
|
||||||
|
|
||||||
txtTitle: 'Allow Users to Edit Ranges',
|
txtTitle: 'Allow Users to Edit Ranges',
|
||||||
textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells)',
|
textRangesDesc: 'Ranges unlocked by a password when sheet is protected (this works only for locked cells)',
|
||||||
textTitle: 'Title',
|
textTitle: 'Title',
|
||||||
|
|
Loading…
Reference in a new issue