Skip to content

Commit

Permalink
fix: assigned user default value and clearable
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreiffers committed Oct 13, 2023
1 parent 068ef8a commit f27a6ad
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/components/fields/field-select/field-select.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ExternalProps {
showLabel: boolean;
showRequired: boolean;
label: string;
placeHolder?: string;
placeholder?: string;
onClear: () => void;
onChange: () => void;
onInputChange?: (arg: string) => void;
Expand Down Expand Up @@ -58,7 +58,7 @@ const SelectFieldPure: FC<Props> = ({
showRequired,
defaultValue,
label,
placeHolder,
placeholder,
onClear,
onChange,
onInputChange,
Expand Down Expand Up @@ -106,7 +106,7 @@ const SelectFieldPure: FC<Props> = ({
maxMenuHeight={450}
options={options}
isClearable
placeholder={placeHolder ?? localization.select}
placeholder={placeholder ?? localization.select}
name={name}
value={defaultValue}
onChange={option =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const renderInternalField = (
<Field
name={name}
component={SelectField}
placeHolder={localization.selectUser}
placeholder={localization.selectUser}
label={getTranslateText(internalField.label)}
showLabel
showCustomOption
Expand Down Expand Up @@ -222,11 +222,18 @@ export const InternalInfo: FC<Props> = ({ catalogId, errors }) => {
<Field
name='assignedUser'
component={SelectField}
placeholder={localization.selectUser}
options={userList.map(item => ({
label: item.name,
value: item.id
}))}
isClearable
onClear={form => form.setFieldValue('assignedUser', '')}
onChange={(form, f, option) => form.setFieldValue(f, option.value)}
defaultValue={{
value: values.assignedUser,
label: userList.find(user => user.id === values.assignedUser)?.name
}}
/>
</SC.AssignUser>
<SC.Information>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const RelationItem: FC<Props> = ({
<Field
name={`begrepsRelasjon[${index}].relatertBegrep`}
component={SelectField}
placeHolder={localization.searchConcepts}
placeholder={localization.searchConcepts}
label={localization.relatedConcept}
showLabel
showRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const RelatedConceptsPure: FC<Props> = ({
<Field
name={field.name}
component={SelectField}
placeHolder={localization.searchConcepts}
placeholder={localization.searchConcepts}
showCustomOption
options={conceptSuggestionsMap}
onClear={() => form.setFieldValue(field.name, '')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const Validity: FC = () => {
<Field
name={erstattesAv.name}
component={SelectField}
placeHolder={localization.searchConcepts}
placeholder={localization.searchConcepts}
showCustomOption
options={conceptSuggestionsMap}
onClear={() => form.setFieldValue(erstattesAv.name, '')}
Expand Down

0 comments on commit f27a6ad

Please sign in to comment.