discourse/app/assets/javascripts/admin/controllers/admin-emojis.js

Failed to ignore revisions in .git-blame-ignore-revs.

38 lines
961 B
JavaScript
Raw Normal View History

import { sort } from "@ember/object/computed";
import EmberObject from "@ember/object";
import Controller from "@ember/controller";
2018-06-15 11:03:24 -04:00
import { ajax } from "discourse/lib/ajax";
export default Controller.extend({
sortedEmojis: sort("model", "emojiSorting"),
init() {
this._super(...arguments);
this.emojiSorting = ["name"];
},
2014-12-22 19:12:26 -05:00
actions: {
emojiUploaded(emoji) {
emoji.url += "?t=" + new Date().getTime();
this.model.pushObject(EmberObject.create(emoji));
2014-12-22 19:12:26 -05:00
},
destroy(emoji) {
return bootbox.confirm(
I18n.t("admin.emoji.delete_confirm", { name: emoji.get("name") }),
I18n.t("no_value"),
I18n.t("yes_value"),
destroy => {
if (destroy) {
2018-06-15 11:03:24 -04:00
return ajax("/admin/customize/emojis/" + emoji.get("name"), {
type: "DELETE"
}).then(() => {
this.model.removeObject(emoji);
});
}
2014-12-22 19:12:26 -05:00
}
);
2014-12-22 19:12:26 -05:00
}
}
});