Files
forum/plugins/poll/assets/javascripts/discourse/components/poll-option-ranked-choice-dropdown.gjs
David TaylorandGitHub aae6642947 DEV: Enable discourse-common-imports eslint rule (#30742)
Applies the autofix, which caught a few places that were missed in the
original find/replace

See https://github.com/discourse/lint-configs/pull/91
2025-01-13 16:01:34 +00:00

52 lines
1.4 KiB
Plaintext

import Component from "@glimmer/component";
import { fn } from "@ember/helper";
import { action } from "@ember/object";
import DButton from "discourse/components/d-button";
import DropdownMenu from "discourse/components/dropdown-menu";
import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n";
import DMenu from "float-kit/components/d-menu";
export default class PollOptionsDropdownComponent extends Component {
@action
onRegisterApi(api) {
this.dMenu = api;
}
@action
selectRank(option, rank) {
this.args.sendRank(option, rank);
this.dMenu.close();
}
get rankLabel() {
return this.args.rank === 0
? i18n("poll.options.ranked_choice.abstain")
: this.args.rank;
}
<template>
<DMenu @onRegisterApi={{this.onRegisterApi}}>
<:trigger>
<span class="d-button-label">
{{this.rankLabel}}
</span>
{{icon "angle-down"}}
</:trigger>
<:content>
<DropdownMenu as |dropdown|>
{{#each @rankedChoiceDropdownContent as |content|}}
<dropdown.item>
<DButton
@translatedLabel={{content.name}}
class="btn-transparent poll-option-dropdown"
@action={{fn this.selectRank @option.id content.id}}
/>
</dropdown.item>
{{/each}}
</DropdownMenu>
</:content>
</DMenu>
</template>
}