2021-07-14 00:22:39 +08:00
|
|
|
import { computed } from "@ember/object";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
2021-07-08 15:46:21 +08:00
|
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
2024-08-23 19:17:07 +08:00
|
|
|
import {
|
|
|
|
pluginApiIdentifiers,
|
|
|
|
selectKitOptions,
|
|
|
|
} from "select-kit/components/select-kit";
|
2021-07-08 15:46:21 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@classNames("flair-chooser")
|
|
|
|
@selectKitOptions({
|
|
|
|
selectedNameComponent: "selected-flair",
|
|
|
|
})
|
|
|
|
@pluginApiIdentifiers(["flair-chooser"])
|
|
|
|
export default class FlairChooser extends ComboBoxComponent {
|
2021-07-08 15:46:21 +08:00
|
|
|
modifyComponentForRow() {
|
|
|
|
return "flair-row";
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2021-07-14 00:22:39 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@computed("value", "content.[]", "selectKit.noneItem")
|
|
|
|
get selectedContent() {
|
|
|
|
const content = (this.content || []).findBy(
|
|
|
|
this.selectKit.valueProperty,
|
|
|
|
this.value
|
|
|
|
);
|
2021-07-14 00:22:39 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
if (content) {
|
|
|
|
return this.selectKit.modifySelection(content);
|
|
|
|
} else {
|
|
|
|
return this.selectKit.noneItem;
|
2021-07-14 00:22:39 +08:00
|
|
|
}
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
|
|
|
}
|