aboutsummaryrefslogtreecommitdiffstats
path: root/components/editor/quest/modal/EditorQuestModalYaml.vue
blob: 365055c90eb802f590a8520e13275de0f0f18306 (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
<script setup lang="ts">
import { stringify } from 'yaml';
import { mapJsonQuestToYamlObject } from '~/lib/questsLoader';

const emit = defineEmits(['delete']);
const props = defineProps({
  questId: {
    required: true,
    type: String
  },
});

const session = useSessionStore();

const showModal = ref(false);
const yamlString = ref('');

const open = () => {
  const quest = session.getQuestById(props.questId);
  if (!quest) {
    return
  }
  const mappedObject = mapJsonQuestToYamlObject(quest);
  yamlString.value = stringify(mappedObject);
  showModal.value = true;
}

defineExpose({
  open
})
</script>

<template>
  <Modal v-model="showModal">
    <template v-slot:header>
      <h2>YAML</h2>
    </template>

    <p>YAML file for <code>{{ props.questId }}</code></p>

    <textarea rows="20" :value="yamlString" readonly />

    <div id="confirm" class="control-group">
      <Button type="solid" :icon="['fas', 'check']" :label="'Close'" @click="showModal = false"></Button>
    </div>
  </Modal>
</template>

<style scoped>
#confirm {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

textarea {
  width: 100%;
}
</style>