@@ -69,7 +69,23 @@ SPDX-License-Identifier: AGPL-3.0-or-later
6969 </div >
7070
7171 <div v-if =" field.can_edit" class =" profile-fields-personal__embedded-content" >
72+ <NcSelect
73+ v-if =" field.definition.type === 'select'"
74+ :data-testid =" `profile-fields-personal-input-${field.definition.field_key}`"
75+ :input-id =" fieldInputId(field.definition.id)"
76+ class =" profile-fields-personal__input-control profile-fields-personal__input-control--embedded"
77+ :model-value =" selectOptionFor(field)"
78+ :input-label =" field.definition.label"
79+ label-outside
80+ :clearable =" true"
81+ :searchable =" false"
82+ :options =" selectOptionsFor(field.definition)"
83+ label =" label"
84+ :placeholder =" placeholderForField(field)"
85+ @update:model-value =" updateSelectValue(field.definition.id, $event)"
86+ />
7287 <NcInputField
88+ v-else
7389 :data-testid =" `profile-fields-personal-input-${field.definition.field_key}`"
7490 :id =" fieldInputId(field.definition.id)"
7591 class =" profile-fields-personal__input-control profile-fields-personal__input-control--embedded"
@@ -201,21 +217,23 @@ const embeddedVisibilityAnchorReady = ref(false)
201217const draftValues = reactive <Record <number , string >>({})
202218const draftVisibilities = reactive <Record <number , FieldVisibility >>({})
203219
204- const inputModesByType = {
220+ const inputModesByType: Record < FieldType , ' text ' | ' decimal ' > = {
205221 text: ' text' ,
206222 number: ' decimal' ,
207- } as const
223+ select: ' text' ,
224+ }
208225
209- const inputModeForType = (type : FieldType ): ' text' | ' decimal' | ' numeric ' => {
226+ const inputModeForType = (type : FieldType ): ' text' | ' decimal' => {
210227 return inputModesByType [type ]
211228}
212229
213230const fieldInputId = (fieldId : number ) => ` profile-fields-personal-value-${fieldId } `
214231
215- const componentInputTypesByType = {
232+ const componentInputTypesByType: Record < FieldType , ' text ' | ' number ' > = {
216233 text: ' text' ,
217234 number: ' number' ,
218- } as const
235+ select: ' text' ,
236+ }
219237
220238const componentInputTypeForType = (type : FieldType ): ' text' | ' number' => {
221239 return componentInputTypesByType [type ]
@@ -230,6 +248,10 @@ const placeholderForField = (field: EditableField) => {
230248 return ' Enter a number'
231249 }
232250
251+ if (field .definition .type === ' select' ) {
252+ return ' Choose a value'
253+ }
254+
233255 return ' Enter a value'
234256}
235257
@@ -326,7 +348,7 @@ const canAutosaveField = (field: EditableField) => {
326348 return true
327349 }
328350
329- if (field .definition .type === ' text' ) {
351+ if (field .definition .type === ' text' || field . definition . type === ' select ' ) {
330352 return true
331353 }
332354
@@ -420,6 +442,18 @@ const buildPayload = (field: EditableField) => {
420442 }
421443}
422444
445+ const selectOptionsFor = (definition : { options: string [] | null }) =>
446+ (definition .options ?? []).map ((opt : string ) => ({ value: opt , label: opt }))
447+
448+ const selectOptionFor = (field : EditableField ) => {
449+ const value = draftValues [field .definition .id ]
450+ return value ? { value , label: value } : null
451+ }
452+
453+ const updateSelectValue = (fieldId : number , option : { value: string , label: string } | null ) => {
454+ updateDraftValue (fieldId , option ?.value ?? ' ' )
455+ }
456+
423457const saveField = async (field : EditableField ) => {
424458 const fieldId = field .definition .id
425459 if (! hasFieldChanges (field )) {
0 commit comments