Fork me on GitHub
#fulcro
<
2020-05-31
>
daniel.spaniel00:05:49

thanks @tony.kay that was too easy 🙂 I usually do pass symbol, but some times I want to just say .. just use the class for the current form.

Björn Ebbinghaus14:05:41

Hey, I am trying to use dr/current-route for rendering. My component has the following query, but it still won’t rerender when the route of ContentRouter changes.

{:query [[:com.fulcrologic.fulcro.ui-state-machines/asm-id :todoish.ui.todo-app/ContentRouter]]}
Any tips what I am doing wrong?

fjolne08:06:10

just in case, your router query (the one which queries for the router itself, not for ASM) should be the first in the :query list, otherwise there can be rendering issues with dr/current-route

tony.kay14:06:13

this is not true

dvingo16:05:59

My only tip is that the current route is data in db just like everything else so you can add debugging print statements or whatever you use for debugging to track the value over time - that way you can determine if the issue is the actual data not being updated at the time you want it to - or if it's a rendering issue

Björn Ebbinghaus22:05:37

Thanks. The issue resolved itself… Somehow it started to behave like expected.

murtaza5219:05:03

@tony.kay given a defsc-form, is it possible to add custom behaviour to its action-buttons, or modify the state machine associated with the form.

tony.kay19:05:27

you can completely override the state machine using ::form/machine (I think that is the option name).

tony.kay19:05:46

don’t remember how much I made for customizing control buttons in generated UI…but there are all sorts of angles you can expand

tony.kay19:05:36

you could: 1. Create a custom UI style for your form, and define a new control renderer that accepts whatever optiosn you want 2. Add a body to your form and render the fields and controls yourself, or partially use plugin UI to render parts, and control others

tony.kay19:05:50

3. override the state machine def, and customize what it does

murtaza5221:05:01

@tony.kay that means I can specify keys from the ::form (::form/machine) ns also in a defsc-form? I was currently considering keys only in the ::forms-options ns. Also will the ::form-options ns keys work for the reports also ? I wanted to specify a derived field (`fo/triggers`) and then the layout (`fo/layout`) to place that derived field, can I do that in a report using form-options keys ?

tony.kay05:06:19

so, the form-options ns are the officially supported options that I’ve documented. Don’t see myself changing the machine one, but it isn’t documented yet. no, you cannot use form options on reports.

murtaza5207:06:19

cool thanks that gives me lot of flexibility, if I can use the ::form/machine with defsc-forms.

murtaza5214:06:24

@tony.kay I would like to add a total of one of the columns, the end of the table that the rad report is displaying, is there a way to do that ?

tony.kay14:06:00

At present, there is not an interface to header/footer kinds of things. You can take control of the rendering, and use things from the plugin to render the parts, or you could just do something like this for the body of the report:

(dom/div
  (report/render-layout this)
  (div "Total: " ...use props to figure out total...))

tony.kay14:06:24

that won't make it part of the table itself, but it'll get the info on screen.

tony.kay14:06:42

Summary rows should be something supported...but I don't need them yet, and am busy

tony.kay14:06:49

Also remember that RAD isn't meant to do everything. It has escape hatches everywhere. It is intended to get something stood up quickly, not be a complete "kitchen sink".

murtaza5215:06:07

I would like to contribute, could you point me to sections where I can look for making the change ///

tony.kay15:06:55

So, there isn't a ton of code to it. The main report.cljc ns has most of the logic, except where the concern is primarily a UI bit of logic (very little of that). The semantic-ui plugin is where rendering is. The default style is table...so you look in semantic_ui_controls.cljc, and find the UI thing of interest and follow it. The pluggable stuff makes it a little hard to trace. Best to understand the data model of the report UISM and generated component (i.e. the query).

tony.kay15:06:57

Summary rows need a little design...how do they interact with pagination? etc.

tony.kay15:06:38

can there be more than one? Do you supply one for each column? Is it a summary sub-table with multiple rows?

tony.kay15:06:38

The main trouble is probably just pagination...supporting a simply summary row isn't that hard. I imagine you'd just supply a function that has to return a "row" map with the same keys as what you have for columns, and just render that as a tfoot

tony.kay15:06:09

perhaps an option for "on each page" or "in total"...that will (might?) affect that function's signature

tony.kay15:06:29

::report/footer (fn [rpt] {:sales/amount (reduce + ...)})

tony.kay15:06:58

where rpt is the instance, where you can get the props and look at everything from that paginate flag to the currently visible rows

tony.kay15:06:40

I guess you could easily make that return a map or vector...if a vector, then it renders more than one summary row? Not sure about labels, though

tony.kay15:06:32

I guess there could be a ::report/footer-headings or something that could supply strings for each column, and the rendering plugin could figure out something to do with them??? No great ideas there at the moment.

murtaza5216:06:33

thanks let me dig into the above and then will get back if I am stuck somewhere

Eccentric J22:05:06

Would it be an uphill battle to use https://github.com/clj-commons/cljss with fulcro? It has om bindings so would it just work?

Eccentric J23:05:20

Ah yes, I saw that! But I also noticed it was separated out for Fulcro 3 so you could use other tools if you preferred. Are there any major advantages to fulcro-garden-css I'm missing?