DEV: removes unused badge-selector (#27803)

This commit is contained in:
Joffrey JAFFEUX 2024-07-09 21:06:13 +02:00 committed by GitHub
parent 5fc7c79d8e
commit 56cd318728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 63 deletions

View File

@ -1,6 +0,0 @@
<input
type="text"
placeholder={{this.placeholder}}
name="badges"
class="ember-text-field badge-names"
/>

View File

@ -1,57 +0,0 @@
import Component from "@ember/component";
import $ from "jquery";
import { makeArray } from "discourse-common/lib/helpers";
import { findRawTemplate } from "discourse-common/lib/raw-templates";
import discourseComputed, {
observes,
on,
} from "discourse-common/utils/decorators";
import I18n from "discourse-i18n";
export default Component.extend({
@discourseComputed("placeholderKey")
placeholder(placeholderKey) {
return placeholderKey ? I18n.t(placeholderKey) : "";
},
@observes("badgeNames")
_update() {
if (this.canReceiveUpdates === "true") {
this._initializeAutocomplete({ updateData: true });
}
},
@on("didInsertElement")
_initializeAutocomplete(opts) {
let selectedBadges;
$(this.element.querySelector("input")).autocomplete({
allowAny: false,
items: makeArray(this.badgeNames),
single: this.single,
updateData: opts && opts.updateData ? opts.updateData : false,
template: findRawTemplate("badge-selector-autocomplete"),
onChangeItems(items) {
selectedBadges = items;
this.set("badgeNames", items.join(","));
},
transformComplete(g) {
return g.name;
},
dataSource(term) {
return this.badgeFinder(term).then((badges) => {
if (!selectedBadges) {
return badges;
}
return badges.filter(
(badge) => !selectedBadges.any((s) => s === badge.name)
);
});
},
});
},
});