Skip to content

Commit

Permalink
Merge pull request #2153 from FAIRsharing/RG_newFieldRegExp#2152
Browse files Browse the repository at this point in the history
Dealing with showing additional information that it is a String
  • Loading branch information
ramGranell authored Oct 3, 2023
2 parents 6b78f77 + 61b2f2c commit fc79ddd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/Records/Record/AdditionalInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ export default {
// if received node is not an array
if (!isArray(selectedNode)) {
this.tempData[key] = []
Object.keys(selectedNode).forEach(item_key => {
this.tempData[key].push({[item_key]: selectedNode[item_key]})
})
// Special case this is a string
if (typeof selectedNode === 'string' ){
this.tempData[key].push({"Value": selectedNode})
}
else {
Object.keys(selectedNode).forEach(item_key => {
this.tempData[key].push({[item_key]: selectedNode[item_key]})
})
}
return
}
// if received node is an array
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/components/Records/Record/AdditionalInfo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("AdditionalInfo.vue", function(){
await wrapper.vm.setAvailableData(selectedNode,'n')
selectedNode = [{}]
await wrapper.vm.setAvailableData(selectedNode,'a')
await wrapper.vm.setAvailableData("Hello",'justString')
expect(wrapper.vm.tempData).toStrictEqual({
"a": [
{
Expand All @@ -88,6 +89,11 @@ describe("AdditionalInfo.vue", function(){
{
"a": []
}
],
"justString": [
{
"Value": "Hello"
}
]
});
});
Expand Down

0 comments on commit fc79ddd

Please sign in to comment.