mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
Add checkbox to contain all tags in advanced search and change separators according its state.
This commit is contained in:
parent
9c9102d39a
commit
2927b45ff2
@ -77,7 +77,8 @@ export default Em.Component.extend({
|
|||||||
likes: false,
|
likes: false,
|
||||||
private: false,
|
private: false,
|
||||||
seen: false
|
seen: false
|
||||||
}
|
},
|
||||||
|
all_tags: false
|
||||||
},
|
},
|
||||||
status: '',
|
status: '',
|
||||||
min_post_count: '',
|
min_post_count: '',
|
||||||
@ -230,13 +231,15 @@ export default Em.Component.extend({
|
|||||||
|
|
||||||
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
|
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
|
||||||
const tags = this.get('searchedTerms.tags');
|
const tags = this.get('searchedTerms.tags');
|
||||||
|
const contain_all_tags = this.get('searchedTerms.special.all_tags');
|
||||||
|
|
||||||
if (match.length !== 0) {
|
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, '');
|
const userInput = match[0].replace(REGEXP_TAGS_REPLACE, '');
|
||||||
|
|
||||||
if (existingInput !== userInput) {
|
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) {
|
} else if (tags.length !== 0) {
|
||||||
this.set('searchedTerms.tags', []);
|
this.set('searchedTerms.tags', []);
|
||||||
@ -365,14 +368,16 @@ export default Em.Component.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes('searchedTerms.tags')
|
@observes('searchedTerms.tags', 'searchedTerms.special.all_tags')
|
||||||
updateSearchTermForTags() {
|
updateSearchTermForTags() {
|
||||||
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
|
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
|
||||||
const tagFilter = this.get('searchedTerms.tags');
|
const tagFilter = this.get('searchedTerms.tags');
|
||||||
let searchTerm = this.get('searchTerm') || '';
|
let searchTerm = this.get('searchTerm') || '';
|
||||||
|
const contain_all_tags = this.get('searchedTerms.special.all_tags');
|
||||||
|
|
||||||
if (tagFilter && tagFilter.length !== 0) {
|
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) {
|
if (match.length !== 0) {
|
||||||
searchTerm = searchTerm.replace(match[0], `tags:${tags}`);
|
searchTerm = searchTerm.replace(match[0], `tags:${tags}`);
|
||||||
|
@ -41,12 +41,15 @@
|
|||||||
<label class="control-label" for="search-with-tags">{{i18n "search.advanced.with_tags.label"}}</label>
|
<label class="control-label" for="search-with-tags">{{i18n "search.advanced.with_tags.label"}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{tag-chooser tags=searchedTerms.tags blacklist=searchedTerms.tags allowCreate=false placeholder="" everyTag="true" unlimitedTagCount="true" width="70%"}}
|
{{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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">contain_all_tags
|
||||||
<div class="control-group pull-left">
|
<div class="control-group pull-left">
|
||||||
<label class="control-label" for="search-in-options">{{i18n "search.advanced.filters.label"}}</label>
|
<label class="control-label" for="search-in-options">{{i18n "search.advanced.filters.label"}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -1340,6 +1340,7 @@ en:
|
|||||||
seen: I've read
|
seen: I've read
|
||||||
unseen: I've not read
|
unseen: I've not read
|
||||||
wiki: are wiki
|
wiki: are wiki
|
||||||
|
all_tags: Contains all tags
|
||||||
statuses:
|
statuses:
|
||||||
label: Where topics
|
label: Where topics
|
||||||
open: are open
|
open: are open
|
||||||
|
Loading…
x
Reference in New Issue
Block a user