[DE] Cross-reference: add labels from caption dialog

This commit is contained in:
Julia Radzhabova 2020-09-23 13:08:37 +03:00
parent 20954eedea
commit 770c62fb13

View file

@ -88,7 +88,7 @@ define([
'</tr>', '</tr>',
'<tr>', '<tr>',
'<td colspan="2" style="width: 100%;">', '<td colspan="2" style="width: 100%;">',
'<label>' + this.textWhich + '</label>', '<label id="id-dlg-cross-which">' + this.textWhich + '</label>',
'<div id="id-dlg-cross-list" class="no-borders" style="width:100%; height:161px;margin-top: 2px; "></div>', '<div id="id-dlg-cross-list" class="no-borders" style="width:100%; height:161px;margin-top: 2px; "></div>',
'</td>', '</td>',
'</tr>', '</tr>',
@ -110,9 +110,27 @@ define([
$window = this.getChild(); $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
var arr = Common.Utils.InternalSettings.get("de-settings-captions");
if (arr==null || arr==undefined) {
arr = Common.localStorage.getItem("de-settings-captions") || '';
Common.Utils.InternalSettings.set("de-settings-captions", arr);
}
arr = arr ? JSON.parse(arr) : [];
// 0 - not removable
arr = arr.concat([{ value: 5, displayValue: this.textEquation },
{ value: 6, displayValue: this.textFigure },
{ value: 7, displayValue: this.textTable }
]);
arr.sort(function(a,b){
var sa = a.displayValue.toLowerCase(),
sb = b.displayValue.toLowerCase();
return sa>sb ? 1 : (sa<sb ? -1 : 0);
});
this.cmbType = new Common.UI.ComboBox({ this.cmbType = new Common.UI.ComboBox({
el : $window.find('#id-dlg-cross-type'), el : $window.find('#id-dlg-cross-type'),
menuStyle : 'min-width: 100%;', menuStyle : 'min-width: 100%;max-height: 233px;',
editable : false, editable : false,
cls : 'input-group-nr', cls : 'input-group-nr',
data : [ data : [
@ -120,17 +138,14 @@ define([
{ value: 1, displayValue: this.textHeading }, { value: 1, displayValue: this.textHeading },
{ value: 2, displayValue: this.textBookmark }, { value: 2, displayValue: this.textBookmark },
{ value: 3, displayValue: this.textFootnote }, { value: 3, displayValue: this.textFootnote },
{ value: 4, displayValue: this.textEndnote }, { value: 4, displayValue: this.textEndnote }
{ value: 5, displayValue: this.textEquation }, ].concat(arr)
{ value: 6, displayValue: this.textFigure },
{ value: 7, displayValue: this.textTable }
]
}); });
this.cmbType.on('selected', _.bind(this.onTypeSelected, this)); this.cmbType.on('selected', _.bind(this.onTypeSelected, this));
this.cmbReference = new Common.UI.ComboBox({ this.cmbReference = new Common.UI.ComboBox({
el : $window.find('#id-dlg-cross-ref'), el : $window.find('#id-dlg-cross-ref'),
menuStyle : 'min-width: 100%;max-height: 183px;', menuStyle : 'min-width: 100%;max-height: 233px;',
editable : false, editable : false,
cls : 'input-group-nr', cls : 'input-group-nr',
data : [] data : []
@ -176,6 +191,8 @@ define([
}); });
this.refList.on('item:select', _.bind(this.onSelectReference, this)); this.refList.on('item:select', _.bind(this.onSelectReference, this));
this.lblWhich = $window.find('#id-dlg-cross-which');
this.afterRender(); this.afterRender();
}, },
@ -214,68 +231,75 @@ define([
}, },
onTypeSelected: function (combo, record) { onTypeSelected: function (combo, record) {
var arr = []; var arr = [],
switch (record.value) { str = this.textWhich;
case 0: // paragraph if (record.type==1 || record.value > 4) {
arr = [ // custom labels from caption dialog and Equation, Figure, Table
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, arr = [
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textCaption },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, { value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, { value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption },
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
]; ];
break; } else {
case 1: // heading switch (record.value) {
arr = [ case 0: // paragraph
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textHeadingText }, arr = [
{ 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.textParaNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull }, { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText },
]; { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
break; ];
case 2: // bookmark str = this.textWhichPara;
arr = [ break;
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textBookmarkText }, case 1: // heading
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, arr = [
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum }, { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textHeadingText },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo }, { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull }, { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo },
]; { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull },
break; { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
case 3: // note ];
arr = [ str = this.textWhichHeading;
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum }, break;
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, case 2: // bookmark
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, arr = [
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm } { value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textBookmarkText },
]; { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
break; { value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum },
case 4: // end note { value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
arr = [ { value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull },
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum }, { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, ];
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }, str = this.textWhichBookmark;
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm } break;
]; case 3: // note
break; arr = [
case 5: // Equation { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum },
case 6: // Shape { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
case 7: // Table { value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
arr = [ { value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm }
{ value: Asc.c_oAscDocumentRefenceToType.EntireCaption, displayValue: this.textCaption }, ];
{ value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum }, str = this.textWhichNote;
{ value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption }, break;
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum }, case 4: // end note
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow } arr = [
]; { value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum },
break; { value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm }
];
str = this.textWhichEndnote;
break;
}
} }
this.cmbReference.setData(arr); this.cmbReference.setData(arr);
this.cmbReference.setValue(arr[0].value); this.cmbReference.setValue(arr[0].value);
this.lblWhich.text(str);
}, },
txtTitle: 'Cross-reference', txtTitle: 'Cross-reference',
@ -284,7 +308,6 @@ define([
textInsertAs: 'Insert as hyperlink', textInsertAs: 'Insert as hyperlink',
textSeparate: 'Separate numbers with', textSeparate: 'Separate numbers with',
textIncludeAbove: 'Include above/below', textIncludeAbove: 'Include above/below',
textWhich: 'For which caption',
textPageNum: 'Page number', textPageNum: 'Page number',
textParaNum: 'Paragraph number', textParaNum: 'Paragraph number',
textParaNumNo: 'Paragraph number (no context)', textParaNumNo: 'Paragraph number (no context)',
@ -311,7 +334,13 @@ define([
textEquation: 'Equation', textEquation: 'Equation',
textFigure: 'Figure', textFigure: 'Figure',
textTable: 'Table', textTable: 'Table',
textInsert: 'Insert' textInsert: 'Insert',
textWhich: 'For which caption',
textWhichHeading: 'For which heading',
textWhichBookmark: 'For which bookmark',
textWhichNote: 'For which footnote',
textWhichEndnote: 'For which endnote',
textWhichPara: 'For which numbered item'
}, DE.Views.CrossReferenceDialog || {})) }, DE.Views.CrossReferenceDialog || {}))
}); });