Skip to content

Commit 2144fca

Browse files
committed
controllers/search: Show warning when using multiple category: filters
1 parent f8e8722 commit 2144fca

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

app/controllers/search.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { restartableTask } from 'ember-concurrency';
77
import { bool, reads } from 'macro-decorators';
88

99
import { pagination } from '../utils/pagination';
10-
import { processSearchQuery } from '../utils/search';
10+
import { CATEGORY_PREFIX, processSearchQuery } from '../utils/search';
1111

1212
export default class SearchController extends Controller {
1313
@service store;
@@ -49,6 +49,11 @@ export default class SearchController extends Controller {
4949

5050
@bool('totalItems') hasItems;
5151

52+
get hasMultiCategoryFilter() {
53+
let tokens = this.q.trim().split(/\s+/);
54+
return tokens.filter(token => token.startsWith(CATEGORY_PREFIX)).length > 1;
55+
}
56+
5257
@action fetchData() {
5358
this.dataTask.perform().catch(() => {
5459
// we ignore errors here because they are handled in the template already

app/styles/application.module.css

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
--grey200: hsl(200, 17%, 96%);
77
--green800: hsl(115, 31%, 31%);
88
--green900: hsl(115, 31%, 21%);
9+
10+
--orange-50: #fff7ed;
11+
--orange-100: #ffedd5;
12+
--orange-200: #fed7aa;
13+
--orange-300: #fdba74;
14+
--orange-400: #fb923c;
15+
--orange-500: #f97316;
16+
--orange-600: #ea580c;
17+
--orange-700: #c2410c;
18+
--orange-800: #9a3412;
19+
--orange-900: #7c2d12;
20+
921
--yellow500: hsl(44, 100%, 60%);
1022
--yellow700: hsl(44, 67%, 50%);
1123

app/styles/search.module.css

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
margin-bottom: 25px;
66
}
77

8+
.warning {
9+
margin: 0 0 16px;
10+
padding: 8px;
11+
color: var(--orange-700);
12+
background: var(--orange-100);
13+
border-left: solid var(--orange-400) 4px;
14+
border-radius: 2px;
15+
}
16+
817
.sort-by-label {
918
composes: small from './shared/typography.module.css';
1019
}

app/templates/search.hbs

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
data-test-header
99
/>
1010

11+
{{#if this.hasMultiCategoryFilter}}
12+
<div local-class="warning">
13+
Support for using multiple <code>category:</code> filters is not yet implemented.
14+
</div>
15+
{{/if}}
16+
1117
{{#if this.firstResultPending}}
1218
<h2>Loading search results...</h2>
1319
{{else if this.dataTask.lastComplete.error}}

app/utils/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CATEGORY_PREFIX = 'category:';
1+
export const CATEGORY_PREFIX = 'category:';
22
const KEYWORD_PREFIX = 'keyword:';
33

44
/**

0 commit comments

Comments
 (0)