-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom_fields: compose fields from given list #229
Conversation
kpsherva
commented
Jan 26, 2024
•
edited
Loading
edited
- closes https://github.com/zenodo/rdm-project/issues/649
state = { sections: [] }; | ||
constructor(props) { | ||
super(props); | ||
this.state = { sections: undefined, composeSections: undefined }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to explain e.g docstring what is the difference between sections
and composeSections
.
{fields} | ||
</AccordionField> | ||
))} | ||
{composeSections && composeSections && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{composeSections && composeSections && ( | |
{composeSections && ( |
}); | ||
sections.push({ ...sectionCfg, fields }); | ||
if (sectionCfg.compose_fields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should align the name with the comment here
</AccordionField> | ||
))} | ||
{composeSections && composeSections && ( | ||
<ComposeFields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it more of ComposedSections
? I think here, if I understand correctly, it is a matter of having different section components. Some will have the default presentation and some the "composed" one.
constructor(props) { | ||
super(props); | ||
const { composeSections, record } = props; | ||
const filled = Object.keys(record.custom_fields).map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm here are not only the "compose" fields but all record save fields right?
return cfg; | ||
}; | ||
|
||
getFieldsWithValues = (sectionFields) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe here a better name would be availableSectionFields
? To differentiate from the "active" ones you compute in this function...
return filledFields; | ||
}; | ||
|
||
getSectionOfField = (field) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSectionOfField = (field) => { | |
getFieldSection = (field) => { |
const { templateLoaders, record } = this.props; | ||
const { sections, tempFields, recordFields } = this.state; | ||
const existingFields = [ | ||
...Object.entries(tempFields).map(([key, value]) => value.key), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tempFields
it might be a bit confusing depends on what they are referring to...maybe we need a better name on that. Aren't these addedFields
? maybe we discuss the naming....
|
||
render() { | ||
const { filteredFieldsList } = this.state; | ||
const { alreadyAddedFields, fieldPath, handleSelectField, sections } = this.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we use that instead of tempFields
?