DEV: removes unused badge-selector (#27803)
This commit is contained in:
parent
5fc7c79d8e
commit
56cd318728
|
@ -1,6 +0,0 @@
|
|||
<input
|
||||
type="text"
|
||||
placeholder={{this.placeholder}}
|
||||
name="badges"
|
||||
class="ember-text-field badge-names"
|
||||
/>
|
|
@ -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)
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue