Skip to content

Commit

Permalink
Merge pull request #80 from ConductionNL/feature/PC108-103/taken-afro…
Browse files Browse the repository at this point in the history
…nden

added handle task button
  • Loading branch information
RalkeyOfficial authored Dec 6, 2024
2 parents 1617fa7 + e4d29e5 commit a7e4628
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 18 deletions.
13 changes: 13 additions & 0 deletions src/services/icons/icon/icon-calendar-check-outline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getTheme } from '../../getTheme.js'

/**
* Returns the correct 'calendar-check-outline' icon based on the theme as a class name.
*
* this class name can be put into a component that accepts an 'icon' prop
* @return {string}
*/
export function iconCalendarCheckOutline() {
const theme = getTheme()

return theme === 'light' ? 'icon-calendar-check-outline-dark' : 'icon-calendar-check-outline-light'
}
8 changes: 8 additions & 0 deletions src/services/icons/icons.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/services/icons/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { iconProgressClose as _iconProgressClose } from './icon/icon-progress-close.js'
import { iconPencil as _iconPencil } from './icon/icon-pencil.js'
import { iconCalendarCheckOutline as _iconCalendarCheckOutline } from './icon/icon-calendar-check-outline.js'

export const iconProgressClose = _iconProgressClose()
export const iconPencil = _iconPencil()
export const iconCalendarCheckOutline = _iconCalendarCheckOutline()
16 changes: 8 additions & 8 deletions src/store/modules/taak.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ export const useTaakStore = defineStore('taken', {
async refreshTakenList(search = null, notClosed = false) {
let endpoint = apiEndpoint

if (search !== null && search !== '') {
endpoint = endpoint + '?_search=' + search
const params = new URLSearchParams()
if (search) {
params.append('_search', search)
}

if (notClosed) {
if (search !== null && search !== '') {
endpoint = endpoint + '&status=open'
} else {
endpoint = endpoint + '?status=open'
}
params.append('status', 'open')
}

if (params.toString()) {
endpoint += `?${params.toString()}`
}

const response = await fetch(endpoint, {
Expand Down
43 changes: 33 additions & 10 deletions src/views/widgets/TakenWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { taakStore, navigationStore } from '../../store/store.js'
:loading="loading"
:item-menu="itemMenu"
@show="onShow"
@sluiten="onSluiten">
@statusClose="onCloseStatus"
@statusHandled="onHandledStatus">
<template #empty-content>
<NcEmptyContent name="Geen open taken">
<template #icon>
Expand Down Expand Up @@ -51,6 +52,9 @@ import { getTheme } from '../../services/getTheme.js'
// Entities
import { Taak } from '../../entities/index.js'
// Icons
import { iconProgressClose, iconCalendarCheckOutline } from '../../services/icons/index.js'
import Plus from 'vue-material-design-icons/Plus.vue'
import Folder from 'vue-material-design-icons/Folder.vue'
import Refresh from 'vue-material-design-icons/Refresh.vue'
Expand All @@ -77,9 +81,13 @@ export default {
text: 'Bekijk',
icon: 'icon-toggle',
},
sluiten: {
statusClose: {
text: 'Sluiten',
icon: this.getSluitenIcon(),
icon: iconProgressClose,
},
statusHandled: {
text: 'Taak Afhandelen',
icon: iconCalendarCheckOutline,
},
},
}
Expand Down Expand Up @@ -138,13 +146,7 @@ export default {
this.isModalOpen = true
},
getSluitenIcon() {
const theme = getTheme()
return theme === 'light' ? 'icon-progress-close-dark' : 'icon-progress-close-light'
},
async onSluiten(event) {
async onCloseStatus(event) {
// change status to 'gesloten'
const { data } = await taakStore.getTaak(event.id)
Expand All @@ -158,6 +160,27 @@ export default {
status: 'gesloten',
})
taakStore.saveTaak(newTaak)
.then(({ response }) => {
if (response.ok) {
this.fetchTaakItems(null, true)
}
})
},
async onHandledStatus(event) {
// change status to 'afgerond'
const { data } = await taakStore.getTaak(event.id)
if (data?.status === 'afgerond') {
console.info('Taak is already handled')
return
}
const newTaak = new Taak({
...data,
status: 'afgerond',
})
taakStore.saveTaak(newTaak)
.then(({ response }) => {
if (response.ok) {
Expand Down

0 comments on commit a7e4628

Please sign in to comment.