discourse/app/assets/javascripts/admin/addon/components/site-settings/bool.gjs
Martin Brennan 4aa7a89371
DEV: Round 1 converting admin site setting components to gjs (#30526)
Converts the following site setting components:

* Bool
* Category
* Colors
* Category
* CompactList
* EmojiList
2025-01-03 11:34:28 +10:00

34 lines
827 B
Plaintext

import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { htmlSafe } from "@ember/template";
import { isEmpty } from "@ember/utils";
export default class Bool extends Component {
@tracked
enabled = isEmpty(this.args.value)
? false
: this.args.value.toString() === "true";
@action
onToggle(event) {
if (event.target.checked) {
this.args.changeValueCallback("true");
} else {
this.args.changeValueCallback("false");
}
}
<template>
<label class="checkbox-label">
<input
{{on "input" this.onToggle}}
type="checkbox"
checked={{this.enabled}}
/>
<span>{{htmlSafe @setting.description}}</span>
</label>
</template>
}