Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 00:09:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 00:09:21 +0300
commit06bb4eba7828ce59fde366734828458c037059b4 (patch)
tree44b95a53123d91684cc1c67716ef87cc1c0964fb /app/assets/javascripts/vue_shared
parent219eead23f9feb5da9ec378c451d773aea2dfe61 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared')
-rw-r--r--app/assets/javascripts/vue_shared/components/confirm_modal.vue58
1 files changed, 27 insertions, 31 deletions
diff --git a/app/assets/javascripts/vue_shared/components/confirm_modal.vue b/app/assets/javascripts/vue_shared/components/confirm_modal.vue
index c77827205d6..52ff906ccec 100644
--- a/app/assets/javascripts/vue_shared/components/confirm_modal.vue
+++ b/app/assets/javascripts/vue_shared/components/confirm_modal.vue
@@ -1,49 +1,45 @@
<script>
import { GlModal } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
+import { uniqueId } from 'lodash';
export default {
components: {
GlModal,
},
props: {
- modalAttributes: {
- type: Object,
- required: false,
- default: () => {
- return {};
- },
- },
- path: {
- type: String,
- required: false,
- default: '',
- },
- method: {
+ selector: {
type: String,
- required: false,
- default: '',
- },
- showModal: {
- type: Boolean,
- required: false,
- default: false,
+ required: true,
},
},
- watch: {
- showModal(val) {
- if (val) {
- // Wait for v-if to render
- this.$nextTick(() => {
- this.openModal();
- });
- }
- },
+ data() {
+ return {
+ modalId: uniqueId('confirm-modal-'),
+ path: '',
+ method: '',
+ modalAttributes: {},
+ };
+ },
+ mounted() {
+ document.querySelectorAll(this.selector).forEach(button => {
+ button.addEventListener('click', e => {
+ e.preventDefault();
+
+ this.path = button.dataset.path;
+ this.method = button.dataset.method;
+ this.modalAttributes = JSON.parse(button.dataset.modalAttributes);
+ this.openModal();
+ });
+ });
},
methods: {
openModal() {
this.$refs.modal.show();
},
+ closeModal() {
+ this.$refs.modal.hide();
+ },
submitModal() {
this.$refs.form.submit();
},
@@ -54,11 +50,11 @@ export default {
<template>
<gl-modal
- v-if="showModal"
ref="modal"
+ :modal-id="modalId"
v-bind="modalAttributes"
@primary="submitModal"
- @canceled="$emit('dismiss')"
+ @cancel="closeModal"
>
<form ref="form" :action="path" method="post">
<!-- Rails workaround for <form method="delete" />