Merge pull request #570 from ONLYOFFICE/fix/bugfix

Fix/bugfix
This commit is contained in:
Julia Radzhabova 2020-11-17 15:57:37 +03:00 committed by GitHub
commit d98a8ef05f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 13 deletions

View file

@ -82,7 +82,8 @@ define([
onLaunch: function () { onLaunch: function () {
this._state = { this._state = {
prcontrolsdisable:undefined, prcontrolsdisable:undefined,
in_object: false in_object: false,
in_header: false
}; };
Common.Gateway.on('setactionlink', function (url) { Common.Gateway.on('setactionlink', function (url) {
console.log('url with actions: ' + url); console.log('url with actions: ' + url);
@ -154,6 +155,7 @@ define([
} }
this._state.prcontrolsdisable = paragraph_locked || header_locked; this._state.prcontrolsdisable = paragraph_locked || header_locked;
this._state.in_object = in_image || in_table || in_equation; this._state.in_object = in_image || in_table || in_equation;
this._state.in_header = in_header;
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false, control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false,
@ -461,6 +463,7 @@ define([
me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({ me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({
api: me.api, api: me.api,
crossRefProps: me.crossRefProps, crossRefProps: me.crossRefProps,
inHeader: me._state.in_header,
handler: function (result, settings) { handler: function (result, settings) {
if (result != 'ok') if (result != 'ok')
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);

View file

@ -101,6 +101,7 @@ define([
this.api = options.api; this.api = options.api;
this.options.tpl = _.template(this.template)(this.options); this.options.tpl = _.template(this.template)(this.options);
this._locked = false; this._locked = false;
this.inHeader = options.inHeader || false;
Common.UI.Window.prototype.initialize.call(this, this.options); Common.UI.Window.prototype.initialize.call(this, this.options);
}, },
@ -200,6 +201,33 @@ define([
afterRender: function() { afterRender: function() {
this._setDefaults(); this._setDefaults();
var me = this;
var onApiFocusObject = function(selectedObjects) {
var i = -1,
in_header = false;
while (++i < selectedObjects.length) {
if (selectedObjects[i].get_ObjectType() === Asc.c_oAscTypeSelectElement.Header) {
in_header = true;
break;
}
}
if (me.inHeader !== in_header) {
me.inHeader = in_header;
var rec = me.cmbReference.getSelectedRecord();
me.refreshReferenceTypes(me.cmbType.getSelectedRecord(), rec && (!me.inHeader || rec.value !== Asc.c_oAscDocumentRefenceToType.AboveBelow) ? rec.value : undefined);
}
};
var onApiEndCalculate = function() {
var rec = me.cmbType.getSelectedRecord();
rec && me.refreshReferences(rec.value);
};
this.api.asc_registerCallback('asc_onFocusObject', onApiFocusObject);
this.api.asc_registerCallback('asc_onEndCalculate', onApiEndCalculate);
this.on('close', function(obj){
me.api.asc_unregisterCallback('asc_onFocusObject', onApiFocusObject);
me.api.asc_unregisterCallback('asc_onEndCalculate', onApiEndCalculate);
});
}, },
_handleInput: function(state, fromButton) { _handleInput: function(state, fromButton) {
@ -285,8 +313,7 @@ define([
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textCaption }, { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textCaption },
{ value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum }, { value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum },
{ value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption }, { value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption },
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
]; ];
} else { } else {
type = record.value; type = record.value;
@ -297,8 +324,7 @@ define([
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull },
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText }, { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText }
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
]; ];
str = this.textWhichPara; str = this.textWhichPara;
break; break;
@ -308,8 +334,7 @@ define([
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum }, { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull }
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
]; ];
str = this.textWhichHeading; str = this.textWhichHeading;
break; break;
@ -319,8 +344,7 @@ define([
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
]; ];
str = this.textWhichBookmark; str = this.textWhichBookmark;
break; break;
@ -328,7 +352,6 @@ define([
arr = [ arr = [
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum }, { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum },
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm } { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm }
]; ];
str = this.textWhichNote; str = this.textWhichNote;
@ -337,15 +360,18 @@ define([
arr = [ arr = [
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum }, { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum },
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm } { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm }
]; ];
str = this.textWhichEndnote; str = this.textWhichEndnote;
break; break;
} }
} }
if (!this.inHeader)
arr.push({ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow });
this.cmbReference.setData(arr); this.cmbReference.setData(arr);
this.cmbReference.setValue(currentRef ? currentRef : arr[0].value);
var rec = this.cmbReference.store.findWhere({value: currentRef});
this.cmbReference.setValue(rec ? currentRef : arr[0].value);
this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord()); this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord());
this.lblWhich.text(str); this.lblWhich.text(str);
this.refreshReferences(type); this.refreshReferences(type);
@ -383,7 +409,7 @@ define([
arr.push({value: name}); arr.push({value: name});
} }
} }
} else { } else if (props) {
for (var i=0; i<props.length; i++) { for (var i=0; i<props.length; i++) {
arr.push({value: props[i].asc_getText(), para: props[i]}); arr.push({value: props[i].asc_getText(), para: props[i]});
} }
@ -399,6 +425,8 @@ define([
}, },
onReferenceSelected: function(combo, record) { onReferenceSelected: function(combo, record) {
if (!record) return;
var refType = record.value, var refType = record.value,
typeRec = this.cmbType.getSelectedRecord(), typeRec = this.cmbType.getSelectedRecord(),
type = (typeRec.type==1 || typeRec.value>4) ? 5 : typeRec.value; type = (typeRec.type==1 || typeRec.value>4) ? 5 : typeRec.value;