Add checkbox to contain all tags in advanced search and change separators according its state.

This commit is contained in:
Jakub Macina 2017-05-29 19:12:07 +02:00
parent 9c9102d39a
commit 2927b45ff2
3 changed files with 15 additions and 6 deletions

View File

@ -77,7 +77,8 @@ export default Em.Component.extend({
likes: false,
private: false,
seen: false
}
},
all_tags: false
},
status: '',
min_post_count: '',
@ -230,13 +231,15 @@ export default Em.Component.extend({
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
const tags = this.get('searchedTerms.tags');
const contain_all_tags = this.get('searchedTerms.special.all_tags');
if (match.length !== 0) {
const existingInput = _.isArray(tags) ? tags.join(',') : tags;
const join_char = contain_all_tags ? ',' : '|';
const existingInput = _.isArray(tags) ? tags.join(join_char) : tags;
const userInput = match[0].replace(REGEXP_TAGS_REPLACE, '');
if (existingInput !== userInput) {
this.set('searchedTerms.tags', (userInput.length !== 0) ? userInput.split(',') : []);
this.set('searchedTerms.tags', (userInput.length !== 0) ? userInput.split(join_char) : []);
}
} else if (tags.length !== 0) {
this.set('searchedTerms.tags', []);
@ -365,14 +368,16 @@ export default Em.Component.extend({
}
},
@observes('searchedTerms.tags')
@observes('searchedTerms.tags', 'searchedTerms.special.all_tags')
updateSearchTermForTags() {
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
const tagFilter = this.get('searchedTerms.tags');
let searchTerm = this.get('searchTerm') || '';
const contain_all_tags = this.get('searchedTerms.special.all_tags');
if (tagFilter && tagFilter.length !== 0) {
const tags = tagFilter.join(',');
const join_char = contain_all_tags ? ',' : '|';
const tags = tagFilter.join(join_char);
if (match.length !== 0) {
searchTerm = searchTerm.replace(match[0], `tags:${tags}`);

View File

@ -41,12 +41,15 @@
<label class="control-label" for="search-with-tags">{{i18n "search.advanced.with_tags.label"}}</label>
<div class="controls">
{{tag-chooser tags=searchedTerms.tags blacklist=searchedTerms.tags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true" width="70%"}}
<section class="field">
<label>{{ input type="checkbox" class="all-tags" checked=searchedTerms.special.all_tags}} {{i18n "search.advanced.filters.all_tags"}} </label>
</section>
</div>
</div>
</div>
{{/if}}
<div class="container">
<div class="container">contain_all_tags
<div class="control-group pull-left">
<label class="control-label" for="search-in-options">{{i18n "search.advanced.filters.label"}}</label>
<div class="controls">

View File

@ -1340,6 +1340,7 @@ en:
seen: I've read
unseen: I've not read
wiki: are wiki
all_tags: Contains all tags
statuses:
label: Where topics
open: are open