Skip to content

Commit

Permalink
Merge pull request #2008 from Heigvd/MIM-132-fix-language-bug
Browse files Browse the repository at this point in the history
MIM-132 fix language bug
  • Loading branch information
TehAwol authored Jan 16, 2025
2 parents 024999f + 647cf91 commit 20e7223
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ createLanguageSchema.properties!['active'].view!.type = 'hidden';

const editLanguageSchema = cloneDeep(languageSchema);
editLanguageSchema.properties!['visibility'].view!.type = 'hidden';
editLanguageSchema.properties!['visibility'].view!.type = 'hidden';
(
editLanguageSchema.properties!['code'].view! as { readOnly: boolean }
).readOnly = true;
Expand Down Expand Up @@ -128,19 +127,24 @@ export default function LanguageEditor() {
const schema =
selectedLanguage.id == null ? createLanguageSchema : editLanguageSchema;

if (
Array.isArray(translatableLanguages) &&
schema.properties != null &&
schema.properties['code'] != null &&
schema.properties['code']['view'] != null
) {
schema.properties.code.view.type = 'select';
(schema.properties.code as ISelectProps).view.choices =
translatableLanguages.filter(
code => !languages.map(lang => lang.code).includes(code),
);
(schema.properties.code as ISelectProps).view.allowAnyValue = true;
}
React.useEffect(() => {
if (
Array.isArray(translatableLanguages) &&
translatableLanguages.length > 0 &&
createLanguageSchema.properties != null &&
createLanguageSchema.properties['code'] != null &&
createLanguageSchema.properties['code']['view'] != null
) {
createLanguageSchema.properties.code.view.type = 'select';
(createLanguageSchema.properties.code as ISelectProps).view.choices =
translatableLanguages.filter(
code => !languages.map(lang => lang.code).includes(code),
);
(
createLanguageSchema.properties.code as ISelectProps
).view.allowAnyValue = true;
}
}, [translatableLanguages, languages, createLanguageSchema]);

return (
<div className={cx(flex, flexRow, grow)}>
Expand Down

0 comments on commit 20e7223

Please sign in to comment.