From 9a11e0f4a38297006b89cc7bb2a60734111582e0 Mon Sep 17 00:00:00 2001
From: Leonardo Bishop <me@leonardobishop.com>
Date: Sun, 10 Mar 2024 00:13:25 +0000
Subject: Migrate to nuxt

---
 components/Editor/Quest/QuestTasksOptionsPanel.vue | 98 ++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 components/Editor/Quest/QuestTasksOptionsPanel.vue

(limited to 'components/Editor/Quest/QuestTasksOptionsPanel.vue')

diff --git a/components/Editor/Quest/QuestTasksOptionsPanel.vue b/components/Editor/Quest/QuestTasksOptionsPanel.vue
new file mode 100644
index 0000000..a79e636
--- /dev/null
+++ b/components/Editor/Quest/QuestTasksOptionsPanel.vue
@@ -0,0 +1,98 @@
+<script setup lang="ts">
+import { useSessionStore, type EditorQuest } from '@/stores/session';
+import { computed, ref } from 'vue';
+import EditorOptionsPanel from '@/components/Editor/EditorOptionsPanel.vue';
+import TaskConfiguration from '@/components/Editor/Quest/Task/TaskConfiguration.vue';
+import Button from '@/components/Control/Button.vue';
+import AddTaskModal from './Task/Modal/AddTaskModal.vue';
+
+const props = defineProps<{
+  questId: string;
+}>();
+
+const sessionStore = useSessionStore();
+
+const quest = computed(() => {
+  return sessionStore.getQuestById(props.questId) as EditorQuest;
+});
+
+const showAddTaskModal = ref(false);
+
+const addTask = (newId: string, newType: string) => {
+  sessionStore.getQuestById(props.questId)!.tasks[newId] = {
+    id: newId,
+    config: {
+      type: newType,
+    },
+  };
+  
+  showAddTaskModal.value = false;
+};
+</script>
+
+<template>
+  <EditorOptionsPanel v-if="quest">
+    <div id="options">
+      <h2>Tasks <code>({{ Object.keys(quest.tasks).length }})</code></h2>
+      
+      <p v-if="Object.keys(quest.tasks).length === 0" class="error-text">This quest does not have any tasks.</p>
+      <TaskConfiguration v-for="(task, taskId) in quest.tasks" :key="taskId" :taskId="String(taskId)" :quest="quest" />
+      
+      <div id="controls">
+        <Button
+          id="add-task"
+          :icon="['fas', 'fa-plus']"
+          type="solid"
+          label="Add task" 
+          @click="showAddTaskModal = true"
+          />
+      </div>
+    </div>
+  </EditorOptionsPanel>
+  
+  <AddTaskModal
+    v-if="quest"
+    v-model="showAddTaskModal"
+    :questId="questId"
+    @add="addTask"
+  />
+</template>
+
+
+<style scoped>
+#options {
+  display: flex;
+  flex-direction: column;
+  gap: 1rem;
+  
+  #controls {
+    display: flex;
+    justify-content: flex-end;
+    gap: 1rem;
+  }
+}
+
+.option-group {
+  display: flex;
+  flex-direction: column;
+  gap: 0.5rem;
+}
+
+.description {
+  font-size: 0.8em;
+}
+
+label {
+  font-weight: 700;
+}
+
+h2 {
+  border-bottom: 1px solid var(--color-border);
+  
+  code {
+    font-size: 0.8em;
+    color: var(--color-text-mute);
+  }
+}
+</style>
+
-- 
cgit v1.2.3-70-g09d2

