[SSE] Search: send selected result item
This commit is contained in:
parent
a3812a8c3c
commit
749ba979f4
|
@ -335,7 +335,8 @@ define([
|
||||||
} else {
|
} else {
|
||||||
text = current === 'no-results' ? this.textNoSearchResults :
|
text = current === 'no-results' ? this.textNoSearchResults :
|
||||||
(current === 'stop' ? this.textSearchHasStopped :
|
(current === 'stop' ? this.textSearchHasStopped :
|
||||||
(!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)));
|
(current === 'content-changed' ? this.textContentChanged :
|
||||||
|
(!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count))));
|
||||||
}
|
}
|
||||||
this.$reaultsNumber.text(text);
|
this.$reaultsNumber.text(text);
|
||||||
!window.SSE && this.disableReplaceButtons(!count);
|
!window.SSE && this.disableReplaceButtons(!count);
|
||||||
|
@ -422,7 +423,8 @@ define([
|
||||||
textCell: 'Cell',
|
textCell: 'Cell',
|
||||||
textValue: 'Value',
|
textValue: 'Value',
|
||||||
textFormula: 'Formula',
|
textFormula: 'Formula',
|
||||||
textSearchHasStopped: 'Search has stopped'
|
textSearchHasStopped: 'Search has stopped',
|
||||||
|
textContentChanged: 'Document content has changed.'
|
||||||
|
|
||||||
}, Common.Views.SearchPanel || {}));
|
}, Common.Views.SearchPanel || {}));
|
||||||
});
|
});
|
|
@ -93,7 +93,9 @@ define([
|
||||||
withinSheet: Asc.c_oAscSearchBy.Sheet,
|
withinSheet: Asc.c_oAscSearchBy.Sheet,
|
||||||
searchByRows: true,
|
searchByRows: true,
|
||||||
lookInFormulas: true,
|
lookInFormulas: true,
|
||||||
isValidSelectedRange: true
|
isValidSelectedRange: true,
|
||||||
|
lastSelectedItem: undefined,
|
||||||
|
isContentChanged: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -111,8 +113,8 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this));
|
this.api.asc_registerCallback('asc_onEndTextAroundSearch', _.bind(this.onEndTextAroundSearch, this));
|
||||||
this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this));
|
this.api.asc_registerCallback('asc_onGetTextAroundSearchPack', _.bind(this.onApiGetTextAroundSearch, this));
|
||||||
this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this));
|
this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this));
|
||||||
this.api.asc_registerCallback('asc_onSearchEnd', _.bind(this.onApiSearchEnd, this));
|
|
||||||
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this));
|
this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this));
|
||||||
|
this.api.asc_registerCallback('asc_onModifiedDocument', _.bind(this.onApiModifiedDocument, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -259,6 +261,8 @@ define([
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._state.isContentChanged = false;
|
||||||
|
|
||||||
var options = new Asc.asc_CFindOptions();
|
var options = new Asc.asc_CFindOptions();
|
||||||
options.asc_setFindWhat(this._state.searchText);
|
options.asc_setFindWhat(this._state.searchText);
|
||||||
options.asc_setScanForward(d != 'back');
|
options.asc_setScanForward(d != 'back');
|
||||||
|
@ -271,6 +275,7 @@ define([
|
||||||
options.asc_setScanByRows(this._state.searchByRows);
|
options.asc_setScanByRows(this._state.searchByRows);
|
||||||
options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
||||||
options.asc_setNeedRecalc(isNeedRecalc);
|
options.asc_setNeedRecalc(isNeedRecalc);
|
||||||
|
options.asc_setLastSearchElem(this._state.lastSelectedItem);
|
||||||
if (!this.api.asc_findText(options)) {
|
if (!this.api.asc_findText(options)) {
|
||||||
this.resultItems = [];
|
this.resultItems = [];
|
||||||
this.view.updateResultsNumber(undefined, 0);
|
this.view.updateResultsNumber(undefined, 0);
|
||||||
|
@ -296,6 +301,7 @@ define([
|
||||||
}
|
}
|
||||||
options.asc_setScanByRows(this._state.searchByRows);
|
options.asc_setScanByRows(this._state.searchByRows);
|
||||||
options.asc_setLookIn(this._state.lookIn ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
options.asc_setLookIn(this._state.lookIn ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
||||||
|
options.asc_setLastSearchElem(this._state.lastSelectedItem);
|
||||||
options.asc_setIsReplaceAll(false);
|
options.asc_setIsReplaceAll(false);
|
||||||
|
|
||||||
this.api.asc_replaceText(options);
|
this.api.asc_replaceText(options);
|
||||||
|
@ -314,6 +320,7 @@ define([
|
||||||
}
|
}
|
||||||
options.asc_setScanByRows(this._state.searchByRows);
|
options.asc_setScanByRows(this._state.searchByRows);
|
||||||
options.asc_setLookIn(this._state.lookIn ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
options.asc_setLookIn(this._state.lookIn ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
||||||
|
options.asc_setLastSearchElem(this._state.lastSelectedItem);
|
||||||
options.asc_setIsReplaceAll(true);
|
options.asc_setIsReplaceAll(true);
|
||||||
|
|
||||||
this.api.asc_replaceText(options);
|
this.api.asc_replaceText(options);
|
||||||
|
@ -345,6 +352,7 @@ define([
|
||||||
}
|
}
|
||||||
options.asc_setScanByRows(this._state.searchByRows);
|
options.asc_setScanByRows(this._state.searchByRows);
|
||||||
options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
|
||||||
|
options.asc_setLastSearchElem(this._state.lastSelectedItem);
|
||||||
if (!this.api.asc_findText(options)) {
|
if (!this.api.asc_findText(options)) {
|
||||||
this.removeResultItems();
|
this.removeResultItems();
|
||||||
}
|
}
|
||||||
|
@ -384,6 +392,7 @@ define([
|
||||||
item.selected = false;
|
item.selected = false;
|
||||||
});
|
});
|
||||||
if (this.resultItems[current]) {
|
if (this.resultItems[current]) {
|
||||||
|
this._state.lastSelectedItem = this.resultItems[current].data;
|
||||||
this.resultItems[current].selected = true;
|
this.resultItems[current].selected = true;
|
||||||
$('#search-results').find('.item').removeClass('selected');
|
$('#search-results').find('.item').removeClass('selected');
|
||||||
this.resultItems[current].$el.addClass('selected');
|
this.resultItems[current].$el.addClass('selected');
|
||||||
|
@ -443,9 +452,14 @@ define([
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
$item.addClass('selected');
|
$item.addClass('selected');
|
||||||
}
|
}
|
||||||
var resultItem = {id: item[0], $el: $item, el: tr, selected: isSelected, data: data};
|
var resultItem = {id: item[0], $el: $item, el: tr, selected: isSelected, data: item};
|
||||||
me.resultItems.push(resultItem);
|
me.resultItems.push(resultItem);
|
||||||
$item.on('click', _.bind(function (el) {
|
$item.on('click', _.bind(function (el) {
|
||||||
|
if (me._state.isContentChanged) {
|
||||||
|
me._state.lastSelectedItem = item;
|
||||||
|
me.onQuerySearch();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var id = item[0];
|
var id = item[0];
|
||||||
me.api.asc_SelectSearchElement(id);
|
me.api.asc_SelectSearchElement(id);
|
||||||
}, me));
|
}, me));
|
||||||
|
@ -551,8 +565,9 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiSearchEnd: function () {
|
onApiModifiedDocument: function () {
|
||||||
this.removeResultItems('stop');
|
this._state.isContentChanged = true;
|
||||||
|
this.view.updateResultsNumber('content-changed');
|
||||||
},
|
},
|
||||||
|
|
||||||
onActiveSheetChanged: function (index) {
|
onActiveSheetChanged: function (index) {
|
||||||
|
|
Loading…
Reference in a new issue