discourse/app/assets/javascripts/select-kit/components/multi-select/selected-name.js.es6

47 lines
1.3 KiB
Plaintext
Raw Normal View History

import computed from "ember-addons/ember-computed-decorators";
2017-11-10 02:57:53 +08:00
export default Ember.Component.extend({
attributeBindings: [
"tabindex",
"ariaLabel:aria-label",
"title",
"name:data-name",
"value:data-value",
"guid:data-guid"
],
classNames: ["selected-name", "choice"],
2017-11-10 02:57:53 +08:00
classNameBindings: ["isHighlighted", "isLocked"],
layoutName: "select-kit/templates/components/multi-select/selected-name",
tagName: "span",
2017-11-10 02:57:53 +08:00
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);
2017-11-10 02:57:53 +08:00
}),
click() {
if (this.get("isLocked") === true) { return false; }
this.toggleProperty("isHighlighted");
return false;
}
});