aboutsummaryrefslogtreecommitdiffstats
path: root/components/editor/quest/modal/EditorQuestModalDuplicate.vue
blob: 73a2fd08d0977aaa756b2ffd6a6a5371ca84381d (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
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useSessionStore } from '@/stores/session';

const model = defineModel();

const emit = defineEmits(['duplicate']);

const props = defineProps({
  questId: String,
});

const session = useSessionStore();

const newQuestId = ref(props.questId);

const isDuplicate = computed(() => {
  return session.getQuestById(newQuestId.value!) !== undefined;
});

</script>

<template>
  <Modal v-model="model">
    <template v-slot:header>
      <h2>Duplicate '{{ questId }}'</h2>
    </template>

    <template v-slot:body>
      <div id="body">
        <div class="option-group">
          <label for="new-type">ID of new quest</label>
          <input id="new-type" name="new-type" type="text" v-model="newQuestId" />
        </div>
        <p v-if="isDuplicate" class="error-text">Name is not unique.</p>
        <p>A Quest ID must be unique, alphanumeric, and not contain any spaces.</p>
        <div id="confirm" class="control-group">
          <Button :icon="['fas', 'times']" :label="'Cancel'" @click="model = false"></Button>
          <Button type="solid" :icon="['fas', 'check']" :label="'Duplicate'" :disabled="isDuplicate"
            @click="emit('duplicate', newQuestId)"></Button>
        </div>
      </div>
    </template>
  </Modal>
</template>

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

#body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
</style>