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
42 changes: 42 additions & 0 deletions frontend/src/modules/member/member-array-attributes-field.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import StringField from '@/shared/fields/string-field'

export default class MemberArrayAttributesField extends StringField {
constructor(name, label, config = {}) {
super(name, label)

this.placeholder = config.placeholder
this.hint = config.hint
this.required = config.required
this.matches = config.matches
this.filterable = config.filterable || false
this.custom = config.custom || false
this.options = config.options
}

dropdownOptions() {
return this.options.sort((x, y) => {
return x.label < y.label
? -1
: x.label > y.label
? 1
: 0
})
}

forFilter() {
return {
name: this.name,
label: this.label,
custom: this.custom,
props: {
options: this.dropdownOptions(),
multiple: true
},
defaultValue: [],
value: [],
defaultOperator: 'contains',
operator: 'contains',
type: 'select-multi'
}
}
}
4 changes: 3 additions & 1 deletion frontend/src/modules/member/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export default {
}
},

async doBulkEnrich({ rootGetters }, ids) {
async doBulkEnrich({ rootGetters, dispatch }, ids) {
try {
const currentTenant =
rootGetters['auth/currentTenant']
Expand Down Expand Up @@ -403,6 +403,8 @@ export default {
showEnrichmentLoadingMessage({ isBulk: true })

await MemberService.enrichMemberBulk(ids)

await dispatch('doFetchCustomAttributes')
} catch (error) {
Message.closeAll()
Errors.handle(error)
Expand Down
30 changes: 24 additions & 6 deletions frontend/src/shared/fields/get-custom-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ import StringField from '@/shared/fields/string-field'
import BooleanField from '@/shared/fields/boolean-field'
import IntegerField from '@/shared/fields/integer-field'
import DateField from '@/shared/fields/date-field'
import ArrayField from '@/shared/fields/array-field'
import MemberArrayAttributesField from '@/modules/member/member-array-attributes-field'

export default (customAttributes) => {
return (
Object.values(customAttributes)
.filter((a) => a.show)
.filter((a) => {
// Don't render special filters that do not have available options
if (
a.type === 'multiSelect' ||
a.type === 'special'
) {
return a.options.length && a.show
}

return a.show
})
.map((customAttribute) => {
switch (customAttribute.type) {
case 'boolean':
Expand All @@ -30,12 +40,20 @@ export default (customAttributes) => {
)

case 'multiSelect':
case 'special':
return new ArrayField(
customAttribute.name,
customAttribute.label
case 'special': {
const options = customAttribute.options.map(
(o) => ({
value: o,
label: o
})
)

return new MemberArrayAttributesField(
customAttribute.name,
customAttribute.label,
{ options }
)
}
default:
return new StringField(
customAttribute.name,
Expand Down