diff --git a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js index 098f8defa87..fdb7204d527 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js @@ -201,19 +201,24 @@ export default class AdminBadgesShowController extends Controller { } } + @action + registerApi(api) { + this.formApi = api; + } + @action async handleDelete() { if (!this.model?.id) { return this.router.transitionTo("adminBadges.index"); } - const adminBadges = this.adminBadges.model; return this.dialog.yesNoConfirm({ message: I18n.t("admin.badges.delete_confirm"), didConfirm: async () => { try { + await this.formApi.reset(); await this.model.destroy(); - adminBadges.removeObject(this.model); + this.adminBadges.model.removeObject(this.model); this.router.transitionTo("adminBadges.index"); } catch { this.dialog.alert(I18n.t("generic_error")); diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs index 9eeea37fddf..643463e8e88 100644 --- a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs +++ b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs @@ -2,6 +2,7 @@ @data={{this.formData}} @onSubmit={{this.handleSubmit}} @validate={{this.validateForm}} + @onRegisterApi={{this.registerApi}} class="badge-form current-badge content-body" as |form data| > @@ -295,7 +296,10 @@