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

confirm_modal.js « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff29d5fa3555d8f6c203b6292b453711e420a754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Vue from 'vue';
import ConfirmModal from '~/vue_shared/components/confirm_modal.vue';

const mountConfirmModal = () => {
  return new Vue({
    data() {
      return {
        path: '',
        method: '',
        modalAttributes: null,
        showModal: false,
      };
    },
    mounted() {
      document.querySelectorAll('.js-confirm-modal-button').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.showModal = true;
        });
      });
    },
    methods: {
      dismiss() {
        this.showModal = false;
      },
    },
    render(h) {
      return h(ConfirmModal, {
        props: {
          path: this.path,
          method: this.method,
          modalAttributes: this.modalAttributes,
          showModal: this.showModal,
        },
        on: { dismiss: this.dismiss },
      });
    },
  }).$mount();
};

export default () => mountConfirmModal();