From a072c91cc0dc26e417c51f666e8547e08ef40942 Mon Sep 17 00:00:00 2001
From: Leonardo Bishop <me@leonardobishop.com>
Date: Tue, 12 Mar 2024 23:18:23 +0000
Subject: Add import from file system

---
 components/loader/LoaderFileSystemModal.vue | 81 +++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 components/loader/LoaderFileSystemModal.vue

(limited to 'components/loader/LoaderFileSystemModal.vue')

diff --git a/components/loader/LoaderFileSystemModal.vue b/components/loader/LoaderFileSystemModal.vue
new file mode 100644
index 0000000..27f4e12
--- /dev/null
+++ b/components/loader/LoaderFileSystemModal.vue
@@ -0,0 +1,81 @@
+<script setup lang="ts">
+const loader = useLoaderStore();
+const session = useSessionStore();
+
+const showModal = ref(false);
+
+const open = () => {
+  showModal.value = true;
+}
+
+const confirm = () => {
+  const categories = loader.getCategories();
+  const quests = loader.getQuests();
+  const items = loader.getItems();
+
+  session.setCategories(categories);
+  session.setQuests(quests);
+  session.setItems(items);
+
+  showModal.value = false;
+}
+
+const status = computed(() => loader.getFileSystemLoaderStatus());
+const questsCount = computed(() => loader.getQuests().length);
+const categoriesCount = computed(() => loader.getCategories().length);
+const itemsCount = computed(() => loader.getItems().length);
+const path = computed(() => loader.getPath());
+
+defineExpose({
+  open
+})
+</script>
+
+<template>
+  <Modal v-model="showModal">
+    <template v-slot:header>
+      <h2>Import from Filesystem</h2>
+    </template>
+
+    <div v-if="status === 'pending'">
+      <p>Select the Quests plugin data directory.</p>
+      <p>Waiting for selection...</p>
+    </div>
+
+    <div v-if="status === 'inactive'">
+      <p>The request was aborted.</p>
+    </div>
+
+    <div v-if="status === 'loaded'">
+      <p>Parsing files in directory <code>{{ path }}</code>...</p>
+    </div>
+
+    <div v-if="status === 'invalid'">
+      <p>You have selected an invalid directory.</p>
+    </div>
+
+    <div v-if="status === 'valid'">
+      <p>Successfully parsed directory <code>{{ path }}</code>.</p>
+      <ul>
+        <li>{{ categoriesCount }} categories loaded</li>
+        <li>{{ questsCount }} quests loaded</li>
+        <li>{{ itemsCount }} items loaded</li>
+      </ul>
+      <p>You are about to replace your current workspace. Are you sure you want to continue?</p>
+    </div>
+
+    <div id="controls" class="control-group">
+      <Button :icon="['fas', 'xmark']" :label="'Cancel'" @click="showModal = false"></Button>
+      <Button v-if="status === 'valid'" type="solid" :icon="['fas', 'check']" :label="'Confirm'"
+        @click="confirm"></Button>
+    </div>
+  </Modal>
+</template>
+
+<style scoped>
+#controls {
+  display: flex;
+  justify-content: flex-end;
+  margin-top: 1rem;
+}
+</style>
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

