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

init_listbox_inputs.js « listbox_input « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b447822b1e0da4bd20b38973bc65a0fa9c1708b7 (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 ListboxInput from '~/vue_shared/components/listbox_input/listbox_input.vue';
import { parseBoolean } from '~/lib/utils/common_utils';

export const initListboxInputs = () => {
  const els = [...document.querySelectorAll('.js-listbox-input')];

  els.forEach((el, index) => {
    const { label, description, name, defaultToggleText, value = null } = el.dataset;
    const { id } = el;
    const items = JSON.parse(el.dataset.items);

    return new Vue({
      el,
      name: `ListboxInputRoot${index + 1}`,
      data() {
        return {
          selected: value,
        };
      },
      render(createElement) {
        return createElement(ListboxInput, {
          on: {
            select: (newValue) => {
              this.selected = newValue;
            },
          },
          props: {
            label,
            description,
            name,
            defaultToggleText,
            selected: this.selected,
            block: parseBoolean(el.dataset.block),
            fluidWidth: parseBoolean(el.dataset.fluidWidth),
            items,
          },
          attrs: {
            id,
          },
        });
      },
    });
  });
};