discourse/app/assets/javascripts/select-kit/components/multi-select/selected-name.js.es6
Joffrey JAFFEUX f9648de897
DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808)
Co-Authored-By: Bianca Nenciu <nbianca@users.noreply.github.com>
Co-Authored-By: David Taylor <david@taylorhq.com>
2019-01-10 11:06:01 +01:00

54 lines
1.5 KiB
JavaScript

import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
attributeBindings: [
"tabindex",
"ariaLabel:aria-label",
"title",
"name:data-name",
"value:data-value",
"guid:data-guid"
],
classNames: ["selected-name", "choice"],
classNameBindings: ["isHighlighted", "isLocked"],
layoutName: "select-kit/templates/components/multi-select/selected-name",
tagName: "span",
tabindex: -1,
@computed("computedContent")
guid(computedContent) {
return Ember.guidFor(computedContent);
},
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);
}),
@computed("computedContent", "highlightedSelection.[]")
isHighlighted(computedContent, highlightedSelection) {
return highlightedSelection.includes(this.get("computedContent"));
},
click() {
if (this.get("isLocked")) return false;
this.onClickSelectionItem([this.get("computedContent")]);
return false;
}
});