Skip to content

Commit

Permalink
multilingual-localvocab
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed Oct 26, 2023
1 parent bcae568 commit 4ec0f4c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const I18nRichInputField = ({
labelIcon,
placeholder,
editorConfig,
lngFieldWidth,
usedLanguages,
lngFieldWidth,
...uiProps
}) => {
return (
Expand Down Expand Up @@ -62,7 +62,7 @@ I18nRichInputField.propTypes = {
disabled: PropTypes.bool,
optimized: PropTypes.bool,
editorConfig: PropTypes.object,
languageOptions: PropTypes.array,
usedLanguages: PropTypes.array,
lngFieldWidth: PropTypes.number,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ I18nTextInputField.propTypes = {
helpText: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
disabled: PropTypes.bool,
optimized: PropTypes.bool,
languageOptions: PropTypes.array,
usedLanguages: PropTypes.array,
lngFieldWidth: PropTypes.number,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export const LanguageSelectField = ({
multiple={multiple}
label={<FieldLabel htmlFor={fieldPath} icon={labelIcon} label={label} />}
optionsListName="languages"
usedOptions={usedLanguages}
usedLanguages={usedLanguages}
onChange={({ e, data, formikProps }) => {
formikProps.form.setFieldValue(fieldPath, data.value);
}}
value={getIn(values, fieldPath, multiple ? [] : '')}
value={getIn(values, fieldPath, multiple ? [] : "")}
{...uiProps}
/>
);
Expand All @@ -46,7 +46,7 @@ LanguageSelectField.propTypes = {
multiple: PropTypes.bool,
clearable: PropTypes.bool,
placeholder: PropTypes.string,
options: PropTypes.array,
usedLanguages: PropTypes.array,
};

LanguageSelectField.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const MultilingualTextInput = ({
helpText,
addButtonLabel,
lngFieldWidth,
sameLanguagesAllowed,
...uiProps
}) => {
const { options: languages } = useVocabularyOptions("languages");
Expand All @@ -45,7 +46,6 @@ export const MultilingualTextInput = ({
languages.all,
array
);

return (
<ArrayFieldItem
indexPath={indexPath}
Expand All @@ -55,13 +55,16 @@ export const MultilingualTextInput = ({
<Form.Field width={16}>
{rich ? (
<I18nRichInputField
key={availableLanguages.length}
fieldPath={fieldPathPrefix}
label={textFieldLabel}
labelIcon={textFieldIcon}
editorConfig={editorConfig}
optimized
required={required}
usedLanguages={array.map((v) => v.lang)}
usedLanguages={
sameLanguagesAllowed ? languages.all : availableLanguages
}
lngFieldWidth={lngFieldWidth}
{...uiProps}
/>
Expand All @@ -72,7 +75,9 @@ export const MultilingualTextInput = ({
label={textFieldLabel}
labelIcon={textFieldIcon}
required={required}
usedLanguages={array.map((v) => v.lang)}
usedLanguages={
sameLanguagesAllowed ? languages.all : availableLanguages
}
lngFieldWidth={lngFieldWidth}
{...uiProps}
/>
Expand All @@ -97,6 +102,7 @@ MultilingualTextInput.propTypes = {
helpText: PropTypes.string,
addButtonLabel: PropTypes.string,
lngFieldWidth: PropTypes.number,
sameLanguagesAllowed: PropTypes.bool,
};

MultilingualTextInput.defaultProps = {
Expand All @@ -107,4 +113,5 @@ MultilingualTextInput.defaultProps = {
rich: false,
label: undefined,
addButtonLabel: i18next.t("Add another language"),
sameLanguagesAllowed: false,
};

0 comments on commit 4ec0f4c

Please sign in to comment.