Files
baserow/web-frontend/modules/database/mixins/collaboratorField.js
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

51 lines
1.5 KiB
JavaScript

import selectDropdown from '@baserow/modules/database/mixins/selectDropdown'
import availableCollaborators from '@baserow/modules/database/mixins/availableCollaborators'
export default {
mixins: [selectDropdown, availableCollaborators],
emits: ['update'],
methods: {
/**
* Removes the provided ID from the current values list and emits an update
* event with the new values list.
*/
removeValue(event, currentValues, itemIdToRemove) {
const vals = currentValues.filter((item) => item.id !== itemIdToRemove)
this.$emit('update', vals, currentValues)
},
/**
* Checks if the new value is valid for the field and if
* so will add it to a new values list. If this new list of values is unequal
* to the old list of values an update event will be emitted which will result
* in an API call in order to persist the new value to the field.
*/
updateValue(newId, oldValue) {
if (!oldValue) {
oldValue = []
}
const workspaceUser =
this.workspaceCollaborators.find(
(workspaceUser) => workspaceUser.id === newId
) || null
let newOption = null
if (workspaceUser) {
newOption = {
id: workspaceUser.id,
name: workspaceUser.name,
}
}
const newValue = [...oldValue]
if (newOption) {
newValue.push(newOption)
}
if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) {
this.$emit('update', newValue, oldValue)
}
},
},
}