pipeline_schedule_form_bundle.js 1.4 KB
Newer Older
1
import Vue from 'vue';
2 3
import Translate from '../vue_shared/translate';
import intervalPatternInput from './components/interval_pattern_input.vue';
4 5 6
import TimezoneDropdown from './components/timezone_dropdown';
import TargetBranchDropdown from './components/target_branch_dropdown';

7 8 9
Vue.use(Translate);

function initIntervalPatternInput() {
10 11 12
  const intervalPatternMount = document.getElementById('interval-pattern-input');
  const initialCronInterval = intervalPatternMount ? intervalPatternMount.dataset.initialInterval : '';

13 14 15 16
  return new Vue({
    el: intervalPatternMount,
    components: {
      intervalPatternInput,
17
    },
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    render(createElement) {
      return createElement('interval-pattern-input', {
        props: {
          initialCronInterval,
        },
      });
    },
  });
}

document.addEventListener('DOMContentLoaded', () => {
  /* Most of the form is written in haml, but for fields with more complex behaviors,
   * you should mount individual Vue components here. If at some point components need
   * to share state, it may make sense to refactor the whole form to Vue */

  initIntervalPatternInput();

  // Initialize non-Vue JS components in the form
36 37

  const formElement = document.getElementById('new-pipeline-schedule-form');
38

39 40 41 42
  gl.timezoneDropdown = new TimezoneDropdown();
  gl.targetBranchDropdown = new TargetBranchDropdown();
  gl.pipelineScheduleFieldErrors = new gl.GlFieldErrors(formElement);
});