Don't show section headers for sections with no results and don't show page
controls if there is only one page of results This makes the search results display more streamlined. Make sure that we move the selection to a different section if we are going from displaying a single section to displaying all and the section that used to be displayed alone doesn't have any results.
This commit is contained in:
parent
dfe16f4af6
commit
02c65fab8d
@ -641,10 +641,27 @@ Dash.prototype = {
|
|||||||
for (var i = 0; i < this._searchSections.length; i++) {
|
for (var i = 0; i < this._searchSections.length; i++) {
|
||||||
let section = this._searchSections[i];
|
let section = this._searchSections[i];
|
||||||
section.resultArea.display.setSearch(text);
|
section.resultArea.display.setSearch(text);
|
||||||
let itemCount = section.resultArea.display.getMatchedItemsCount() + "";
|
let itemCount = section.resultArea.display.getMatchedItemsCount();
|
||||||
section.header.countText.text = itemCount;
|
let itemCountText = itemCount + "";
|
||||||
if (this._searchResultsSingleShownSection == section.type)
|
section.header.countText.text = itemCountText;
|
||||||
this._searchResultsSection.header.setCountText(itemCount);
|
|
||||||
|
if (this._searchResultsSingleShownSection == section.type) {
|
||||||
|
this._searchResultsSection.header.setCountText(itemCountText);
|
||||||
|
if (itemCount == 0) {
|
||||||
|
section.resultArea.actor.hide();
|
||||||
|
} else {
|
||||||
|
section.resultArea.actor.show();
|
||||||
|
}
|
||||||
|
} else if (this._searchResultsSingleShownSection == null) {
|
||||||
|
// Don't show the section if it has no results
|
||||||
|
if (itemCount == 0) {
|
||||||
|
section.header.actor.hide();
|
||||||
|
section.resultArea.actor.hide();
|
||||||
|
} else {
|
||||||
|
section.header.actor.show();
|
||||||
|
section.resultArea.actor.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the selection when a new search is applied.
|
// Refresh the selection when a new search is applied.
|
||||||
section.resultArea.display.unsetSelected();
|
section.resultArea.display.unsetSelected();
|
||||||
@ -880,11 +897,12 @@ Dash.prototype = {
|
|||||||
// This will be the only section shown.
|
// This will be the only section shown.
|
||||||
section.resultArea.display.selectFirstItem();
|
section.resultArea.display.selectFirstItem();
|
||||||
section.resultArea.controlBox.show();
|
section.resultArea.controlBox.show();
|
||||||
let itemCount = section.resultArea.display.getMatchedItemsCount() + "";
|
let itemCount = section.resultArea.display.getMatchedItemsCount();
|
||||||
|
let itemCountText = itemCount + "";
|
||||||
section.header.actor.hide();
|
section.header.actor.hide();
|
||||||
this._searchResultsSection.header.setTitle(section.title);
|
this._searchResultsSection.header.setTitle(section.title);
|
||||||
this._searchResultsSection.header.setBackLinkVisible(true);
|
this._searchResultsSection.header.setBackLinkVisible(true);
|
||||||
this._searchResultsSection.header.setCountText(itemCount);
|
this._searchResultsSection.header.setCountText(itemCountText);
|
||||||
} else {
|
} else {
|
||||||
// We need to hide this section.
|
// We need to hide this section.
|
||||||
section.header.actor.hide();
|
section.header.actor.hide();
|
||||||
@ -897,20 +915,35 @@ Dash.prototype = {
|
|||||||
|
|
||||||
_showAllSearchSections: function() {
|
_showAllSearchSections: function() {
|
||||||
if (this._searchResultsSingleShownSection != null) {
|
if (this._searchResultsSingleShownSection != null) {
|
||||||
|
let selectionSet = false;
|
||||||
for (var i = 0; i < this._searchSections.length; i++) {
|
for (var i = 0; i < this._searchSections.length; i++) {
|
||||||
let section = this._searchSections[i];
|
let section = this._searchSections[i];
|
||||||
if (section.type == this._searchResultsSingleShownSection) {
|
if (section.type == this._searchResultsSingleShownSection) {
|
||||||
// This will no longer be the only section shown.
|
// This will no longer be the only section shown.
|
||||||
section.resultArea.display.displayPage(0);
|
section.resultArea.display.displayPage(0);
|
||||||
section.resultArea.controlBox.hide();
|
section.resultArea.controlBox.hide();
|
||||||
section.header.actor.show();
|
let itemCount = section.resultArea.display.getMatchedItemsCount();
|
||||||
|
if (itemCount != 0) {
|
||||||
|
section.header.actor.show();
|
||||||
|
section.resultArea.display.selectFirstItem();
|
||||||
|
selectionSet = true;
|
||||||
|
}
|
||||||
this._searchResultsSection.header.setTitle(_("SEARCH RESULTS"));
|
this._searchResultsSection.header.setTitle(_("SEARCH RESULTS"));
|
||||||
this._searchResultsSection.header.setBackLinkVisible(false);
|
this._searchResultsSection.header.setBackLinkVisible(false);
|
||||||
this._searchResultsSection.header.setCountText("");
|
this._searchResultsSection.header.setCountText("");
|
||||||
} else {
|
} else {
|
||||||
// We need to restore this section.
|
// We need to restore this section.
|
||||||
section.header.actor.show();
|
let itemCount = section.resultArea.display.getMatchedItemsCount();
|
||||||
section.resultArea.actor.show();
|
if (itemCount != 0) {
|
||||||
|
section.header.actor.show();
|
||||||
|
section.resultArea.actor.show();
|
||||||
|
// This ensures that some other section will have the selection if the
|
||||||
|
// single section that was being displayed did not have any items.
|
||||||
|
if (!selectionSet) {
|
||||||
|
section.resultArea.display.selectFirstItem();
|
||||||
|
selectionSet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._searchResultsSingleShownSection = null;
|
this._searchResultsSingleShownSection = null;
|
||||||
|
@ -707,6 +707,9 @@ GenericDisplay.prototype = {
|
|||||||
if (resetDisplayControl) {
|
if (resetDisplayControl) {
|
||||||
this.displayControl.remove_all();
|
this.displayControl.remove_all();
|
||||||
let nPages = this._list.n_pages;
|
let nPages = this._list.n_pages;
|
||||||
|
// Don't show the page indicator if there is only one page.
|
||||||
|
if (nPages == 1)
|
||||||
|
return;
|
||||||
let pageNumber = this._list.page;
|
let pageNumber = this._list.page;
|
||||||
for (let i = 0; i < nPages; i++) {
|
for (let i = 0; i < nPages; i++) {
|
||||||
let pageControl = new Link.Link({ color: (i == pageNumber) ? DISPLAY_CONTROL_SELECTED_COLOR : ITEM_DISPLAY_DESCRIPTION_COLOR,
|
let pageControl = new Link.Link({ color: (i == pageNumber) ? DISPLAY_CONTROL_SELECTED_COLOR : ITEM_DISPLAY_DESCRIPTION_COLOR,
|
||||||
|
Loading…
Reference in New Issue
Block a user