Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: duplicated virtual properties for nested keys
also added isVirtual to PropertyJSON
- Loading branch information
1 parent
f737ab0
commit 8043757
Showing
10 changed files
with
145 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,7 @@ describe('PropertyDecorator', () => { | |
'resourceId', | ||
'path', | ||
'isRequired', | ||
'isVirtual', | ||
) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/backend/decorators/resource/utils/get-property-by-key.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PropertyDecorator } from '../../property' | ||
import { DecoratedProperties } from './decorate-properties' | ||
import { findSubProperty } from './find-sub-property' | ||
import { pathToParts } from './path-to-parts' | ||
|
||
|
||
export const getPropertyByKey = ( | ||
propertyPath: string, | ||
properties: DecoratedProperties, | ||
): PropertyDecorator | null => { | ||
const parts = pathToParts(propertyPath) | ||
const fullPath = parts[parts.length - 1] | ||
const property = properties[fullPath] | ||
|
||
if (!property) { | ||
// User asks for nested property (embed inside the mixed property) | ||
if (parts.length > 1) { | ||
const mixedPropertyPath = parts.find(part => ( | ||
properties[part] && properties[part].type() === 'mixed' | ||
)) | ||
if (mixedPropertyPath) { | ||
const mixedProperty = properties[mixedPropertyPath] | ||
const subProperty = findSubProperty(parts, mixedProperty) | ||
|
||
if (subProperty) { | ||
return subProperty | ||
} | ||
} | ||
} | ||
} | ||
return property || null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters