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

page_size_selector.vue « 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: 5c097220d236c619c0a9420aaf9a57a4b562b009 (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
<script>
import { GlCollapsibleListbox } from '@gitlab/ui';
import { n__ } from '~/locale';

export const PAGE_SIZES = [20, 50, 100].map((value) => ({
  value,
  text: n__('SecurityReports|Show %d item', 'SecurityReports|Show %d items', value),
}));

export default {
  components: { GlCollapsibleListbox },
  props: {
    value: {
      type: Number,
      required: true,
    },
  },
  computed: {
    selectedItem() {
      return PAGE_SIZES.find(({ value }) => value === this.value);
    },
    toggleText() {
      return this.selectedItem.text;
    },
  },
  methods: {
    emitInput(pageSize) {
      this.$emit('input', pageSize);
    },
  },
  PAGE_SIZES,
};
</script>

<template>
  <gl-collapsible-listbox
    :toggle-text="toggleText"
    :items="$options.PAGE_SIZES"
    :selected="value"
    @select="emitInput($event)"
  />
</template>