Skip to content
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

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

kpsherva
Copy link
Contributor

@kpsherva kpsherva commented Jan 26, 2024

state = { sections: [] };
constructor(props) {
super(props);
this.state = { sections: undefined, composeSections: undefined };
Copy link
Member

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 && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{composeSections && composeSections && (
{composeSections && (

});
sections.push({ ...sectionCfg, fields });
if (sectionCfg.compose_fields) {
Copy link
Member

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
Copy link
Member

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(
Copy link
Member

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) => {
Copy link
Member

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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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),
Copy link
Member

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;
Copy link
Member

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?

@kpsherva kpsherva merged commit e3306a6 into inveniosoftware:master Jan 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants