DEV: Move `noResults` to search service (#26084)
This commit is contained in:
parent
2a6e4a7ba0
commit
0bc0efbd0a
|
@ -54,7 +54,6 @@
|
||||||
{{#if @inlineResults}}
|
{{#if @inlineResults}}
|
||||||
<SearchMenu::Results
|
<SearchMenu::Results
|
||||||
@loading={{this.loading}}
|
@loading={{this.loading}}
|
||||||
@noResults={{this.noResults}}
|
|
||||||
@invalidTerm={{this.invalidTerm}}
|
@invalidTerm={{this.invalidTerm}}
|
||||||
@suggestionKeyword={{this.suggestionKeyword}}
|
@suggestionKeyword={{this.suggestionKeyword}}
|
||||||
@suggestionResults={{this.suggestionResults}}
|
@suggestionResults={{this.suggestionResults}}
|
||||||
|
@ -70,7 +69,6 @@
|
||||||
<MenuPanel @panelClass="search-menu-panel">
|
<MenuPanel @panelClass="search-menu-panel">
|
||||||
<SearchMenu::Results
|
<SearchMenu::Results
|
||||||
@loading={{this.loading}}
|
@loading={{this.loading}}
|
||||||
@noResults={{this.noResults}}
|
|
||||||
@invalidTerm={{this.invalidTerm}}
|
@invalidTerm={{this.invalidTerm}}
|
||||||
@suggestionKeyword={{this.suggestionKeyword}}
|
@suggestionKeyword={{this.suggestionKeyword}}
|
||||||
@suggestionResults={{this.suggestionResults}}
|
@suggestionResults={{this.suggestionResults}}
|
||||||
|
|
|
@ -36,7 +36,6 @@ export default class SearchMenu extends Component {
|
||||||
@service appEvents;
|
@service appEvents;
|
||||||
|
|
||||||
@tracked loading = false;
|
@tracked loading = false;
|
||||||
@tracked noResults = false;
|
|
||||||
@tracked
|
@tracked
|
||||||
inPMInboxContext = this.search.searchContext?.type === "private_messages";
|
inPMInboxContext = this.search.searchContext?.type === "private_messages";
|
||||||
@tracked typeFilter = DEFAULT_TYPE_FILTER;
|
@tracked typeFilter = DEFAULT_TYPE_FILTER;
|
||||||
|
@ -215,7 +214,7 @@ export default class SearchMenu extends Component {
|
||||||
|
|
||||||
const matchSuggestions = this.matchesSuggestions();
|
const matchSuggestions = this.matchesSuggestions();
|
||||||
if (matchSuggestions) {
|
if (matchSuggestions) {
|
||||||
this.noResults = true;
|
this.search.noResults = true;
|
||||||
this.search.results = {};
|
this.search.results = {};
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.suggestionResults = [];
|
this.suggestionResults = [];
|
||||||
|
@ -253,7 +252,7 @@ export default class SearchMenu extends Component {
|
||||||
this.suggestionResults = result.users;
|
this.suggestionResults = result.users;
|
||||||
this.suggestionKeyword = "@";
|
this.suggestionKeyword = "@";
|
||||||
} else {
|
} else {
|
||||||
this.noResults = true;
|
this.search.noResults = true;
|
||||||
this.suggestionKeyword = false;
|
this.suggestionKeyword = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -266,14 +265,14 @@ export default class SearchMenu extends Component {
|
||||||
this.suggestionKeyword = false;
|
this.suggestionKeyword = false;
|
||||||
|
|
||||||
if (!this.search.activeGlobalSearchTerm) {
|
if (!this.search.activeGlobalSearchTerm) {
|
||||||
this.noResults = false;
|
this.search.noResults = false;
|
||||||
this.search.results = {};
|
this.search.results = {};
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.invalidTerm = false;
|
this.invalidTerm = false;
|
||||||
} else if (
|
} else if (
|
||||||
!isValidSearchTerm(this.search.activeGlobalSearchTerm, this.siteSettings)
|
!isValidSearchTerm(this.search.activeGlobalSearchTerm, this.siteSettings)
|
||||||
) {
|
) {
|
||||||
this.noResults = true;
|
this.search.noResults = true;
|
||||||
this.search.results = {};
|
this.search.results = {};
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.invalidTerm = true;
|
this.invalidTerm = true;
|
||||||
|
@ -298,7 +297,7 @@ export default class SearchMenu extends Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.noResults = results.resultTypes.length === 0;
|
this.search.noResults = results.resultTypes.length === 0;
|
||||||
this.search.results = results;
|
this.search.results = results;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -339,7 +338,7 @@ export default class SearchMenu extends Component {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
triggerSearch() {
|
triggerSearch() {
|
||||||
this.noResults = false;
|
this.search.noResults = false;
|
||||||
|
|
||||||
if (this.includesTopics) {
|
if (this.includesTopics) {
|
||||||
if (this.search.contextType === "topic") {
|
if (this.search.contextType === "topic") {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default class Results extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get noTopicResults() {
|
get noTopicResults() {
|
||||||
return this.args.searchTopics && this.args.noResults;
|
return this.args.searchTopics && this.search.noResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
get termTooShort() {
|
get termTooShort() {
|
||||||
|
|
|
@ -14,6 +14,7 @@ export default class Search extends Service {
|
||||||
@tracked inTopicContext = false;
|
@tracked inTopicContext = false;
|
||||||
@tracked visible = false;
|
@tracked visible = false;
|
||||||
@tracked results = {};
|
@tracked results = {};
|
||||||
|
@tracked noResults = false;
|
||||||
|
|
||||||
// only relative for the widget search menu
|
// only relative for the widget search menu
|
||||||
searchContextEnabled = false; // checkbox to scope search
|
searchContextEnabled = false; // checkbox to scope search
|
||||||
|
|
Loading…
Reference in New Issue