mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:21:23 +08:00
DEV: Refactor the last few bootbox dialogs (#18416)
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
import { gte, sort } from "@ember/object/computed";
|
||||
import Controller from "@ember/controller";
|
||||
import I18n from "I18n";
|
||||
import bootbox from "bootbox";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
const MAX_FIELDS = 30;
|
||||
|
||||
export default Controller.extend({
|
||||
dialog: service(),
|
||||
fieldTypes: null,
|
||||
createDisabled: gte("model.length", MAX_FIELDS),
|
||||
sortedFields: sort("model", "fieldSortOrder"),
|
||||
@ -53,18 +54,17 @@ export default Controller.extend({
|
||||
|
||||
// Only confirm if we already been saved
|
||||
if (f.get("id")) {
|
||||
bootbox.confirm(
|
||||
I18n.t("admin.user_fields.delete_confirm"),
|
||||
function (result) {
|
||||
if (result) {
|
||||
f.destroyRecord()
|
||||
.then(function () {
|
||||
model.removeObject(f);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
}
|
||||
);
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.user_fields.delete_confirm"),
|
||||
didConfirm: () => {
|
||||
return f
|
||||
.destroyRecord()
|
||||
.then(function () {
|
||||
model.removeObject(f);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
model.removeObject(f);
|
||||
}
|
||||
|
Reference in New Issue
Block a user