Skip to content

Commit

Permalink
Switched to msgBoxConfirm instead
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Schauer-Köckeis <[email protected]>
  • Loading branch information
Gepardgame committed Sep 17, 2024
1 parent 74e7bff commit 7054907
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 86 deletions.
41 changes: 0 additions & 41 deletions src/views/components/NotificationDialog.vue

This file was deleted.

61 changes: 16 additions & 45 deletions src/views/portfolio/projects/ProjectDetailsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ import permissionsMixin from '../../../mixins/permissionsMixin';
import common from '../../../shared/common';
import Multiselect from 'vue-multiselect';
import xssFilters from 'xss-filters';
import NotificationDialog from '../../components/NotificationDialog';
import Vue from 'vue';
export default {
name: 'ProjectDetailsModal',
Expand Down Expand Up @@ -712,50 +710,23 @@ export default {
},
deleteProject: async function () {
this.$root.$emit('bv::hide::modal', 'projectDetailsModal');
try {
await this.showWarning(
this.$t('message.project_delete_message'),
this.$t('message.project_delete_title'),
);
} catch {
return;
}
let url =
`${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid;
this.axios
.delete(url)
.then((response) => {
this.$toastr.s(this.$t('message.project_deleted'));
this.$router.replace({ name: 'Projects' });
})
.catch((error) => {
this.$toastr.w(this.$t('condition.unsuccessful_action'));
});
},
async showWarning(message, title) {
return new Promise((resolve, reject) => {
const WarningConstructor = Vue.extend(NotificationDialog);
const instance = new WarningConstructor({
propsData: { message, title },
});
instance.$mount();
document.body.appendChild(instance.$el);
instance.$bvModal.show('notification-dialog');
instance.$on('confirm', () => {
resolve();
this.cleanupInstance(instance);
});
instance.$on('cancel', () => {
reject();
this.cleanupInstance(instance);
let confirmed = await this.$bvModal
.msgBoxConfirm(this.$t('message.project_delete_message'), {
title: this.$t('message.project_delete_title'),
});
});
},
cleanupInstance(instance) {
document.body.removeChild(instance.$el);
instance.$destroy();
if (confirmed) {
let url =
`${this.$api.BASE_URL}/${this.$api.URL_PROJECT}/` + this.project.uuid;
this.axios
.delete(url)
.then((response) => {
this.$toastr.s(this.$t('message.project_deleted'));
this.$router.replace({ name: 'Projects' });
})
.catch((error) => {
this.$toastr.w(this.$t('condition.unsuccessful_action'));
});
}
},
hasActiveChild: function (project) {
return (
Expand Down

0 comments on commit 7054907

Please sign in to comment.