Fork me on GitHub
#fulcro
<
2021-01-12
>
Jakub Holý (HolyJak)19:01:36

I have created https://github.com/fulcro-community/guides as a home to community created guides and created a draft of https://github.com/fulcro-community/guides/blob/main/learning-fulcro.adoc - I really need help with this one!

👏 18
JAtkins00:01:02

yup, I'm (slowly) pulling one together! Interesting finding though - it will be very hard to have running examples in any browser based example material - defsc is very heavily based on clj code in the macros, making sci a very hard to use method of getting editable running examples.

❤️ 3
Jakub Holý (HolyJak)07:01:02

Yes 😢 I looked at that (though not Sci) a way back. Having a server that would compile and return the code is the only solution I found. Perhaps an AWS Lambda or similar with limited throughout (to keep charges negligible)...

Björn Ebbinghaus21:01:06

@U2QGRCMSM Pins are not personal. You pinned this message to the channel.

Jakub Holý (HolyJak)20:01:05

🙏 If you have any input on how to best learn Fulcro, please https://docs.google.com/document/d/1XMWwwnxtukZ0o3ev4GH2Kpa8MvX4z-r4kYKJMaMBw2A/edit?usp=sharing that I will feed back to ☝️

alex-eberts23:01:28

I’m building a simple Todo app in Fulcro RAD that has Todos organized into Projects. I have a simple RAD report that lists all Projects. Projects can have many Todos (via a ref attribute). My report’s source-attribute is :projects/all-projects, a global resolver that returns all :project/ids. My report columns are “:project/label”, “:project/project-todos” and “:todo/label” (:todo/label is a “to-many” :ref from :project/project-todos to :todo/id). When I render the report, it displays the :project/label and :project/project-todos a vector of id’s (which makes sense). However, I would like to display the :todo/labels in the report. What’s the proper way to have the report render the individual :todo/labels themselves instead of the “idents in a list” that it displays by default? Link to the c.e.model.project.cljc: https://github.com/aeberts/fulcro-rad-demo/blob/develop/src/shared/com/example/model/project.cljc And a link to the c.e.ui.project.cljc: https://github.com/aeberts/fulcro-rad-demo/blob/develop/src/shared/com/example/ui/project.cljc

tony.kay00:01:13

The trivial answer is to make a resolver on an invented property name on the back-end. The alternative is more complicated, but there are many alternatives. Is the invented propery like :project/sample-todo-labels where the resolver sends back a comma-separated string not good enough?

tony.kay00:01:47

The main alts are: • Custom BodyItem • Row query inclusions (alternate to prior, cannot be used together) with a custom column renderer.

alex-eberts01:01:18

Hi @U0CKQ19AQ I think the invented property name you suggested would work in most cases. Does the invented property need to have an associated attribute defined in the model or is defining a resolver sufficient for this approach?

alex-eberts01:01:55

For learning purposes, I’m curious about how custom BodyItem and row query inclusions would work. Is there some example code somewhere that implements that? Thanks for the info!

tony.kay01:01:24

You’ll need an attr in order to add it as a column

👍 3
tony.kay01:01:38

in CLJC, you can co-locate the resolution with the attr

tony.kay01:01:22

On the other: Reports have to have a component for the report rows. The macro, by default, generates one (with -Row as a suffix to your report component’s name). That generated row component has the query for the cols + row query inclusions and an ident based on the id attribute of the row. If you specify BodyItem then you’re making the row component. It’s just a standard Fulcro component. You specify the ident, query, etc. From there the report component will just pass you props for the row, which you can render, or you can call the helper for row rendering the that plugin uses.

tony.kay01:01:11

The macro isn’t a ton of code…for educational purposes it is probably worth reading

alex-eberts01:01:05

Ok - that makes sense. Thanks. What is the name of the macro that generates the -Row component?

tony.kay02:01:35

defsc-report 😄

tony.kay02:01:01

it generates your report component, and if you don’t tell it the row component (BodyItem), it generates that too

alex-eberts02:01:18

re: defsc-report Doh! I probably could have guessed that one..facepalm

Jakub Holý (HolyJak)10:01:55

@U0CKQ19AQ could you be so kind and elaborate on > Row query inclusions (alternate to prior, cannot be used together) with a custom column renderer. namely what do you mean by "a custom column renderer"? I know I can have a custom ro/column-formatters but that does not help me because I do not have a column for the child entites (todos) added via row-query-inclusion . Did you mean essentially replacing the default sui-report/render-table-row (https://github.com/fulcrologic/fulcro-rad-semantic-ui/blob/4e331c855ef681152a418ece636628adb7303e25/src/main/com/fulcrologic/rad/rendering/semantic_ui/report.cljc#L50) with a custom one, that both renders the report columns and the row-inclusion-provided todos?

tony.kay14:01:09

I mean you can do a bunch of different things. There are escape hatches everywhere. You can customize render of a column with column formatters, you can take over row query/ident/rendering with BodyItem, you can take over the entire rendering of the table by supplying a body, etc. The generated row component generates a query. Read the macro. See where row-query-inclusions is used? See where BodyItem overrides the generated one? It’s pretty straightforward in the code I think. The rendering plugin doesn’t have many constraints from RAD itself (other than a basic entry point). I wrote SUI renderers one way, but there is definitely room to do it others.

Jakub Holý (HolyJak)16:01:18

Thank you. I did have a look at the code. My understanding it: 1. I can add the data using row-query-inclusion but then I cannot use column-formatters to show them - because on which column would I do that? There is no column for the data, it was added via query inclusion. Unless I add a dummy attribute and take over its column with a custom column formatter that would render the data from the query inclusion there. 2. Or I can have specify a ro/BodyItem with the desirable query and e.g. a custom row rendering to display them. 3. (I'm sure there are other, though perhaps more involved, solutions, such as completely replacing the report layout) Is that correct?

yubrshen16:01:26
replied to a thread:

Thank you all for your recommendations. I've finished following the chapter 4, and completed the coding, and it worked. I got some feeling of the magic. I still find it hard to write query and mutation on my own. I'll watch the video hoping to develop better understanding of query, and mutation. It also occurs to me that it seems Fulcro's database assume a graph database model (node, edge, query, ident, etc.). I might need better understanding and intuition of graph database model as prerequisite to be more comfortable with Fulcro. I wonder if my guess is on track? Also any expert advice of good material of graph database introduction? Thanks again!