Skip to content

Commit

Permalink
Modal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Aug 27, 2024
1 parent dcd2de4 commit 146cb67
Show file tree
Hide file tree
Showing 14 changed files with 1,331 additions and 5 deletions.
38 changes: 37 additions & 1 deletion src/modals/Modals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,79 @@
<!-- Placeholder -->
<div>
<EditAbility />
<DeleteAbility />
<EditCharacter />
<DeleteCharacter />
<EditCondition />
<DeleteCondition />
<EditEffect />
<DeleteEffect />
<EditEvent />
<DeleteEvent />
<EditItem />
<DeleteItem />
<EditPlayer />
<DeletePlayer />
<EditSkill />
<DeleteSkill />
<EditTemplate />
<DeleteTemplate />
<AddSkillToCharacter />
<AddItemToCharacter />
<AddConditionToCharacter />
<AddEventToCharacter />
</div>
</template>

<script>
import EditAbility from './ability/EditAbility.vue'
import DeleteAbility from './ability/DeleteAbility.vue'
import EditCharacter from './character/EditCharacter.vue'
import DeleteCharacter from './character/DeleteCharacter.vue'
import EditCondition from './condition/EditCondition.vue'
import DeleteCondition from './condition/DeleteCondition.vue'
import EditEffect from './effect/EditEffect.vue'
import DeleteEffect from './effect/DeleteEffect.vue'
import EditEvent from './event/EditEvent.vue'
import DeleteEvent from './event/DeleteEvent.vue'
import EditItem from './item/EditItem.vue'
import DeleteItem from './item/DeleteItem.vue'
import EditPlayer from './player/EditPlayer.vue'
import DeletePlayer from './player/DeletePlayer.vue'
import EditSkill from './skill/EditSkill.vue'
import DeleteSkill from './skill/DeleteSkill.vue'
import EditTemplate from './template/EditTemplate.vue'
import DeleteTemplate from './template/DeleteTemplate.vue'
import AddSkillToCharacter from './character/AddSkillToCharacter.vue'
import AddItemToCharacter from './character/AddItemToCharacter.vue'
import AddConditionToCharacter from './character/AddConditionToCharacter.vue'
import AddEventToCharacter from './character/AddEventToCharacter.vue'
export default {
name: 'Modals',
components: {
EditAbility,
DeleteAbility,
EditCharacter,
DeleteCharacter,
EditCondition,
DeleteCondition,
EditEffect,
DeleteEffect,
EditEvent,
DeleteEvent,
EditItem,
EditSkill,
DeleteItem,
EditPlayer,
DeletePlayer,
EditSkill,
DeleteSkill,
EditTemplate,
DeleteTemplate,
AddSkillToCharacter,
AddItemToCharacter,
AddConditionToCharacter,
AddEventToCharacter,
},
}
</script>
102 changes: 102 additions & 0 deletions src/modals/ability/DeleteAbility.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<script setup>
import { abilityStore, navigationStore } from '../../store/store.js'
</script>

<template>
<NcDialog v-if="navigationStore.dialog === 'deleteAbility'"
name="Vaardigheid verwijderen"
size="normal"
:can-close="false">

<p v-if="!success">
Wil je <b>{{ abilityStore.abilityItem.name }}</b> definitief verwijderen? Deze actie kan niet ongedaan worden gemaakt.
</p>

<NcNoteCard v-if="success" type="success">
<p>Vaardigheid succesvol verwijderd</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>

<template #actions>
<NcButton
@click="navigationStore.setDialog(false)">
<template #icon>
<Cancel :size="20" />
</template>
{{ success ? 'Sluiten' : 'Annuleer' }}
</NcButton>
<NcButton
v-if="!success"
:disabled="loading"
type="error"
@click="deleteAbility()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<TrashCanOutline v-if="!loading" :size="20" />
</template>
Verwijderen
</NcButton>
</template>
</NcDialog>

</template>

<script>
import {
NcButton,
NcDialog,
NcTextField,
NcTextArea,
NcSelect,
NcLoadingIcon,
NcNoteCard,
} from '@nextcloud/vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
export default {
name: 'DeleteAbility',
components: {
NcDialog,
NcTextField,
NcTextArea,
NcButton,
NcSelect,
NcLoadingIcon,
NcNoteCard,
// Icons
TrashCanOutline,
Cancel,
},
data() {
return {
success: false,
loading: false,
error: false,
}
},
methods: {
async deleteAbility() {
this.loading = true
try {
await abilityStore.deleteAbility()
// Close modal or show success message
this.success = true
this.loading = false
this.error = false
setTimeout(() => {
this.success = false
navigationStore.setDialog(false)
}, 2000)
} catch (error) {
this.loading = false
this.success = false
this.error = error.message || 'Er is een fout opgetreden bij het verwijderen van de vaardigheid'
}
}
},
}
</script>
116 changes: 116 additions & 0 deletions src/modals/character/AddConditionToCharacter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<script setup>
import { characterStore, conditionStore, navigationStore } from '../../store/store.js'
import { onMounted } from 'vue'
</script>

<template>
<NcDialog v-if="navigationStore.modal === 'addConditionToCharacter'"
name="Conditie toevoegen aan karakter"
size="normal"
:can-close="false">

<NcNoteCard v-if="success" type="success">
<p>Conditie succesvol toegevoegd aan karakter</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>

<div v-if="!success" class="formContainer">
<p>Let op: Het toevoegen van een conditie aan een karakter kan invloed hebben op de eigenschappen en vaardigheden van het karakter. Dit is een asynchroon proces, dus het kan even duren voordat de wijzigingen zichtbaar worden.</p>

<NcSelect
:disabled="loading"
label="Conditie *"
inputLabel="Conditie *"
:options="conditionStore.conditions"
:value.sync="selectedCondition"
option-label="name"
option-value="id"
required
/>
</div>

<template #actions>
<NcButton @click="navigationStore.setModal(false)">
<template #icon><Cancel :size="20" /></template>
{{ success ? 'Sluiten' : 'Annuleer' }}
</NcButton>
<NcButton @click="openLink('https://conduction.gitbook.io/opencatalogi-nextcloud/gebruikers/publicaties', '_blank')">
<template #icon><Help :size="20" /></template>
Help
</NcButton>
<NcButton v-if="!success" :disabled="loading" type="primary" @click="addConditionToCharacter()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<Plus v-if="!loading" :size="20" />
</template>
Toevoegen
</NcButton>
</template>
</NcDialog>
</template>

<script>
import {
NcButton,
NcDialog,
NcSelect,
NcLoadingIcon,
NcNoteCard,
} from '@nextcloud/vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import Help from 'vue-material-design-icons/Help.vue'
export default {
name: 'AddConditionToCharacter',
components: {
NcDialog,
NcButton,
NcSelect,
NcLoadingIcon,
NcNoteCard,
// Icons
Cancel,
Plus,
Help,
},
data() {
return {
success: false,
loading: false,
error: false,
selectedCondition: null,
}
},
mounted(){
conditionStore.refreshConditionList()
},
methods: {
async addConditionToCharacter() {
this.loading = true
try {
if (!characterStore.characterItem.conditions) {
characterStore.characterItem.conditions = []
}
characterStore.characterItem.conditions.push(this.selectedCondition)
await characterStore.saveCharacter()
this.success = true
this.loading = false
this.error = false
setTimeout(() => {
this.success = false
navigationStore.setModal(false)
}, 2000)
} catch (error) {
this.loading = false
this.success = false
this.error = error.message || 'Er is een fout opgetreden bij het toevoegen van de conditie aan het karakter'
}
}
},
}
</script>
Loading

0 comments on commit 146cb67

Please sign in to comment.