Skip to content

Commit

Permalink
Merge pull request #635 from noi-techpark/development
Browse files Browse the repository at this point in the history
latest fixes
  • Loading branch information
RudiThoeni authored Oct 18, 2024
2 parents e648e22 + 1bd5914 commit f9ba1b0
Showing 1 changed file with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import { MaybeRef, computed, toValue } from 'vue';
import {
DatasetDomain,
DetailElements,
EditElements,
ListElements,
PropertyConfig,
SubCategoryElement,
} from '../../../config/types';
import {
DetailViewConfigWithType,
Expand Down Expand Up @@ -100,17 +103,68 @@ const applyReplacementsToSingleRecordView = <
objectValueReplacer: ObjectValueReplacer
): T | undefined => ({
...view,
elements: view.elements.map((element) => ({
...element,
subcategories: element.subcategories.map((subcategory) => ({
...subcategory,
properties: subcategory.properties.map((property) =>
replaceMappings(property, stringReplacer, objectValueReplacer)
),
})),
})),
elements: applyReplacementsToElements(
view.elements,
stringReplacer,
objectValueReplacer
),
});

const applyReplacementsToElements = (
elements: DetailElements[] | EditElements[],
stringReplacer: StringReplacer,
objectValueReplacer: ObjectValueReplacer
) => {
return elements.map((element) => ({
...applyReplacementsToSubElements(
element,
stringReplacer,
objectValueReplacer
),
subcategories: applyReplacementsToSubCategories(
element.subcategories,
stringReplacer,
objectValueReplacer
),
}));
};

const applyReplacementsToSubCategories = (
subcategories: SubCategoryElement[],
stringReplacer: StringReplacer,
objectValueReplacer: ObjectValueReplacer
) => {
return subcategories.map((subcategory) => ({
...subcategory,
properties: subcategory.properties.map((property) =>
replaceMappings(property, stringReplacer, objectValueReplacer)
),
}));
};

const applyReplacementsToSubElements = (
element: DetailElements,
stringReplacer: StringReplacer,
objectValueReplacer: ObjectValueReplacer
) => {
return element.subElements
? {
...element,
subElements: [...element.subElements].map((subElement) => ({
...subElement,
elements: {
...subElement.elements,
subcategories: applyReplacementsToSubCategories(
subElement.elements.subcategories,
stringReplacer,
objectValueReplacer
),
},
})),
}
: element;
};

const replaceMappings = (
property: PropertyConfig,
stringReplacer: StringReplacer,
Expand Down

0 comments on commit f9ba1b0

Please sign in to comment.