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

date_token.vue « tokens « filtered_search_bar « 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: 4446886dc889e8912b32e21931ba4c69de704643 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<script>
import { GlDatepicker, GlFilteredSearchToken } from '@gitlab/ui';
import { formatDate } from '~/lib/utils/datetime_utility';

export default {
  components: {
    GlDatepicker,
    GlFilteredSearchToken,
  },
  props: {
    active: {
      type: Boolean,
      required: true,
    },
    config: {
      type: Object,
      required: true,
    },
    value: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      selectedDate: null,
    };
  },
  methods: {
    selectValue(value) {
      this.selectedDate = formatDate(value, 'yyyy-mm-dd');
    },
    close(submitValue) {
      if (this.selectedDate == null) {
        return;
      }

      submitValue(this.selectedDate);
    },
    handle() {
      const listeners = { ...this.$listeners };
      // If we don't remove this, clicking the month/year in the datepicker will deactivate
      delete listeners.deactivate;
      return listeners;
    },
  },
  dataSegmentInputAttributes: {
    id: 'glfs-datepicker',
    placeholder: 'YYYY-MM-DD',
  },
};
</script>

<template>
  <gl-filtered-search-token
    :config="config"
    :value="value"
    :active="active"
    :data-segment-input-attributes="$options.dataSegmentInputAttributes"
    v-bind="{ ...$props, ...$attrs }"
    v-on="handle()"
  >
    <template #before-data-segment-input="{ submitValue }">
      <gl-datepicker
        class="gl-display-none!"
        target="#glfs-datepicker"
        :container="null"
        @input="selectValue($event)"
        @close="close(submitValue)"
      />
    </template>
  </gl-filtered-search-token>
</template>