From 8664ad155c89d47affd94f8b0385ebf39841f1f8 Mon Sep 17 00:00:00 2001
From: Leonardo Bishop <me@leonardobishop.com>
Date: Tue, 12 Mar 2024 17:46:44 +0000
Subject: Add YAML modal

---
 components/editor/quest/modal/Yaml.vue | 59 ++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 components/editor/quest/modal/Yaml.vue

(limited to 'components/editor/quest/modal/Yaml.vue')

diff --git a/components/editor/quest/modal/Yaml.vue b/components/editor/quest/modal/Yaml.vue
new file mode 100644
index 0000000..365055c
--- /dev/null
+++ b/components/editor/quest/modal/Yaml.vue
@@ -0,0 +1,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>
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

