Skip to content

Commit

Permalink
Merge pull request #84 from ConductionNL/feature/PC108-116/zaak-add-taak
Browse files Browse the repository at this point in the history
feature/PC108-116/zaak-add-taak
  • Loading branch information
RalkeyOfficial authored Dec 6, 2024
2 parents 3e3f615 + 7b52685 commit d727c28
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 32 deletions.
3 changes: 3 additions & 0 deletions src/modals/Modals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { navigationStore } from '../store/store.js'
<ViewZaakAuditTrail v-if="navigationStore.modal === 'viewZaakAuditTrail'" />
<WidgetZaakForm v-if="navigationStore.modal === 'widgetZaakForm'" />
<AddBerichtToZaak v-if="navigationStore.modal === 'addBerichtToZaak'" />
<AddTaakToZaak v-if="navigationStore.modal === 'addTaakToZaak'" />
<!-- ==== -->
<EditZaakType />
<EditKlant />
Expand Down Expand Up @@ -41,6 +42,7 @@ import ViewKlantRegister from './klantRegister/ViewKlantRegister.vue'
import DeleteContactMoment from './contactMomenten/DeleteContactMoment.vue'
import EditMedewerker from './medewerkers/EditMedewerker.vue'
import AddBerichtToZaak from './zaken/AddBerichtToZaak.vue'
import AddTaakToZaak from './zaken/AddTaakToZaak.vue'
export default {
name: 'Modals',
Expand All @@ -60,6 +62,7 @@ export default {
DeleteContactMoment,
EditMedewerker,
AddBerichtToZaak,
AddTaakToZaak,
},
}
</script>
1 change: 1 addition & 0 deletions src/modals/zaken/AddBerichtToZaak.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default {
}
},
mounted() {
this.zaakItem = zaakStore.zaakItem
this.fetchBerichtenData()
},
methods: {
Expand Down
150 changes: 150 additions & 0 deletions src/modals/zaken/AddTaakToZaak.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<script setup>
import { zaakStore, navigationStore, taakStore } from '../../store/store.js'
</script>

<template>
<NcModal ref="modalRef"
label-id="addTaakToZaak"
@close="closeModal">
<div class="modalContent">
<h2>Taak toevoegen aan {{ zaakStore.zaakItem.title }}</h2>

<div v-if="success !== null || error">
<NcNoteCard v-if="success" type="success">
<p>Taak succesvol toegevoegd aan zaak</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>
</div>

<div v-if="success === null" class="form-group">
<NcSelect v-bind="taken"
v-model="taken.value"
input-label="Taak"
:loading="takenLoading"
:disabled="loading"
required />
</div>

<NcButton v-if="success === null"
:disabled="!taken?.value || loading"
type="primary"
@click="addTaakToZaak">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<Plus v-if="!loading" :size="20" />
</template>
Toevoegen
</NcButton>
</div>
</NcModal>
</template>

<script>
import { NcButton, NcModal, NcLoadingIcon, NcNoteCard, NcSelect } from '@nextcloud/vue'
import { Taak } from '../../entities/index.js'
import _ from 'lodash'
import Plus from 'vue-material-design-icons/Plus.vue'
export default {
name: 'AddTaakToZaak',
components: {
NcModal,
NcButton,
NcLoadingIcon,
NcNoteCard,
NcSelect,
// Icons
Plus,
},
data() {
return {
takenLoading: false,
taken: [],
loading: false,
success: null,
error: false,
errorCode: '',
hasUpdated: false,
}
},
mounted() {
this.zaakItem = zaakStore.zaakItem
this.fetchTakenData()
},
methods: {
closeModal() {
navigationStore.setModal(false)
},
fetchTakenData() {
this.takenLoading = true
taakStore.refreshTakenList()
.then(({ data }) => {
this.taken = {
options: data
// zaak is stored on the taak itself as a singular id, indicating that only taken without a zaak can be used
.filter((taak) => !taak.zaak)
.map((taak) => ({
id: taak.id,
label: taak.title,
})),
}
})
.catch((err) => {
console.error(err)
})
.finally(() => {
this.takenLoading = false
})
},
addTaakToZaak() {
this.loading = true
this.error = false
const taakItem = taakStore.takenList.find((taak) => taak.id === this.taken.value.id)
if (!taakItem) {
this.error = 'something went majorly wrong'
this.loading = false
return
}
const taakItemCopy = _.cloneDeep(taakItem)
taakItemCopy.zaak = this.zaakItem.id
const newTaakItem = new Taak(taakItemCopy)
taakStore.saveTaak(newTaakItem)
.then(({ response }) => {
this.success = response.ok
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
self.success = null
self.closeModal()
}, 2000)
this.hasUpdated = false
})
.catch((err) => {
this.error = err
this.hasUpdated = false
})
.finally(() => {
this.loading = false
})
},
},
}
</script>

<style scoped>
.modalContent {
margin: var(--zaa-margin-50, 12px);
text-align: center;
}
</style>
64 changes: 35 additions & 29 deletions src/views/taken/ZaakTaken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { navigationStore, taakStore } from '../../store/store.js'

<template>
<div>
<div v-if="!loading">
<NcListItem v-for="(taak, i) in takenList.results"
<div v-if="filteredTakenList?.length">
<NcListItem v-for="(taak, i) in filteredTakenList"
:key="`${taak}${i}`"
:name="taak?.title"
:bold="true"
Expand All @@ -23,21 +23,33 @@ import { navigationStore, taakStore } from '../../store/store.js'
{{ taak?.onderwerp }}
</template>
<template #actions>
<NcActionButton @click="showEditTaakModal(taak)">
<NcActionButton @click="taakStore.setTaakItem(taak); navigationStore.setSelected('taken')">
<template #icon>
<Eye :size="20" />
</template>
Bekijken
</NcActionButton>
<!-- <NcActionButton @click="berichtStore.setBerichtItem(bericht); navigationStore.setModal('editBericht')">
<template #icon>
<Pencil :size="20" />
</template>
Bewerken
</NcActionButton> -->
<NcActionButton>
<template #icon>
<TrashCanOutline :size="20" />
</template>
Verwijderen van zaak
</NcActionButton>
</template>
</NcListItem>
</div>

<div v-if="!takenList?.results?.length && !loading">
<div v-if="!filteredTakenList?.length && !loading">
Geen taken gevonden.
</div>

<NcLoadingIcon v-if="loading"
<NcLoadingIcon v-if="!filteredTakenList?.length && loading"
class="loadingIcon"
:size="64"
appearance="dark"
Expand All @@ -50,7 +62,8 @@ import { NcListItem, NcActionButton, NcLoadingIcon } from '@nextcloud/vue'
// Icons
import CalendarMonthOutline from 'vue-material-design-icons/CalendarMonthOutline.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
import Eye from 'vue-material-design-icons/Eye.vue'
export default {
name: 'ZaakTaken',
Expand All @@ -70,43 +83,36 @@ export default {
return {
search: '',
loading: true,
takenList: [],
}
},
computed: {
filteredTakenList() {
return taakStore.takenList.filter((taak) => taak.zaak === this.zaakId)
},
},
watch: {
zaakId(newVal) {
this.fetchData(newVal)
this.fetchData()
},
},
mounted() {
this.fetchData(this.zaakId)
this.fetchData()
},
methods: {
showEditTaakModal(taak) {
taakStore.setTaakItem(taak)
navigationStore.setModal('editTaak')
},
fetchData(zaakId) {
fetchData() {
this.loading = true
fetch(
'/index.php/apps/zaakafhandelapp/api/taken',
{
method: 'GET',
},
)
.then((response) => {
response.json().then((data) => {
this.takenList = data
})
this.loading = false
})
.catch((err) => {
console.error(err)
taakStore.refreshTakenList()
.finally(() => {
this.loading = false
})
},
toggleTaak(taak) {
// TODO: toggle taak
if (taakStore.taakItem?.id === taak.id) {
taakStore.setTaakItem(null)
} else {
taakStore.setTaakItem(taak)
}
},
clearText() {
this.search = ''
Expand Down
6 changes: 5 additions & 1 deletion src/views/zaken/ZaakDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { navigationStore, zaakStore } from '../../store/store.js'
</template>
Rol toevoegen
</NcActionButton>
<NcActionButton @click="navigationStore.setModal('addTaak')">
<NcActionButton @click="navigationStore.setModal('addTaakToZaak')">
<template #icon>
<CalendarPlus :size="20" />
</template>
Expand Down Expand Up @@ -225,6 +225,7 @@ export default {
data() {
return {
// state
loading: true,
currentActiveZaak: null,
// data
auditTrails: [],
Expand All @@ -242,6 +243,9 @@ export default {
}
},
methods: {
fetchData() {
this.loading = true
},
fetchAuditTrails(id) {
fetch(`/index.php/apps/zaakafhandelapp/api/zaken/${id}/audit_trail`)
Expand Down
4 changes: 2 additions & 2 deletions src/views/zaken/ZakenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ import { navigationStore, zaakStore } from '../../store/store.js'
:key="`${zaak}${i}`"
:name="zaak?.identificatie"
:force-display-actions="true"
:active="zaakStore.zaakItem?.uuid === zaak?.uuid"
:active="zaakStore.zaakItem?.id === zaak?.id"
:details="'1h'"
:counter-number="44"
@click="zaakStore.setZaakItem(zaak)">
<template #icon>
<BriefcaseAccountOutline :class="zaakStore.zaakItem?.uuid === zaak?.uuid && 'selectedZaakIcon'"
<BriefcaseAccountOutline :class="zaakStore.zaakItem?.id === zaak?.id && 'selectedZaakIcon'"
disable-menu
:size="44" />
</template>
Expand Down

0 comments on commit d727c28

Please sign in to comment.