2017-11-21 18:53:09 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
|
|
|
|
2017-11-10 02:57:53 +08:00
|
|
|
export default Ember.Component.extend({
|
2017-11-21 18:53:09 +08:00
|
|
|
attributeBindings: [
|
|
|
|
"tabindex",
|
2017-12-22 20:08:12 +08:00
|
|
|
"ariaLabel:aria-label",
|
|
|
|
"title",
|
|
|
|
"name:data-name",
|
|
|
|
"value:data-value",
|
2017-11-21 18:53:09 +08:00
|
|
|
"guid:data-guid"
|
|
|
|
],
|
|
|
|
classNames: ["selected-name", "choice"],
|
2017-11-10 02:57:53 +08:00
|
|
|
classNameBindings: ["isHighlighted", "isLocked"],
|
2017-11-21 18:53:09 +08:00
|
|
|
layoutName: "select-kit/templates/components/multi-select/selected-name",
|
2017-11-27 00:21:39 +08:00
|
|
|
tagName: "span",
|
2017-11-10 02:57:53 +08:00
|
|
|
tabindex: -1,
|
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
@computed("computedContent")
|
|
|
|
guid(computedContent) { return Ember.guidFor(computedContent); },
|
2017-11-21 18:53:09 +08:00
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
|
|
|
|
|
|
|
|
@computed("computedContent.title", "name")
|
|
|
|
title(computedContentTitle, name) {
|
|
|
|
if (computedContentTitle) return computedContentTitle;
|
|
|
|
if (name) return name;
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
label: Ember.computed.or("computedContent.label", "title", "name"),
|
|
|
|
|
|
|
|
name: Ember.computed.alias("computedContent.name"),
|
|
|
|
|
|
|
|
value: Ember.computed.alias("computedContent.value"),
|
|
|
|
|
|
|
|
isLocked: Ember.computed("computedContent.locked", function() {
|
|
|
|
return this.getWithDefault("computedContent.locked", false);
|
2017-11-10 02:57:53 +08:00
|
|
|
}),
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
@computed("computedContent", "highlightedSelection.[]")
|
|
|
|
isHighlighted(computedContent, highlightedSelection) {
|
|
|
|
return highlightedSelection.includes(this.get("computedContent"));
|
2018-02-26 18:42:57 +08:00
|
|
|
},
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
click() {
|
|
|
|
if (this.get("isLocked")) return false;
|
|
|
|
this.sendAction("onClickSelectionItem", [this.get("computedContent")]);
|
|
|
|
return false;
|
2017-11-10 02:57:53 +08:00
|
|
|
}
|
|
|
|
});
|