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

front_matter_controls.vue « components « static_site_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dad3907c3ffac2445ff3ec1d55a5e3f98e5d9d10 (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
<script>
import { GlForm, GlFormInput, GlFormGroup } from '@gitlab/ui';
import { humanize } from '~/lib/utils/text_utility';

export default {
  components: {
    GlForm,
    GlFormInput,
    GlFormGroup,
  },
  props: {
    settings: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      editableSettings: { ...this.settings },
    };
  },
  methods: {
    getId(type, key) {
      return `sse-front-matter-${type}-${key}`;
    },
    getIsSupported(val) {
      return ['string', 'number'].includes(typeof val);
    },
    getLabel(str) {
      return humanize(str);
    },
    onUpdate() {
      this.$emit('updateSettings', { ...this.editableSettings });
    },
  },
};
</script>
<template>
  <gl-form>
    <template v-for="(value, key) of editableSettings">
      <gl-form-group
        v-if="getIsSupported(value)"
        :id="getId('form-group', key)"
        :key="key"
        :label="getLabel(key)"
        :label-for="getId('control', key)"
      >
        <gl-form-input
          :id="getId('control', key)"
          v-model.lazy="editableSettings[key]"
          type="text"
          @input="onUpdate"
        />
      </gl-form-group>
    </template>
  </gl-form>
</template>