This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/select-box/select-box-row.js.es6
Joffrey JAFFEUX e924920bec uses select-box for pinned-button
This commit also moves more logic in dropdown-select-box instead of
duplicating it for notifications-options and pinned-options
2017-09-11 19:14:22 +02:00

53 lines
1.2 KiB
JavaScript

import computed from 'ember-addons/ember-computed-decorators';
import { iconHTML } from "discourse-common/lib/icon-library";
export default Ember.Component.extend({
layoutName: "components/select-box/select-box-row",
classNames: "select-box-row",
tagName: "li",
attributeBindings: ["title"],
classNameBindings: ["isHighlighted:is-highlighted", "isSelected:is-selected"],
@computed("titleForRow")
title(titleForRow) {
return titleForRow(this);
},
@computed("templateForRow")
template(templateForRow) {
return templateForRow(this);
},
@computed("shouldHighlightRow", "highlightedValue")
isHighlighted(shouldHighlightRow) {
return shouldHighlightRow(this);
},
@computed("shouldSelectRow", "value")
isSelected(shouldSelectRow) {
return shouldSelectRow(this);
},
icon() {
if (this.get("content.icon")) {
const iconName = this.get("content.icon");
const iconClass = this.get("content.iconClass");
return iconHTML(iconName, { class: iconClass });
}
return null;
},
mouseEnter() {
this.sendAction("onHover", this.get("content"));
},
click() {
this.sendAction("onSelect", this.get("content"));
}
});