summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/admin/jobs/index/index.js
blob: 4df210debb564daeaf9defbc742281f03ea6cf5b (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
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import stopJobsModal from './components/stop_jobs_modal.vue';

Vue.use(Translate);

document.addEventListener('DOMContentLoaded', () => {
  const buttonId = 'js-stop-jobs-button';
  const modalId = 'stop-jobs-modal';
  const stopJobsButton = document.getElementById(buttonId);
  if (stopJobsButton) {
    // eslint-disable-next-line no-new
    new Vue({
      el: `#js-${modalId}`,
      components: {
        stopJobsModal,
      },
      mounted() {
        stopJobsButton.classList.remove('disabled');
        stopJobsButton.addEventListener('click', () => {
          this.$root.$emit('bv::show::modal', modalId, `#${buttonId}`);
        });
      },
      render(createElement) {
        return createElement(modalId, {
          props: {
            url: stopJobsButton.dataset.url,
          },
        });
      },
    });
  }
});