Advanced Search UI

Properly support Categories so it updates the search box correctly

Use category id, as it is more consistent with search results than using the slugs, especially for parent/subcategory

Added Status

Improve AutoComplete so it can receive updates
Added the ability for AutoComplete to receive updates to badge-selector and group-selector

Respect null, which is set via web-hooks

Support both # and category: for category detection.

Only update the searchedTerms if they differ from its current value (this helps the Category Selector receive updates)

Opt in receive updates (#3)

* Make the selectors opt-in for receiving updates

* Opt-in to receive updates

* Fix category detection for search-advanced-options

Fix eslint error

Update user-selector so it can receive updates live too
Make the canReceiveUpdates check validate against 'true'

Converted to use template literals

Refactor the regex involved with this feature
Split apart the init to make it a bit more manageable/testable

Switch the category selector to category-chooser, so it is a dropdown of categories instead of auto-complete

Reduce RegEx to make this happier with unicode languages and reduce some of the complexity
This commit is contained in:
cpradio
2016-09-26 20:01:40 -04:00
parent d69cf820d8
commit 4b71fd253b
14 changed files with 659 additions and 14 deletions

View File

@ -42,7 +42,7 @@ export default function(options) {
if (this.length === 0) return;
if (options === 'destroy') {
if (options === 'destroy' || options.updateData) {
Ember.run.cancel(inputTimeout);
$(this).off('keyup.autocomplete')
@ -50,7 +50,8 @@ export default function(options) {
.off('paste.autocomplete')
.off('click.autocomplete');
return;
if (options === 'destroy')
return;
}
if (options && options.cancel && this.data("closeAutocomplete")) {
@ -162,28 +163,46 @@ export default function(options) {
if (isInput) {
const width = this.width();
wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled": "") + "'/>").parent();
wrap.width(width);
if (options.updateData) {
wrap = this.parent();
wrap.find('.item').remove();
me.show();
} else {
wrap = this.wrap("<div class='ac-wrap clearfix" + (disabled ? " disabled" : "") + "'/>").parent();
wrap.width(width);
}
if(options.single) {
this.css("width","100%");
} else {
this.width(150);
}
this.attr('name', this.attr('name') + "-renamed");
this.attr('name', (options.updateData) ? this.attr('name') : this.attr('name') + "-renamed");
var vals = this.val().split(",");
_.each(vals,function(x) {
if (x !== "") {
if (options.reverseTransform) {
x = options.reverseTransform(x);
}
if(options.single){
me.hide();
}
addInputSelectedItem(x);
}
});
if(options.items) {
_.each(options.items, function(item){
if(options.single){
me.hide();
}
addInputSelectedItem(item);
});
}
this.val("");
completeStart = 0;
wrap.click(function() {