👀🔍 showing search queries

This commit is contained in:
undergroundwires
2020-01-11 08:57:06 +01:00
parent 92f1a36bcb
commit 97a7747933
2 changed files with 25 additions and 6 deletions

View File

@@ -5,7 +5,8 @@
## Unreleased ## Unreleased
- Fixed search bug - Fixed search bug
- Hiding grouping while searching - Hiding grouping while searching
- Showing search queries when searching
## [0.4.0] - 2020-01-11 ## [0.4.0] - 2020-01-11

View File

@@ -8,13 +8,15 @@
</div> </div>
<div class="scripts"> <div class="scripts">
<div v-if="!isSearching || searchHasMatches"> <div v-if="!isSearching || searchHasMatches">
<CardList v-if="showCards" /> <CardList v-if="this.showCards" />
<div v-else-if="showList" class="tree"> <div v-else-if="this.showList" class="tree">
<div v-if="this.isSearching" class="search-query">
Searching for "{{this.searchQuery | threeDotsTrim}}"</div>
<ScriptsTree /> <ScriptsTree />
</div> </div>
</div> </div>
<div v-else class="search-no-matches"> <div v-else class="search-no-matches">
Search has no matches 😞 Sorry, no matches for "{{this.searchQuery | threeDotsTrim}}" 😞
Feel free to extend the scripts <a :href="repositoryUrl" target="_blank" class="child github" >here</a>. Feel free to extend the scripts <a :href="repositoryUrl" target="_blank" class="child github" >here</a>.
</div> </div>
</div> </div>
@@ -41,11 +43,21 @@
ScriptsTree, ScriptsTree,
CardList, CardList,
}, },
filters: {
threeDotsTrim(query: string) {
const threshold = 30;
if (query.length <= threshold - 3) {
return query;
}
return `${query.substr(0, threshold)}...`;
},
},
}) })
export default class TheScripts extends StatefulVue { export default class TheScripts extends StatefulVue {
public showCards = false; public showCards = false;
public showList = false; public showList = false;
public repositoryUrl = ''; public repositoryUrl = '';
private searchQuery = '';
private isSearching = false; private isSearching = false;
private searchHasMatches = false; private searchHasMatches = false;
@@ -59,6 +71,7 @@
this.updateGroups(); this.updateGroups();
}); });
state.filter.filtered.on((result: IFilterResult) => { state.filter.filtered.on((result: IFilterResult) => {
this.searchQuery = result.query;
this.isSearching = true; this.isSearching = true;
this.searchHasMatches = result.hasAnyMatches(); this.searchHasMatches = result.hasAnyMatches();
this.updateGroups(); this.updateGroups();
@@ -97,8 +110,13 @@
} }
.tree { .tree {
padding-left: 3%; padding-left: 3%;
margin-top: 15px; // Card margin padding-top: 15px;
margin-bottom: 15px; // Card margin padding-bottom: 15px;
.search-query {
display: flex;
justify-content: center;
color: $gray;
}
} }
} }
.help-container { .help-container {