-
-
+
@@ -24,12 +25,13 @@ import { navigationStore, contactMomentStore, klantStore } from '../../store/sto
- Contact moment starten
+ Contactmoment starten
-
@@ -44,6 +46,7 @@ import { getTheme } from '../../services/getTheme.js'
import { ContactMoment } from '../../entities/index.js'
// Icons
+import { iconPencil, iconProgressClose } from '../../services/icons/index.js'
import Plus from 'vue-material-design-icons/Plus.vue'
import ChatOutline from 'vue-material-design-icons/ChatOutline.vue'
@@ -64,33 +67,34 @@ export default {
data() {
return {
loading: false,
- isModalOpen: false,
- searchKlantModalOpen: false,
+ /**
+ * determines if the contactmoment form modal is open
+ */
+ isContactMomentFormOpen: false,
contactMomentItems: [],
+ // contactmoment form props
contactMomentId: null,
+ isView: false,
+ // widget options
itemMenu: {
show: {
text: 'Bekijk',
icon: 'icon-toggle',
},
+ edit: {
+ text: 'Bewerk',
+ icon: iconPencil,
+ },
sluiten: {
text: 'Sluit',
- icon: this.getSluitenIcon(),
+ icon: iconProgressClose,
},
},
}
},
-
- computed: {
- items() {
- return this.contactMomentItems
- },
- },
-
mounted() {
this.fetchContactMomentItems()
},
-
methods: {
fetchContactMomentItems() {
this.loading = true
@@ -102,7 +106,7 @@ export default {
.then(([contactMomentResponse, klantResponse]) => {
this.contactMomentItems = contactMomentResponse.entities.map(contactMoment => ({
id: contactMoment.id,
- mainText: (() => { // this is a self calling function to get the klant name
+ mainText: (() => { // this is a self calling function to get the klant name, which is why you don't see it being called anywhere
const klant = klantResponse.entities.find(klant => klant.id === contactMoment.klant)
if (klant) {
const tussenvoegsel = klant.tussenvoegsel ? klant.tussenvoegsel + ' ' : ''
@@ -118,6 +122,7 @@ export default {
this.loading = false
})
},
+ // === ICONS ===
getItemIcon() {
const theme = getTheme()
@@ -129,33 +134,51 @@ export default {
return theme === 'light' ? `${appLocation}/zaakafhandelapp/img/chat-outline-dark.svg` : `${appLocation}/zaakafhandelapp/img/chat-outline.svg`
},
- getSluitenIcon() {
- const theme = getTheme()
-
- return theme === 'light' ? 'icon-progress-close-dark' : 'icon-progress-close-light'
- },
+ // === MODAL CONTROL ===
+ /**
+ * Opens the contactmoment form modal in create/add mode
+ */
openModal() {
- this.isModalOpen = true
+ this.isContactMomentFormOpen = true
this.contactMomentId = null
contactMomentStore.setContactMomentItem(null)
- navigationStore.setModal('contactMomentenForm')
},
+ /**
+ * runs when the contact form modal closes
+ */
closeModal() {
- this.isModalOpen = false
+ this.isContactMomentFormOpen = false
+ this.isView = false
navigationStore.setModal(null)
},
-
+ // === EVENTS ===
+ /**
+ * runs when the user clicks on the show button, and opens the contactmoment form modal in view mode
+ * @param {{id: number}} event - the contactmoment item received from the widget
+ */
onShow(event) {
this.contactMomentId = event.id
- this.isModalOpen = true
- navigationStore.setModal('contactMomentenForm')
+ this.isContactMomentFormOpen = true
+ this.isView = true
+ },
+ /**
+ * runs when the user clicks on the edit button, and opens the contactmoment form modal in edit mode
+ * @param {{id: number}} event - the contactmoment item received from the widget
+ */
+ onEdit(event) {
+ this.contactMomentId = event.id
+ this.isContactMomentFormOpen = true
+ this.isView = false
},
+ /**
+ * runs when the user clicks on the "sluiten" button, and changes the status of the contactmoment to 'gesloten'
+ * @param {{id: number}} event - the contactmoment item received from the widget
+ */
async onSluiten(event) {
- // change status to 'gesloten'
const { data } = await contactMomentStore.getContactMoment(event.id)
if (data?.status === 'gesloten') {
- console.info('Contact moment is already closed')
+ console.info('Contactmoment is already closed')
return
}
@@ -175,16 +198,6 @@ export default {
}
-