mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
cleaner title attribute for select-box
This commit is contained in:
@@ -16,20 +16,24 @@ export default DropdownSelectBoxComponent.extend({
|
||||
|
||||
value: Em.computed.alias("notificationLevel"),
|
||||
|
||||
@computed("value")
|
||||
icon(value) {
|
||||
const details = buttonDetails(value);
|
||||
@computed("selectedDetails")
|
||||
icon(details) {
|
||||
return iconHTML(details.icon, {class: details.key}).htmlSafe();
|
||||
},
|
||||
|
||||
@computed("value", "showFullTitle")
|
||||
generatedHeadertext(value, showFullTitle) {
|
||||
if (showFullTitle) {
|
||||
const details = buttonDetails(value);
|
||||
return I18n.t(`${this.get("i18nPrefix")}.${details.key}.title`);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@computed("selectedDetails.key", "i18nPrefix")
|
||||
selectedTitle(key, prefix) {
|
||||
return I18n.t(`${prefix}.${key}.title`);
|
||||
},
|
||||
|
||||
@computed("value")
|
||||
selectedDetails(value) {
|
||||
return buttonDetails(value);
|
||||
},
|
||||
|
||||
@computed("selectedTitle", "showFullTitle")
|
||||
generatedHeadertext(selectedTitle, showFullTitle) {
|
||||
return showFullTitle ? selectedTitle : null;
|
||||
},
|
||||
|
||||
@computed
|
||||
|
||||
@@ -308,6 +308,15 @@ export default Ember.Component.extend({
|
||||
});
|
||||
},
|
||||
|
||||
@computed("headerText", "selectedContent", "textKey")
|
||||
selectedTitle(headerText, selectedContent, textKey) {
|
||||
if (Ember.isNone(selectedContent)) {
|
||||
return headerText;
|
||||
}
|
||||
|
||||
return selectedContent[textKey];
|
||||
},
|
||||
|
||||
@computed("headerText", "dynamicHeaderText", "selectedContent", "textKey", "clearSelectionLabel")
|
||||
generatedHeadertext(headerText, dynamic, selectedContent, textKey, clearSelectionLabel) {
|
||||
if (dynamic && !Ember.isNone(selectedContent)) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<button
|
||||
class="btn {{if text 'btn-icon-text' 'no-text btn-icon'}}"
|
||||
aria-label="{{text}}"
|
||||
aria-label="{{selectedTitle}}"
|
||||
type="button"
|
||||
title="{{text}}">
|
||||
title="{{selectedTitle}}">
|
||||
|
||||
{{{icon}}}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
{{component selectBoxHeaderComponent
|
||||
text=generatedHeadertext
|
||||
selectedTitle=selectedTitle
|
||||
focused=focused
|
||||
caretUpIcon=caretUpIcon
|
||||
caretDownIcon=caretDownIcon
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{d-icon icon class="icon"}}
|
||||
{{/if}}
|
||||
|
||||
<span class="current-selection">
|
||||
<span class="current-selection" title={{selectedTitle}}>
|
||||
{{text}}
|
||||
</span>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user