aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/theme/ThemeExport.vue
blob: 18d29e868441cffe2c75235d4d4cb4a1d815db38 (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
<template>
    <div class="theme-export">
      <button class="button" @click="exportTheme" :disabled="!theme">
        {{ $gettext('Exportieren') }}
      </button>
    </div>
  </template>
  
  <script setup>
  
  const props = defineProps({
    theme: {
      type: Object,
      required: true,
    },
  });
  
  const exportTheme = () => {
    const themeData = {
      name: props.theme.attributes.name,
      description: props.theme.attributes.description || '',
      author: props.theme.attributes.author || '',
      version: props.theme.attributes.version || '1.0',
      type: props.theme.attributes.type || 'light',
      values: props.theme.attributes.values || {},
      studip_min_version: props.theme.attributes.studip_min_version || '6.1',
      studip_max_version: props.theme.attributes.studip_max_version || '7.0',
    };
  
    const blob = new Blob([JSON.stringify(themeData, null, 2)], { type: 'application/json' });
    const link = document.createElement('a');
    link.href = URL.createObjectURL(blob);
    link.download = `${props.theme.attributes.name || 'theme'}.json`;
    link.click();
  };
  </script>
  
  <style scoped>
  .theme-export button {
    padding: 0.5rem 1rem;
    margin-top: 2rem;
  }
  </style>