DEV: Convert track-selected to glimmer/gjs (#26773)

This commit is contained in:
Jarek Radosz 2024-04-27 11:58:42 +02:00 committed by GitHub
parent fb40f50865
commit 2a52f7f13f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 20 deletions

View File

@ -0,0 +1,20 @@
import Component from "@glimmer/component";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
export default class TrackSelected extends Component {
@action
onToggle(e) {
if (e.target.checked) {
this.args.selectedList.addObject(this.args.selectedId);
} else {
this.args.selectedList.removeObject(this.args.selectedId);
}
}
<template>
<span class={{@class}} ...attributes>
<input {{on "input" this.onToggle}} type="checkbox" />
</span>
</template>
}

View File

@ -1 +0,0 @@
<Input @type="checkbox" @checked={{this.selected}} />

View File

@ -1,19 +0,0 @@
import Component from "@ember/component";
import { observes } from "discourse-common/utils/decorators";
export default Component.extend({
tagName: "span",
@observes("selected")
selectionChanged() {
const selected = this.selected;
const list = this.selectedList;
const id = this.selectedId;
if (selected) {
list.addObject(id);
} else {
list.removeObject(id);
}
},
});