2021-08-23 16:44:19 +08:00
|
|
|
import Component from "@ember/component";
|
|
|
|
import { computed } from "@ember/object";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { guidFor } from "@ember/object/internals";
|
2024-08-23 19:17:07 +08:00
|
|
|
import { tagName } from "@ember-decorators/component";
|
2021-08-23 16:44:19 +08:00
|
|
|
import UtilsMixin from "select-kit/mixins/utils";
|
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@tagName("")
|
|
|
|
export default class SelectedChoice extends Component.extend(UtilsMixin) {
|
|
|
|
item = null;
|
|
|
|
selectKit = null;
|
|
|
|
extraClass = null;
|
|
|
|
id = null;
|
2021-08-23 16:44:19 +08:00
|
|
|
|
|
|
|
init() {
|
2024-08-23 19:17:07 +08:00
|
|
|
super.init(...arguments);
|
2021-08-23 16:44:19 +08:00
|
|
|
|
|
|
|
this.set("id", guidFor(this));
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2021-08-23 16:44:19 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@computed("item")
|
|
|
|
get itemValue() {
|
2021-08-23 16:44:19 +08:00
|
|
|
return this.getValue(this.item);
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2021-08-23 16:44:19 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@computed("item")
|
|
|
|
get itemName() {
|
2021-08-23 16:44:19 +08:00
|
|
|
return this.getName(this.item);
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2024-04-18 06:53:52 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@computed("item")
|
|
|
|
get mandatoryValuesArray() {
|
2024-04-18 06:53:52 +08:00
|
|
|
return this.get("mandatoryValues")?.split("|") || [];
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
2024-04-18 06:53:52 +08:00
|
|
|
|
2024-08-23 19:17:07 +08:00
|
|
|
@computed("item")
|
|
|
|
get readOnly() {
|
2024-04-18 06:53:52 +08:00
|
|
|
return this.mandatoryValuesArray.includes(this.item.id);
|
2024-08-23 19:17:07 +08:00
|
|
|
}
|
|
|
|
}
|