summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notifications/components/notification_email_listbox_input.vue
blob: 5d5524deb0dfd7a3f40b4a73b4d84308a8942eed (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
46
<script>
import ListboxInput from '~/vue_shared/components/listbox_input/listbox_input.vue';

export default {
  components: {
    ListboxInput,
  },
  inject: ['label', 'name', 'emails', 'emptyValueText', 'value', 'disabled'],
  data() {
    return {
      selected: this.value,
    };
  },
  computed: {
    options() {
      return [
        {
          value: '',
          text: this.emptyValueText,
        },
        ...this.emails.map((email) => ({
          text: email,
          value: email,
        })),
      ];
    },
  },
  methods: {
    async onSelect() {
      await this.$nextTick();
      this.$el.closest('form').submit();
    },
  },
};
</script>

<template>
  <listbox-input
    v-model="selected"
    :label="label"
    :name="name"
    :items="options"
    :disabled="disabled"
    @select="onSelect"
  />
</template>