A platform for community discussion. Free, open, simple.
REFACTOR: tags mixin (#7533)
Joffrey JAFFEUX7326ddea6dbb
diff --git a/app/assets/javascripts/select-kit/mixins/tags.js.es6 b/app/assets/javascripts/select-kit/mixins/tags.js.es6index 1fbe4588daa..3e4f3f9ad53 100644--- a/app/assets/javascripts/select-kit/mixins/tags.js.es6+++ b/app/assets/javascripts/select-kit/mixins/tags.js.es6@@ -11,8 +11,6 @@ export default Ember.Mixin.create({},searchTags(url, data, callback) {- const self = this;-this.startLoading();return ajax(Discourse.getURL(url), {@@ -22,15 +20,11 @@ export default Ember.Mixin.create({data}).then(json => {- self.set("asyncContent", callback(self, json));- self.autoHighlight();- })- .catch(error => {- popupAjaxError(error);+ this.set("asyncContent", callback(this, json));+ this.autoHighlight();})- .finally(() => {- self.stopLoading();- });+ .catch(error => popupAjaxError(error))+ .finally(() => this.stopLoading());},validateCreate(term) {@@ -63,6 +57,7 @@ export default Ember.Mixin.create({const inSelection = this.get("selection").map(s => toLowerCaseOrUndefined(get(s, "value"))).includes(term);+if (inCollection || inSelection) {return false;}@@ -72,7 +67,7 @@ export default Ember.Mixin.create({createContentFromInput(input) {// See lib/discourse_tagging#clean_tag.- var content = input+ let content = input.trim().replace(/\s+/g, "-").replace(/[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/g, "")