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