FIX: Editing tags was double rendering
This commit is contained in:
parent
2655be512f
commit
d69b782737
|
@ -8,10 +8,17 @@ export default Ember.TextField.extend({
|
|||
classNameBindings: [':tag-chooser'],
|
||||
attributeBindings: ['tabIndex', 'placeholderKey', 'categoryId'],
|
||||
|
||||
_initValue: function() {
|
||||
init() {
|
||||
this._super();
|
||||
const tags = this.get('tags') || [];
|
||||
this.set('value', tags.join(", "));
|
||||
}.on('init'),
|
||||
|
||||
if (this.get('allowCreate') !== false) {
|
||||
this.set('allowCreate', this.site.get('can_create_tag'));
|
||||
}
|
||||
|
||||
this.set('termMatchesForbidden', false);
|
||||
},
|
||||
|
||||
_valueChanged: function() {
|
||||
const tags = this.get('value').split(',').map(v => v.trim()).reject(v => v.length === 0).uniq();
|
||||
|
@ -32,18 +39,13 @@ export default Ember.TextField.extend({
|
|||
}
|
||||
}.observes('tags'),
|
||||
|
||||
_initializeTags: function() {
|
||||
const site = this.site,
|
||||
self = this,
|
||||
filterRegexp = new RegExp(this.site.tags_filter_regexp, "g");
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
var limit = this.siteSettings.max_tags_per_topic;
|
||||
const self = this;
|
||||
const filterRegexp = new RegExp(this.site.tags_filter_regexp, "g");
|
||||
|
||||
if (this.get('allowCreate') !== false) {
|
||||
this.set('allowCreate', site.get('can_create_tag'));
|
||||
}
|
||||
|
||||
this.set('termMatchesForbidden', false);
|
||||
let limit = this.siteSettings.max_tags_per_topic;
|
||||
|
||||
if (this.get('unlimitedTagCount')) {
|
||||
limit = null;
|
||||
|
@ -77,7 +79,7 @@ export default Ember.TextField.extend({
|
|||
|
||||
callback(data);
|
||||
},
|
||||
createSearchChoice: function(term, data) {
|
||||
createSearchChoice(term, data) {
|
||||
term = term.replace(filterRegexp, '').trim().toLowerCase();
|
||||
|
||||
// No empty terms, make sure the user has permission to create the tag
|
||||
|
@ -89,14 +91,14 @@ export default Ember.TextField.extend({
|
|||
return { id: term, text: term };
|
||||
}
|
||||
},
|
||||
createSearchChoicePosition: function(list, item) {
|
||||
createSearchChoicePosition(list, item) {
|
||||
// Search term goes on the bottom
|
||||
list.push(item);
|
||||
},
|
||||
formatSelection: function (data) {
|
||||
formatSelection(data) {
|
||||
return data ? renderTag(this.text(data)) : undefined;
|
||||
},
|
||||
formatSelectionCssClass: function(){
|
||||
formatSelectionCssClass() {
|
||||
return "discourse-tag-select2";
|
||||
},
|
||||
formatResult: formatTag,
|
||||
|
@ -127,10 +129,11 @@ export default Ember.TextField.extend({
|
|||
}
|
||||
},
|
||||
});
|
||||
}.on('didInsertElement'),
|
||||
},
|
||||
|
||||
_destroyTags: function() {
|
||||
willDestroyElement() {
|
||||
this._super();
|
||||
this.$().select2('destroy');
|
||||
}.on('willDestroyElement')
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue