From 49edf9d013fdb253a0a886411d37f59791f32711 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 5 Jan 2026 21:38:52 +0000 Subject: [PATCH 1/3] Bump version to 0.1.136 [skip ci] --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 3ae896c..222a958 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,7 +22,7 @@ Submit a [bug report](https://github.com/OpenCatalogi/.github/issues/new/choose) Submit a [feature request](https://github.com/OpenCatalogi/.github/issues/new/choose). ]]> - 0.1.135 + 0.1.136 agpl organization Conduction From ab6cca91c89f13b526d03e6d70061ec4f90f7c78 Mon Sep 17 00:00:00 2001 From: Remko Date: Thu, 19 Feb 2026 11:41:49 +0100 Subject: [PATCH 2/3] update --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 3d64028..be5951a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,7 +22,7 @@ Submit a [bug report](https://github.com/OpenCatalogi/.github/issues/new/choose) Submit a [feature request](https://github.com/OpenCatalogi/.github/issues/new/choose). ]]> - 0.1.136 + 0.1.138 agpl organization Conduction From 6bac137af99916e8499a272f6cfe77ceaf237d01 Mon Sep 17 00:00:00 2001 From: Remko Date: Thu, 19 Feb 2026 11:46:57 +0100 Subject: [PATCH 3/3] lint --- src/components/AddContactpersoonModal.vue | 28 +- src/components/ContactpersonenList.vue | 424 +++++++++--------- src/components/GenericObjectTable.vue | 18 +- src/modals/OrganisationModal.vue | 46 +- .../object/ChangeOrganisatieStatusDialog.vue | 56 +-- src/store/modules/object.js | 104 ++--- src/views/organisaties/OrganisatieIndex.vue | 162 +++---- 7 files changed, 419 insertions(+), 419 deletions(-) diff --git a/src/components/AddContactpersoonModal.vue b/src/components/AddContactpersoonModal.vue index 6f24742..4fbb495 100644 --- a/src/components/AddContactpersoonModal.vue +++ b/src/components/AddContactpersoonModal.vue @@ -170,24 +170,24 @@ export default { }, } - // Save the new contactpersoon object. - const result = await objectStore.saveObject(newContactpersoonObject, { - register: contactpersoonConfig.register, - schema: contactpersoonConfig.schema, - }) + // Save the new contactpersoon object. + const result = await objectStore.saveObject(newContactpersoonObject, { + register: contactpersoonConfig.register, + schema: contactpersoonConfig.schema, + }) - showSuccess(this.t('softwarecatalog', 'Contactpersoon added successfully')) + showSuccess(this.t('softwarecatalog', 'Contactpersoon added successfully')) - // Emit event to parent component. - this.$emit('contactpersoon-added', result.data) + // Emit event to parent component. + this.$emit('contactpersoon-added', result.data) - // Close modal. - this.closeModal() + // Close modal. + this.closeModal() - // Signal that a contactpersoon was added so parent can refresh with current filters. - navigationStore.setTransferData({ - action: 'contactpersoonAdded', - }) + // Signal that a contactpersoon was added so parent can refresh with current filters. + navigationStore.setTransferData({ + action: 'contactpersoonAdded', + }) } catch (error) { console.error('Error adding contactpersoon:', error) diff --git a/src/components/ContactpersonenList.vue b/src/components/ContactpersonenList.vue index 20a8bb8..659872a 100644 --- a/src/components/ContactpersonenList.vue +++ b/src/components/ContactpersonenList.vue @@ -67,22 +67,22 @@ {{ t("softwarecatalog", "No User") }} - -
- - {{ formatGroupName(group) }} - -
- - - + +
+ + {{ formatGroupName(group) }} + +
+ - + @@ -786,53 +786,53 @@ export default { } }, - /** - * Update contactpersonen with bulk user info. - * @param {object} bulkUserInfo - User info object keyed by contactpersoon ID. - * @return {void} - */ - updateContactpersonenWithUserInfo(bulkUserInfo) { - if (!this.organisationData.contactpersonen) return + /** + * Update contactpersonen with bulk user info. + * @param {object} bulkUserInfo - User info object keyed by contactpersoon ID. + * @return {void} + */ + updateContactpersonenWithUserInfo(bulkUserInfo) { + if (!this.organisationData.contactpersonen) return - this.organisationData.contactpersonen.forEach((contactpersoon, index) => { - const contactpersoonId = contactpersoon.id || contactpersoon.uuid - const userInfo = bulkUserInfo[contactpersoonId] + this.organisationData.contactpersonen.forEach((contactpersoon, index) => { + const contactpersoonId = contactpersoon.id || contactpersoon.uuid + const userInfo = bulkUserInfo[contactpersoonId] - if (userInfo) { - console.info( - `Updating contactpersoon ${contactpersoonId} with user info:`, - userInfo, - ) + if (userInfo) { + console.info( + `Updating contactpersoon ${contactpersoonId} with user info:`, + userInfo, + ) - // Ensure user object exists. - if (!contactpersoon.user) { - contactpersoon.user = {} - } + // Ensure user object exists. + if (!contactpersoon.user) { + contactpersoon.user = {} + } - // Update user object. - contactpersoon.user.hasUser = userInfo.hasUser - contactpersoon.user.username = userInfo.username - contactpersoon.user.groups = userInfo.groups || [] - contactpersoon.user.disabled = !userInfo.enabled // Map enabled to disabled. - contactpersoon.user.displayName = userInfo.displayName - contactpersoon.user.lastLogin = userInfo.lastLogin - - // Update data object for consistency. - if (contactpersoon.data) { - contactpersoon.data.disabled = !userInfo.enabled // Map enabled to disabled. - contactpersoon.data.groups = userInfo.groups || [] // Also set groups in data. - contactpersoon.data.username = userInfo.username // Also set username in data. - } + // Update user object. + contactpersoon.user.hasUser = userInfo.hasUser + contactpersoon.user.username = userInfo.username + contactpersoon.user.groups = userInfo.groups || [] + contactpersoon.user.disabled = !userInfo.enabled // Map enabled to disabled. + contactpersoon.user.displayName = userInfo.displayName + contactpersoon.user.lastLogin = userInfo.lastLogin + + // Update data object for consistency. + if (contactpersoon.data) { + contactpersoon.data.disabled = !userInfo.enabled // Map enabled to disabled. + contactpersoon.data.groups = userInfo.groups || [] // Also set groups in data. + contactpersoon.data.username = userInfo.username // Also set username in data. + } - // Force reactivity update. - this.$set( - this.organisationData.contactpersonen, - index, - contactpersoon, - ) - } - }) - }, + // Force reactivity update. + this.$set( + this.organisationData.contactpersonen, + index, + contactpersoon, + ) + } + }) + }, /** * Refresh user statuses from Nextcloud for all contact persons @@ -853,55 +853,55 @@ export default { await this.loadUserInfoAndGroups() }, - /** - * Get contactperson name. - * @param {object} contactpersoon - The contact person object. - * @return {string} The contact person's name. - */ - getContactpersoonName(contactpersoon) { - const data = contactpersoon.data - return ( - data.naam + /** + * Get contactperson name. + * @param {object} contactpersoon - The contact person object. + * @return {string} The contact person's name. + */ + getContactpersoonName(contactpersoon) { + const data = contactpersoon.data + return ( + data.naam || data.name || data.voornaam + ' ' + data.achternaam || data.email || data['e-mailadres'] || 'Unknown' - ) - }, + ) + }, - /** - * Filter groups to only show those available in the modal. - * @param {object} contactpersoon - The contact person object. - * @return {Array} Filtered array of group IDs. - */ - getFilteredGroups(contactpersoon) { - if (!contactpersoon.user.groups || contactpersoon.user.groups.length === 0) { - return [] - } - - // Get list of available group IDs from the store. - const availableGroupIds = this.availableGroups.map(g => g.id) - - // Filter user groups to only include those in availableGroups. - return contactpersoon.user.groups.filter(groupId => - availableGroupIds.includes(groupId) - ) - }, + /** + * Filter groups to only show those available in the modal. + * @param {object} contactpersoon - The contact person object. + * @return {Array} Filtered array of group IDs. + */ + getFilteredGroups(contactpersoon) { + if (!contactpersoon.user.groups || contactpersoon.user.groups.length === 0) { + return [] + } - /** - * Format group name. - * @param {string} groupId - The group ID. - * @return {string} Formatted group name. - */ - formatGroupName(groupId) { - const groupMap = { - 'gebruik-beheerder': 'Gebruik Beheerder', - 'aanbod-beheerder': 'Aanbod Beheerder', - 'gebruik-raadpleger': 'Gebruik Raadpleger', - } - return groupMap[groupId] || groupId - }, + // Get list of available group IDs from the store. + const availableGroupIds = this.availableGroups.map(g => g.id) + + // Filter user groups to only include those in availableGroups. + return contactpersoon.user.groups.filter(groupId => + availableGroupIds.includes(groupId), + ) + }, + + /** + * Format group name. + * @param {string} groupId - The group ID. + * @return {string} Formatted group name. + */ + formatGroupName(groupId) { + const groupMap = { + 'gebruik-beheerder': 'Gebruik Beheerder', + 'aanbod-beheerder': 'Aanbod Beheerder', + 'gebruik-raadpleger': 'Gebruik Raadpleger', + } + return groupMap[groupId] || groupId + }, async convertToUser(contactpersoon) { console.info('convertToUser called with:', contactpersoon) @@ -1079,32 +1079,32 @@ export default { } }, - /** - * Open groups management dialog. - * @param {object} contactpersoon - The contact person object. - * @return {Promise} - */ - async openGroupsDialog(contactpersoon) { - this.selectedContactpersoon = contactpersoon - this.showGroupsDialog = true + /** + * Open groups management dialog. + * @param {object} contactpersoon - The contact person object. + * @return {Promise} + */ + async openGroupsDialog(contactpersoon) { + this.selectedContactpersoon = contactpersoon + this.showGroupsDialog = true - try { + try { // Fetch user-specific info to get current groups and available groups. - const userInfo = await this.organisatieStore.fetchUserInfo( - contactpersoon.id, - ) - this.selectedGroups = [...(userInfo.groups || [])] - - // Update the local contactpersoon data with the fresh groups info. - // This ensures the table shows the correct groups. - this.updateContactpersoonGroups(contactpersoon.id, userInfo.groups || []) - } catch (error) { - console.error('Error fetching user info for groups dialog:', error) - // Fallback to existing groups. - this.selectedGroups = [...contactpersoon.user.groups] + const userInfo = await this.organisatieStore.fetchUserInfo( + contactpersoon.id, + ) + this.selectedGroups = [...(userInfo.groups || [])] + + // Update the local contactpersoon data with the fresh groups info. + // This ensures the table shows the correct groups. + this.updateContactpersoonGroups(contactpersoon.id, userInfo.groups || []) + } catch (error) { + console.error('Error fetching user info for groups dialog:', error) + // Fallback to existing groups. + this.selectedGroups = [...contactpersoon.user.groups] // Note: Available groups should already be loaded from loadUserInfoAndGroups(). - } - }, + } + }, closeGroupsDialog() { this.showGroupsDialog = false @@ -1126,38 +1126,38 @@ export default { } }, - /** - * Save user groups. - * @return {Promise} - */ - async saveGroups() { - if (!this.selectedContactpersoon) return + /** + * Save user groups. + * @return {Promise} + */ + async saveGroups() { + if (!this.selectedContactpersoon) return - this.groupsLoading = true + this.groupsLoading = true - try { - await this.organisatieStore.updateUserGroups( - this.selectedContactpersoon.user.username, - this.selectedGroups, - ) - - // Update the local contactpersoon data to reflect the new groups. - this.updateContactpersoonGroups(this.selectedContactpersoon.id, this.selectedGroups) - - showSuccess( - this.t('softwarecatalog', 'User groups updated successfully'), - ) - this.closeGroupsDialog() - } catch (error) { - showError( - this.t('softwarecatalog', 'Failed to update user groups: {error}', { - error: error.message, - }), - ) - } finally { - this.groupsLoading = false - } - }, + try { + await this.organisatieStore.updateUserGroups( + this.selectedContactpersoon.user.username, + this.selectedGroups, + ) + + // Update the local contactpersoon data to reflect the new groups. + this.updateContactpersoonGroups(this.selectedContactpersoon.id, this.selectedGroups) + + showSuccess( + this.t('softwarecatalog', 'User groups updated successfully'), + ) + this.closeGroupsDialog() + } catch (error) { + showError( + this.t('softwarecatalog', 'Failed to update user groups: {error}', { + error: error.message, + }), + ) + } finally { + this.groupsLoading = false + } + }, /** * Disable a user account @@ -1199,81 +1199,81 @@ export default { } }, - /** - * Update the disabled status of a contactpersoon in the local data. - * @param {string} contactpersoonId - The ID of the contact person. - * @param {boolean} disabled - Whether the user is disabled. - * @return {void} - */ - updateContactpersoonStatus(contactpersoonId, disabled) { + /** + * Update the disabled status of a contactpersoon in the local data. + * @param {string} contactpersoonId - The ID of the contact person. + * @param {boolean} disabled - Whether the user is disabled. + * @return {void} + */ + updateContactpersoonStatus(contactpersoonId, disabled) { // Find and update the contactpersoon in the organisation data. - if (this.organisationData.contactpersonen) { - const contactIndex = this.organisationData.contactpersonen.findIndex( - (cp) => (cp.id || cp.uuid) === contactpersoonId, - ) + if (this.organisationData.contactpersonen) { + const contactIndex = this.organisationData.contactpersonen.findIndex( + (cp) => (cp.id || cp.uuid) === contactpersoonId, + ) - if (contactIndex !== -1) { + if (contactIndex !== -1) { // Update the disabled status in both user and data objects. - const contactpersoon + const contactpersoon = this.organisationData.contactpersonen[contactIndex] - // Update in the user object (primary source). - if (contactpersoon.user) { - contactpersoon.user.disabled = disabled - } + // Update in the user object (primary source). + if (contactpersoon.user) { + contactpersoon.user.disabled = disabled + } - // Also update in data object for consistency. - if (contactpersoon.data) { - contactpersoon.data.disabled = disabled - } + // Also update in data object for consistency. + if (contactpersoon.data) { + contactpersoon.data.disabled = disabled + } - // Force reactivity update. - this.$set( - this.organisationData.contactpersonen, - contactIndex, - contactpersoon, - ) + // Force reactivity update. + this.$set( + this.organisationData.contactpersonen, + contactIndex, + contactpersoon, + ) + } } - } - }, - - /** - * Update the groups of a contactpersoon in the local data. - * @param {string} contactpersoonId - The ID of the contact person. - * @param {Array} groups - Array of group IDs. - * @return {void} - */ - updateContactpersoonGroups(contactpersoonId, groups) { + }, + + /** + * Update the groups of a contactpersoon in the local data. + * @param {string} contactpersoonId - The ID of the contact person. + * @param {Array} groups - Array of group IDs. + * @return {void} + */ + updateContactpersoonGroups(contactpersoonId, groups) { // Find and update the contactpersoon in the organisation data. - if (this.organisationData.contactpersonen) { - const contactIndex = this.organisationData.contactpersonen.findIndex( - (cp) => (cp.id || cp.uuid) === contactpersoonId, - ) + if (this.organisationData.contactpersonen) { + const contactIndex = this.organisationData.contactpersonen.findIndex( + (cp) => (cp.id || cp.uuid) === contactpersoonId, + ) - if (contactIndex !== -1) { + if (contactIndex !== -1) { // Update the groups in both user and data objects. - const contactpersoon = this.organisationData.contactpersonen[contactIndex] + const contactpersoon = this.organisationData.contactpersonen[contactIndex] - // Update in the user object (primary source). - if (contactpersoon.user) { - contactpersoon.user.groups = [...groups] - } + // Update in the user object (primary source). + if (contactpersoon.user) { + contactpersoon.user.groups = [...groups] + } - // Also update in data object for consistency. - if (contactpersoon.data) { - contactpersoon.data.groups = [...groups] - } + // Also update in data object for consistency. + if (contactpersoon.data) { + contactpersoon.data.groups = [...groups] + } - // Force reactivity update. - this.$set( - this.organisationData.contactpersonen, - contactIndex, - contactpersoon, - ) + // Force reactivity update. + this.$set( + this.organisationData.contactpersonen, + contactIndex, + contactpersoon, + ) + } } - } + }, }, -}, } diff --git a/src/components/GenericObjectTable.vue b/src/components/GenericObjectTable.vue index 371f499..a72e9bf 100644 --- a/src/components/GenericObjectTable.vue +++ b/src/components/GenericObjectTable.vue @@ -425,15 +425,15 @@ import { objectStore, navigationStore } from '../store/store.js' - - + + diff --git a/src/modals/OrganisationModal.vue b/src/modals/OrganisationModal.vue index d2f6606..278436e 100644 --- a/src/modals/OrganisationModal.vue +++ b/src/modals/OrganisationModal.vue @@ -332,34 +332,34 @@ export default { return } - // Update existing organisation using PATCH - only send changed properties - await objectStore.patchObject('organisatie', this.organisation.id, changes) - this.successMessage = this.t('softwarecatalog', 'Organisation updated successfully') - - // Signal that an organization was updated so parent can refresh with current filters. - navigationStore.setTransferData({ - action: 'organisationUpdated', - organisationId: this.organisation.id, - }) - } else { + // Update existing organisation using PATCH - only send changed properties + await objectStore.patchObject('organisatie', this.organisation.id, changes) + this.successMessage = this.t('softwarecatalog', 'Organisation updated successfully') + + // Signal that an organization was updated so parent can refresh with current filters. + navigationStore.setTransferData({ + action: 'organisationUpdated', + organisationId: this.organisation.id, + }) + } else { // Create new organisation (both create and copy modes) - await objectStore.saveObject(this.formData, { + await objectStore.saveObject(this.formData, { register: schemaConfig.register, schema: schemaConfig.schema, - }) - this.successMessage = this.t('softwarecatalog', 'Organisation created successfully') - - // Signal that a new organization was created so parent can refresh. - navigationStore.setTransferData({ - action: 'organisationCreated', - }) - } + }) + this.successMessage = this.t('softwarecatalog', 'Organisation created successfully') + + // Signal that a new organization was created so parent can refresh. + navigationStore.setTransferData({ + action: 'organisationCreated', + }) + } - // Show success state - this.success = true + // Show success state + this.success = true - // NOTE: We don't fetch here anymore. Instead, we use transferData to signal the parent component - // (OrganisatieIndex) so it can refresh with the current search/filter parameters preserved. + // NOTE: We don't fetch here anymore. Instead, we use transferData to signal the parent component + // (OrganisatieIndex) so it can refresh with the current search/filter parameters preserved. // Start countdown timer this.countdown = 3 diff --git a/src/modals/object/ChangeOrganisatieStatusDialog.vue b/src/modals/object/ChangeOrganisatieStatusDialog.vue index c5e8ae7..563b55a 100644 --- a/src/modals/object/ChangeOrganisatieStatusDialog.vue +++ b/src/modals/object/ChangeOrganisatieStatusDialog.vue @@ -127,40 +127,40 @@ export default { throw new Error('Organisatie of nieuwe status ontbreekt') } - // Prepare the patch data - only include the status property. - const patchData = { - status: newStatus, - } + // Prepare the patch data - only include the status property. + const patchData = { + status: newStatus, + } - console.info('Changing organisation status:', { - organisatieId: organisatie.id, - currentStatus: organisatie.status, - newStatus: newStatus, - }) + console.info('Changing organisation status:', { + organisatieId: organisatie.id, + currentStatus: organisatie.status, + newStatus, + }) - // Update only the status using PATCH. - await objectStore.patchObject('organisatie', organisatie.id, patchData) + // Update only the status using PATCH. + await objectStore.patchObject('organisatie', organisatie.id, patchData) this.success = true - // If activating an organisation, store it for search filtering. - if (newStatus === 'Actief') { - const organisatieNaam = organisatie?.naam || organisatie?.name || organisatie?.['@self']?.name - - // Store the activated organisation info in navigationStore transferData. - navigationStore.setTransferData({ - action: 'organisationActivated', - organisationName: organisatieNaam, - status: 'Actief', - }) - } - // For deactivation, don't fetch - the organisation will just disappear from - // the current view if the user has an active filter, which is the expected behavior. + // If activating an organisation, store it for search filtering. + if (newStatus === 'Actief') { + const organisatieNaam = organisatie?.naam || organisatie?.name || organisatie?.['@self']?.name + + // Store the activated organisation info in navigationStore transferData. + navigationStore.setTransferData({ + action: 'organisationActivated', + organisationName: organisatieNaam, + status: 'Actief', + }) + } + // For deactivation, don't fetch - the organisation will just disappear from + // the current view if the user has an active filter, which is the expected behavior. - // Auto-close after 2 seconds on success. - setTimeout(() => { - this.closeDialog() - }, 2000) + // Auto-close after 2 seconds on success. + setTimeout(() => { + this.closeDialog() + }, 2000) } catch (error) { console.error('Error changing organisation status:', error) diff --git a/src/store/modules/object.js b/src/store/modules/object.js index 565cd35..6a428aa 100644 --- a/src/store/modules/object.js +++ b/src/store/modules/object.js @@ -775,20 +775,20 @@ export const useObjectStore = defineStore('object', { } } - // Add pagination and other query parameters - const queryParams = new URLSearchParams({ - _limit: params._limit || 20, - _page: params._page || 1, - ...params, - }) - - // Handle _extend parameter - convert comma-separated string to multiple _extend[] parameters - // Skip _extend for sub-resources (audit-trails, files) as they don't need schema data - // For organizations, only extend contactpersonen (not @self.schema) - const isSubResource = action && ['logs', 'audit-trails', 'files', 'publish', 'depublish', 'unlock', 'lock', 'revert'].includes(action) - const defaultExtend = isSubResource ? null : (type === 'organisatie' ? 'contactpersonen' : '@self.schema') - const extendValue = params._extend || params.extend || defaultExtend - if (extendValue) { + // Add pagination and other query parameters + const queryParams = new URLSearchParams({ + _limit: params._limit || 20, + _page: params._page || 1, + ...params, + }) + + // Handle _extend parameter - convert comma-separated string to multiple _extend[] parameters + // Skip _extend for sub-resources (audit-trails, files) as they don't need schema data + // For organizations, only extend contactpersonen (not @self.schema) + const isSubResource = action && ['logs', 'audit-trails', 'files', 'publish', 'depublish', 'unlock', 'lock', 'revert'].includes(action) + const defaultExtend = isSubResource ? null : (type === 'organisatie' ? 'contactpersonen' : '@self.schema') + const extendValue = params._extend || params.extend || defaultExtend + if (extendValue) { // Split comma-separated extends into individual parameters const extendParts = extendValue.split(',').map(part => part.trim()) extendParts.forEach(part => { @@ -825,42 +825,42 @@ export const useObjectStore = defineStore('object', { await this.fetchSettings() } - // Add _extend parameter if not explicitly set - // For organizations, only extend contactpersonen (not @self.schema) - const queryParams = { - ...params, - _extend: params._extend || params.extend || (type === 'organisatie' ? 'contactpersonen' : '@self.schema'), - } + // Add _extend parameter if not explicitly set + // For organizations, only extend contactpersonen (not @self.schema) + const queryParams = { + ...params, + _extend: params._extend || params.extend || (type === 'organisatie' ? 'contactpersonen' : '@self.schema'), + } - // Log the final URL for debugging - const apiUrl = this._constructApiUrl(type, null, null, queryParams) - console.info('fetchCollection API URL:', apiUrl) + // Log the final URL for debugging + const apiUrl = this._constructApiUrl(type, null, null, queryParams) + console.info('fetchCollection API URL:', apiUrl) const response = await fetch(apiUrl) if (!response.ok) throw new Error(`Failed to fetch ${type} collection`) - const data = await response.json() - console.info('API Response:', data) - console.info('API Response Pagination:', { - total: data.total, - page: data.page, - pages: data.pages, - limit: data.limit, - resultsLength: data.results?.length, - }) + const data = await response.json() + console.info('API Response:', data) + console.info('API Response Pagination:', { + total: data.total, + page: data.page, + pages: data.pages, + limit: data.limit, + resultsLength: data.results?.length, + }) - // Update pagination info - handle both pagination formats - const paginationInfo = { - total: data.total || 0, - page: data.page || 1, - pages: data.pages || Math.ceil((data.total || 0) / (data.limit || 20)), - limit: data.limit || 20, - next: data.next || null, - prev: data.prev || null, - } + // Update pagination info - handle both pagination formats + const paginationInfo = { + total: data.total || 0, + page: data.page || 1, + pages: data.pages || Math.ceil((data.total || 0) / (data.limit || 20)), + limit: data.limit || 20, + next: data.next || null, + prev: data.prev || null, + } - console.info('Setting pagination for type:', type, paginationInfo) - this.setPagination(type, paginationInfo) + console.info('Setting pagination for type:', type, paginationInfo) + this.setPagination(type, paginationInfo) // Set the collection using the new method this.setCollection(type, data.results, append) @@ -898,16 +898,16 @@ export const useObjectStore = defineStore('object', { await this.fetchSettings() } - // Add _extend parameter if not explicitly set - // For organizations, only extend contactpersonen (not @self.schema) - const queryParams = { - ...params, - _extend: params._extend || params.extend || (type === 'organisatie' ? 'contactpersonen' : '@self.schema'), - } + // Add _extend parameter if not explicitly set + // For organizations, only extend contactpersonen (not @self.schema) + const queryParams = { + ...params, + _extend: params._extend || params.extend || (type === 'organisatie' ? 'contactpersonen' : '@self.schema'), + } - // Log the final URL for debugging - const apiUrl = this._constructApiUrl(type, id, null, queryParams) - console.info('fetchObject API URL:', apiUrl) + // Log the final URL for debugging + const apiUrl = this._constructApiUrl(type, id, null, queryParams) + console.info('fetchObject API URL:', apiUrl) const response = await fetch(apiUrl) if (!response.ok) throw new Error(`Failed to fetch ${type} object`) diff --git a/src/views/organisaties/OrganisatieIndex.vue b/src/views/organisaties/OrganisatieIndex.vue index 2dd7cfd..cc687e1 100644 --- a/src/views/organisaties/OrganisatieIndex.vue +++ b/src/views/organisaties/OrganisatieIndex.vue @@ -235,19 +235,19 @@ export default { }, }, ], - organisatieMassActions: [ - { - id: 'massDelete', - label: 'Delete Selected', - icon: Delete, - handler: () => { - navigationStore.setDialog('massDeleteObjects', { - objectType: 'organisatie', - dialogTitle: 'Organisaties', - }) + organisatieMassActions: [ + { + id: 'massDelete', + label: 'Delete Selected', + icon: Delete, + handler: () => { + navigationStore.setDialog('massDeleteObjects', { + objectType: 'organisatie', + dialogTitle: 'Organisaties', + }) + }, }, - }, - ], + ], organisatieActions: [ { id: 'add', @@ -342,21 +342,21 @@ export default { if (!state.transferData) { return } - + // Check if transferData was set with an organisation activation. if (state.transferData.action === 'organisationActivated') { const organisationName = state.transferData.organisationName - + // Clear the transfer data FIRST to prevent retriggering. navigationStore.setTransferData(null) - + // Set search query to the organisation name. this.searchQuery = organisationName || '' - + // Set status filter in currentFilters (for the fetch logic). // This must be done BEFORE calling setFilter so onFilterChange has the correct value. this.currentFilters.status = 'Actief' - + // Update the GenericObjectTable filter UI by calling setFilter directly. // This will trigger the onChange callback which calls fetchOrganisatiesWithFilters(). // So we don't need to call it manually here. @@ -366,25 +366,25 @@ export default { // If ref not available yet, fetch manually. this.fetchOrganisatiesWithFilters() } - + // Update URL to reflect the new state. this.updateUrl() } - + // Handle organisation update - refresh with current filters preserved. if (state.transferData.action === 'organisationUpdated' || state.transferData.action === 'organisationCreated') { // Clear the transfer data. navigationStore.setTransferData(null) - + // Refresh with current search and filters to show the updated/new organisation. this.fetchOrganisatiesWithFilters() } - + // Handle contactpersoon added - refresh with current filters preserved. if (state.transferData.action === 'contactpersoonAdded') { // Clear the transfer data. navigationStore.setTransferData(null) - + // Refresh with current search and filters to show the updated organisation. this.fetchOrganisatiesWithFilters() } @@ -404,17 +404,17 @@ export default { const params = new URLSearchParams(hash) - // Restore search query. - if (params.has('search')) { - this.searchQuery = params.get('search') - console.info('Search query restored from URL:', this.searchQuery) - } + // Restore search query. + if (params.has('search')) { + this.searchQuery = params.get('search') + console.info('Search query restored from URL:', this.searchQuery) + } // Restore filters. if (params.has('status')) { const statusValue = params.get('status') this.currentFilters.status = statusValue - + // Also update the GenericObjectTable filter UI if ref is available. this.$nextTick(() => { if (this.$refs.organisatieTable && statusValue !== 'all') { @@ -425,7 +425,7 @@ export default { if (params.has('type')) { const typeValue = params.get('type') this.currentFilters.type = typeValue - + // Also update the GenericObjectTable filter UI if ref is available. this.$nextTick(() => { if (this.$refs.organisatieTable && typeValue !== 'all') { @@ -499,16 +499,16 @@ export default { const hash = window.location.hash.substring(1) const params = new URLSearchParams(hash) const page = params.has('page') ? parseInt(params.get('page'), 10) : 1 - const limit = 20 + const limit = 20 - // IMPORTANT: Initialize URL parameters FIRST before fetching. - // This ensures search queries and filters from deep links are applied. - this.initializeFromUrl() + // IMPORTANT: Initialize URL parameters FIRST before fetching. + // This ensures search queries and filters from deep links are applied. + this.initializeFromUrl() - // Fetch organisaties collection with contactpersonen extended and URL parameters. - // At this point, this.searchQuery should already be set from initializeFromUrl(). - console.info('Fetching organisaties with page:', page, 'search:', this.searchQuery) - await this.fetchOrganisatiesWithFilters(page, limit) + // Fetch organisaties collection with contactpersonen extended and URL parameters. + // At this point, this.searchQuery should already be set from initializeFromUrl(). + console.info('Fetching organisaties with page:', page, 'search:', this.searchQuery) + await this.fetchOrganisatiesWithFilters(page, limit) } catch (error) { console.error('Error initializing OrganisatieIndex:', error) // Show error to user if needed @@ -571,58 +571,58 @@ export default { this.updateUrl() }, - /** - * Handle filter changes and refetch data. - * @param {string} filterKey - The filter key (status or type). - * @param {string} filterValue - The new filter value. - * @return {Promise} - */ - async onFilterChange(filterKey, filterValue) { + /** + * Handle filter changes and refetch data. + * @param {string} filterKey - The filter key (status or type). + * @param {string} filterValue - The new filter value. + * @return {Promise} + */ + async onFilterChange(filterKey, filterValue) { // Update the current filter. - this.currentFilters[filterKey] = filterValue + this.currentFilters[filterKey] = filterValue - // Reset to first page when filters change. - await this.fetchOrganisatiesWithFilters() + // Reset to first page when filters change. + await this.fetchOrganisatiesWithFilters() - // Update URL to reflect filter change. - this.updateUrl() - }, + // Update URL to reflect filter change. + this.updateUrl() + }, - /** - * Fetch organisaties with current filters and search. - * @param {number} page - The page number to fetch (defaults to 1). - * @param {number} limit - The page size (defaults to 20). - * @return {Promise} - */ - async fetchOrganisatiesWithFilters(page = 1, limit = 20) { - try { - const searchParams = { - _extend: '@self.schema,contactpersonen', - _page: page, - _limit: limit, - } + /** + * Fetch organisaties with current filters and search. + * @param {number} page - The page number to fetch (defaults to 1). + * @param {number} limit - The page size (defaults to 20). + * @return {Promise} + */ + async fetchOrganisatiesWithFilters(page = 1, limit = 20) { + try { + const searchParams = { + _extend: '@self.schema,contactpersonen', + _page: page, + _limit: limit, + } - // Add search query if present. - if (this.searchQuery.trim()) { - searchParams._search = this.searchQuery.trim() - } + // Add search query if present. + if (this.searchQuery.trim()) { + searchParams._search = this.searchQuery.trim() + } - // Add status filter if not 'all'. - if (this.currentFilters.status !== 'all') { - searchParams.status = this.currentFilters.status - } + // Add status filter if not 'all'. + if (this.currentFilters.status !== 'all') { + searchParams.status = this.currentFilters.status + } - // Add type filter if not 'all'. - if (this.currentFilters.type !== 'all') { - searchParams.type = this.currentFilters.type - } + // Add type filter if not 'all'. + if (this.currentFilters.type !== 'all') { + searchParams.type = this.currentFilters.type + } - // Fetch organisaties with all parameters. - await objectStore.fetchCollection('organisatie', searchParams) - } catch (error) { - console.error('Error fetching organisaties with filters:', error) - } - }, + // Fetch organisaties with all parameters. + await objectStore.fetchCollection('organisatie', searchParams) + } catch (error) { + console.error('Error fetching organisaties with filters:', error) + } + }, /** * Handle pagination changes - preserves search and filters