Hello , i need some help related to passing namevalue props to EntityEditor(NameSection) Component using generateEntityProp ..
2021-11-30 33452, 2021
Shubh has quit
2021-11-30 33432, 2021
Shubh joined the channel
2021-11-30 33458, 2021
monkey
What's your question Shubh ?
2021-11-30 33436, 2021
monkey
Always best to ask the question so that I'll be able to see it when I reconnect :)
2021-11-30 33425, 2021
Shubh
I'm kinda stuck for a while figuring out how can i pass the query parameter to NameSection component
2021-11-30 33448, 2021
Shubh
there is generateEntityProps thingy which maybe generate props given if edit page or not , so
2021-11-30 33435, 2021
Shubh
and it return props which i think include initialState where value for name is stored for edit page
2021-11-30 33407, 2021
Shubh
this props passed to EntityEditorMarkup which accepts two props initalState and entity type ( then how we pass it so many props ? )
2021-11-30 33426, 2021
Shubh
EntityEditorMarkup then send rest props ( everything accept initalState which is only entityType ) to EntityEditor which furthur passes it props to NameSection as it is
2021-11-30 33419, 2021
Shubh
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.
2021-11-30 33412, 2021
Shubh
but i can't understand how it is getting its defaultName if EntityEditorMarkup only sending 'rest' which in case entityType props to EntityEditor ...
2021-11-30 33446, 2021
Shubh
what i'm missing here :,
2021-11-30 33403, 2021
Shubh
rest isn't entitytype only ..
2021-11-30 33419, 2021
monkey
I'll be with you shortly
2021-11-30 33426, 2021
Shubh
Thanks
2021-11-30 33412, 2021
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"
2021-11-30 33438, 2021
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`
2021-11-30 33410, 2021
monkey
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
2021-11-30 33458, 2021
monkey
In your case you'll be looking to modify `initialState.nameSection.name` I think
2021-11-30 33452, 2021
Shubh
so modifying name value in initalState.nameSection and passing it to EnityEditorMarkup will do the trick ?
2021-11-30 33407, 2021
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
2021-11-30 33414, 2021
Shubh
All done just one little issue ..
2021-11-30 33444, 2021
Shubh
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 .
2021-11-30 33427, 2021
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
2021-11-30 33406, 2021
monkey
Looking at your message, could it be a case issue? `sortName` instead of `sortname` ?
2021-11-30 33443, 2021
Shubh
i'm making a PR then
2021-11-30 33450, 2021
monkey
Great :)
2021-11-30 33425, 2021
Shubh
one more thing ..
2021-11-30 33410, 2021
Shubh
i'm making calltoaction component appear on every search acc to ticket ..
2021-11-30 33443, 2021
monkey
I'm with you so far, what's your question?
2021-11-30 33454, 2021
Shubh
i'm confirming if you are okay with having the missing entry option for every search anyway i made the PR :)
2021-11-30 33424, 2021
monkey
I think that's a good idea, and what the ticket suggested. Not sure what the best placement is, maybe below the pagination ?
2021-11-30 33412, 2021
Shubh
i did that please have a look
2021-11-30 33412, 2021
monkey
Will do. I'm working on something else at the moment and ask for your patience.