This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/review-settings.js.es6
2019-05-23 12:16:45 -04:00

28 lines
685 B
JavaScript

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Controller.extend({
saving: false,
saved: false,
actions: {
save() {
let priorities = {};
this.get("settings.reviewable_score_types").forEach(st => {
priorities[st.id] = parseFloat(st.reviewable_priority);
});
this.set("saving", true);
ajax("/review/settings", {
method: "PUT",
data: { reviewable_priorities: priorities }
})
.then(() => {
this.set("saved", true);
})
.catch(popupAjaxError)
.finally(() => this.set("saving", false));
}
}
});