So far I managed to get things done the way I needed but I know I am doing some things not very elegantly. Now I am beginning to understand some concepts and I am trying to remake some elements in my project “the right way”.
My project basically list documents from several collections, but the template or card for each element is almost the same. Only a few differences like:
If the document is located in the original collection, it has an icon with a heart so when the student click it, he/she saves that document in its own collection “favorites”.
When that specific document is located in “favorites”, it is exactly the same but the heart changes for a crossed heart icon that would remove from the “favorite” collection the document.
I have another collection named “homework” that has a specific icon as well.
So far I was able to achieve this creating three different components that are exactly the same but changing these icons. I believe that the right way to do this would be to have just one component with different states so these icons would be different according with the state.
So I wonder, am I right about approaching this using the states of the component? If so, how would I indicate in the script about the collection location and change the state accordingly?
I’m not sure if you can easily check the name of the collection in script but if you already know in the “design time” which collection each list is showing you can simply set the proper active component state from Nested comp tab.
Now I wonder how is it possible that I didn’t see how easy it was. You are absolutely right, there’s no need for a script as each list correspond to a different collection and I can point the state and there won’t be any change within that list.
Great to hear this! Anyway even it’s good to use states in some cases but using too much time on “normalizing” the components. So sometimes it’s ok to have almost the same component duplicated multiple times. You can choose your own practise based on what is most clear way of achieving the result and also keeping the project map readable.
That is something that I was just asking myself. If the result is exactly the same, I don’t know which is the “right” way to do it but my intuition tells me that it is better to have less components and play with the states. Nice to read that it is ok to do it the other way around. I am also reorganizing my database and playing with the query options in order to reduce the number of dataSheets and in this regard, I see it is not possible to reorganize or reorder the dataSheets, right? Not a big deal but I am “cleaning” my project and I wanted to put close to one another the related dataSheets as I was creating them on demand of the needs. I guess you get what I am saying.
I hear you but the Data sheet UI is currently organized so that Sheets are shown in order they are created. I’ll check if we could change the alphabetical ordering in the next release.
Not a big deal or any problem. I imagine that with a much larger project it may be more comfortable to have different ways to order or the possibility to sort it manually but for me it is just a small detail.