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
Jarek Radosz 67b34600d5
DEV: Use type instead of method in ajax calls (#8974)
Even though `type` is an alias for `method`, we have custom logic in `/discourse/lib/ajax` that checks only `type`, and ~200 other ajax calls in the codebase already use `type` param.
2020-03-26 21:00:10 +01:00

29 lines
721 B
JavaScript

import Controller from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default 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", {
type: "PUT",
data: { reviewable_priorities: priorities }
})
.then(() => {
this.set("saved", true);
})
.catch(popupAjaxError)
.finally(() => this.set("saving", false));
}
}
});