Hello , i need some help related to passing namevalue props to EntityEditor(NameSection) Component using generateEntityProp ..
Shubh has quit
Shubh joined the channel
monkey
What's your question Shubh ?
Always best to ask the question so that I'll be able to see it when I reconnect :)
Shubh
I'm kinda stuck for a while figuring out how can i pass the query parameter to NameSection component
there is generateEntityProps thingy which maybe generate props given if edit page or not , so
and it return props which i think include initialState where value for name is stored for edit page
this props passed to EntityEditorMarkup which accepts two props initalState and entity type ( then how we pass it so many props ? )
EntityEditorMarkup then send rest props ( everything accept initalState which is only entityType ) to EntityEditor which furthur passes it props to NameSection as it is
NameSection (where i need that name=query prop) accept defaultName value for entity name field this is where i need to pass that query name.
but i can't understand how it is getting its defaultName if EntityEditorMarkup only sending 'rest' which in case entityType props to EntityEditor ...
what i'm missing here :,
rest isn't entitytype only ..
monkey
I'll be with you shortly
Shubh
Thanks
monkey
So, I'm not sure I follow everything, but here are some clues: when you see something like `const {initialState, ...rest} = props;`, the `…rest` in there actually represents all the other items that were in `props` except `initialState`. So it's not a prop name in itself, rather "all the other props"
Shubh
i understand that but there is no field name nameValue in rest object
This 'name' state item is in a section of the state called `nameSection`
Currently I think there is no place where we set the name initially, and so the default `name` prop set to an empty string can be found in src/client/entity-editor/name-section/reducer.js
It looks like we get `initialState` returned by generateEntityProps, and we can modify this initial state at will before sending the markup
In your case you'll be looking to modify `initialState.nameSection.name` I think
Shubh
so modifying name value in initalState.nameSection and passing it to EnityEditorMarkup will do the trick ?
monkey
That should do the trick I'm a bit rusty, but it does look like that's what we're doing in that last bit of code I sent a link to
Shubh
All done just one little issue ..
all other require field in namesection (like sortname) is giving invlid field hint although i provided the default values for other field (like sortname:"") in namesection same as redux .
monkey
Not sure. At this point I think it'll be easier if you open a PR so I can have a look too if you don't find what the issue might be
Looking at your message, could it be a case issue? `sortName` instead of `sortname` ?
Shubh
i'm making a PR then
monkey
Great :)
Shubh
one more thing ..
i'm making calltoaction component appear on every search acc to ticket ..
monkey
I'm with you so far, what's your question?
Shubh
i'm confirming if you are okay with having the missing entry option for every search anyway i made the PR :)
monkey
I think that's a good idea, and what the ticket suggested. Not sure what the best placement is, maybe below the pagination ?
Shubh
i did that please have a look
monkey
Will do. I'm working on something else at the moment and ask for your patience.