mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 02:43:39 +08:00
5bff65aa69
Both of the commits in this PR are meant to fix the problem of invalid
option being shown in the flair chooser. An invalid option can be shown
if at some point it was a valid one - a group with a flair that was
later changed by an admin and flair was removed. The other option an
invalid option can be selected is if the user had a primary group when
the migration ran and copied the same value to the flair_group_id
column.
* FIX: Set flair_group_id only if group has flair
Follow up to 4ba93aac66
.
* FIX: Do not show invalid option in flair chooser
If selected flair group became unavailable because the flair was removed
then the option would still be selected and visible as an ID only.
34 lines
735 B
JavaScript
34 lines
735 B
JavaScript
import { computed } from "@ember/object";
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
|
|
|
export default ComboBoxComponent.extend({
|
|
pluginApiIdentifiers: ["flair-chooser"],
|
|
classNames: ["flair-chooser"],
|
|
|
|
selectKitOptions: {
|
|
selectedNameComponent: "selected-flair",
|
|
},
|
|
|
|
modifyComponentForRow() {
|
|
return "flair-row";
|
|
},
|
|
|
|
selectedContent: computed(
|
|
"value",
|
|
"content.[]",
|
|
"selectKit.noneItem",
|
|
function () {
|
|
const content = (this.content || []).findBy(
|
|
this.selectKit.valueProperty,
|
|
this.value
|
|
);
|
|
|
|
if (content) {
|
|
return this.selectKit.modifySelection(content);
|
|
} else {
|
|
return this.selectKit.noneItem;
|
|
}
|
|
}
|
|
),
|
|
});
|