DEV: Convert PreferenceCheckbox to gjs (#24817)

This commit is contained in:
Jarek Radosz 2023-12-11 22:03:03 +01:00 committed by GitHub
parent c6a2c80441
commit 3999f3e826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 35 deletions

View File

@ -0,0 +1,19 @@
import { Input } from "@ember/component";
import concatClass from "discourse/helpers/concat-class";
import i18n from "discourse-common/helpers/i18n";
const PreferenceCheckbox = <template>
<div class={{concatClass "controls" @class}} ...attributes>
<label class="checkbox-label">
<Input @type="checkbox" @checked={{@checked}} disabled={{@disabled}} />
{{#if @labelCount}}
{{i18n @labelKey count=@labelCount}}
{{else}}
{{i18n @labelKey}}
{{/if}}
</label>
</div>
</template>;
export default PreferenceCheckbox;

View File

@ -1,8 +0,0 @@
<label class="checkbox-label">
<Input
@type="checkbox"
disabled={{this.disabled}}
@checked={{this.checked}}
/>
{{this.label}}
</label>

View File

@ -1,27 +0,0 @@
import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "discourse-i18n";
export default Component.extend({
classNames: ["controls"],
@discourseComputed("labelKey", "labelCount")
label(labelKey, labelCount) {
if (labelCount) {
return I18n.t(labelKey, { count: labelCount });
} else {
return I18n.t(labelKey);
}
},
change() {
const warning = this.warning;
if (warning && this.checked) {
this.warning();
return false;
}
return true;
},
});