mirror of
https://github.com/discourse/discourse.git
synced 2025-02-09 12:54:56 +00:00
FIX: improves tag-list setting (#9574)
- Prevents setting to display an empty tag - Updates dropdown when selecting/removing tag
This commit is contained in:
parent
1e603d7003
commit
a8308e73e7
@ -1,15 +1,17 @@
|
|||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
@discourseComputed("value")
|
@discourseComputed("value")
|
||||||
selectedTags: {
|
selectedTags: {
|
||||||
get(value) {
|
get(value) {
|
||||||
return value.split("|");
|
return value.split("|").filter(Boolean);
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
this.set("value", value.join("|"));
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
changeSelectedTags(tags) {
|
||||||
|
this.set("value", tags.join("|"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
{{tag-chooser tags=selectedTags allowCreate=false}}
|
{{tag-chooser
|
||||||
|
tags=selectedTags
|
||||||
|
onChange=(action "changeSelectedTags")
|
||||||
|
options=(hash
|
||||||
|
allowAny=false
|
||||||
|
)
|
||||||
|
}}
|
||||||
<div class="desc">{{html-safe setting.description}}</div>
|
<div class="desc">{{html-safe setting.description}}</div>
|
||||||
{{setting-validation-message message=validationMessage}}
|
{{setting-validation-message message=validationMessage}}
|
||||||
|
@ -66,8 +66,12 @@ export default MultiSelectComponent.extend(TagsMixin, {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onChange(value) {
|
onChange(value, items) {
|
||||||
this.set("tags", value);
|
if (this.attrs.onChange) {
|
||||||
|
this.attrs.onChange(value, items);
|
||||||
|
} else {
|
||||||
|
this.set("tags", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user