Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress/e2e/column-usergroup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('Test column ' + columnTitle, () => {
cy.get('[data-cy="ncTable"] table tr td .user-bubble__name').contains(localUser.userId).should('be.visible')

cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').click()
cy.get('[data-cy="usergroupRowSelect"] .vs__deselect').click({ multiple: true })
cy.get('[data-cy="usergroupRowSelect"] input').clear().type(nonLocalUser.userId)
cy.get(`.vs__dropdown-menu [id="${nonLocalUser.userId}"]`).click()
cy.get('[data-cy="editRowSaveButton"]').click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ export default {
return {
selectUsers: this.column.usergroupSelectUsers,
selectGroups: this.column.usergroupSelectGroups,
internalLocalValue: [],
}
},
computed: {
localValue: {
get() {
return this.value
return this.internalLocalValue
},
set(v) {
let formattedValue = null
Expand All @@ -58,6 +59,7 @@ export default {
} else {
formattedValue = [v]
}
this.internalLocalValue = formattedValue
this.$emit('update:value', formattedValue)
},
},
Expand All @@ -67,6 +69,22 @@ export default {
// Doing this in data() doesn't work due to timing issues,
// since the data() function runs before the capabilities are fully initialized
this.selectCircles = this.isCirclesEnabled ? this.column.usergroupSelectTeams : false

let initialValue = this.value
if (!initialValue || (Array.isArray(initialValue) && initialValue.length === 0)) {
initialValue = this.column.usergroupDefault || []
}

const formatted = (Array.isArray(initialValue) ? initialValue : []).map(item => ({
...(item ?? {}),
// Adding a unique key such that removing items works correctly
key: this.getKeyPrefix(item?.type) + (item?.id ?? ''),
}))
this.internalLocalValue = formatted

if (formatted.length > 0) {
this.$emit('update:value', formatted)
}
},
methods: {
addItem(selectedItem) {
Expand All @@ -77,6 +95,15 @@ export default {
}
},

getKeyPrefix(type) {
switch (type) {
case 0: return 'users-'
case 1: return 'groups-'
case 2: return 'circles-'
default: return 'unknown-'
}
},

filterOutUnwantedItems(list) {
return list
},
Expand Down
Loading