[SSE] Make result table in search panel
This commit is contained in:
parent
13a79663e6
commit
98a995a6cc
|
@ -405,26 +405,47 @@ define([
|
||||||
onApiGetTextAroundSearch: function (data) { // [id, sheet, name, cell, value, formula]
|
onApiGetTextAroundSearch: function (data) { // [id, sheet, name, cell, value, formula]
|
||||||
if (this.view && this._state.isStartedAddingResults) {
|
if (this.view && this._state.isStartedAddingResults) {
|
||||||
if (data.length > 300) return;
|
if (data.length > 300) return;
|
||||||
var me = this;
|
var me = this,
|
||||||
|
container = me.view.$resultsContainer;
|
||||||
|
container.html('<table style="width:100%">' +
|
||||||
|
'<col style="width:20%">' +
|
||||||
|
'<col style="width:20%">' +
|
||||||
|
'<col style="width:20%">' +
|
||||||
|
'<col style="width:20%">' +
|
||||||
|
'<col style="width:20%">' +
|
||||||
|
'<thead>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<th>' + this.textSheet + '</th>' +
|
||||||
|
'<th>' + this.textName + '</th>' +
|
||||||
|
'<th>' + this.textCell + '</th>' +
|
||||||
|
'<th>' + this.textValue + '</th>' +
|
||||||
|
'<th>' + this.textFormula + '</th>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</thead>' +
|
||||||
|
'<tbody>' +
|
||||||
|
'</table>');
|
||||||
|
var $tableBody = container.find('tbody');
|
||||||
me.resultItems = [];
|
me.resultItems = [];
|
||||||
data.forEach(function (item, ind) {
|
data.forEach(function (item, ind) {
|
||||||
var el = document.createElement("div"),
|
var isSelected = ind === me._state.currentResult;
|
||||||
isSelected = ind === me._state.currentResult;
|
var tr = '<tr class="item">' +
|
||||||
el.className = 'item';
|
'<td>' + item[1] + '</td>' +
|
||||||
el.innerHTML = item[4].trim();
|
'<td>' + item[2] + '</td>' +
|
||||||
me.view.$resultsContainer.append(el);
|
'<td>' + item[3] + '</td>' +
|
||||||
|
'<td>' + item[4] + '</td>' +
|
||||||
|
'<td>' + item[5] + '</td>' +
|
||||||
|
'</tr>';
|
||||||
|
var $item = $(tr).appendTo($tableBody);
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
$(el).addClass('selected');
|
$item.addClass('selected');
|
||||||
}
|
}
|
||||||
|
var resultItem = {id: item[0], $el: $item, selected: isSelected};
|
||||||
var resultItem = {id: item[0], $el: $(el), el: el, selected: isSelected};
|
|
||||||
me.resultItems.push(resultItem);
|
me.resultItems.push(resultItem);
|
||||||
$(el).on('click', _.bind(function (el) {
|
$item.on('click', _.bind(function (el) {
|
||||||
var id = item[0];
|
var id = item[0];
|
||||||
me.api.asc_SelectSearchElement(id);
|
me.api.asc_SelectSearchElement(id);
|
||||||
}, me));
|
}, me));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.view.$resultsContainer.show();
|
this.view.$resultsContainer.show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -490,6 +511,11 @@ define([
|
||||||
textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced',
|
textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced',
|
||||||
textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',
|
textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',
|
||||||
textInvalidRange: 'ERROR! Invalid cells range',
|
textInvalidRange: 'ERROR! Invalid cells range',
|
||||||
|
textSheet: 'Sheet',
|
||||||
|
textName: 'Name',
|
||||||
|
textCell: 'Cell',
|
||||||
|
textValue: 'Value',
|
||||||
|
textFormula: 'Formula'
|
||||||
|
|
||||||
}, SSE.Controllers.Search || {}));
|
}, SSE.Controllers.Search || {}));
|
||||||
});
|
});
|
Loading…
Reference in a new issue