1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-27 09:09:44 +02:00

Warn if search criteria too short

Minimum keywords > 3
This commit is contained in:
sauls8t 2018-06-13 15:54:58 +01:00
parent df9d9e174a
commit f70d4b33a3
3 changed files with 15 additions and 1 deletions

View file

@ -16,6 +16,7 @@ import Component from '@ember/component';
export default Component.extend({ export default Component.extend({
searchSvc: service('search'), searchSvc: service('search'),
results: A([]), results: A([]),
validSearch: true,
init() { init() {
this._super(...arguments); this._super(...arguments);
@ -50,6 +51,12 @@ export default Component.extend({
actions: { actions: {
onSearch() { onSearch() {
if (this.get('filter').trim().length < 3) {
this.set('validSearch', false);
return;
}
this.set('validSearch', true);
this.fetch(); this.fetch();
} }
} }

View file

@ -108,3 +108,6 @@ $color-whats-new: #fc1530;
.background-color-theme-light { .background-color-theme-light {
background-color: $color-primary-light !important; background-color: $color-primary-light !important;
} }
.background-color-gold {
background-color: $color-goldy !important;
}

View file

@ -26,5 +26,9 @@
</div> </div>
</div> </div>
{{#if validSearch}}
{{search/search-results results=results keywords=filter}} {{search/search-results results=results keywords=filter}}
{{else}}
<p class="text-danger my-5">Your search term is too short</p>
{{/if}}
</div> </div>