Fork me on GitHub
#fulcro
<
2021-11-24
>
Michael W02:11:56

I haven't updated deps.edn in a while, I just put everything to the newest versions and am seeing this error now:

The required JS dependency "@js-joda/timezone/dist/js-joda-timezone-10-year-range.min.js" is not available, it was required by "com/fulcrologic/rad/type_support/ten_year_timezone.cljs"
Any idea how to resolve it?

tony.kay04:11:26

Add that to your package.json

tony.kay04:11:34

@js-joda/timezone

tony.kay04:11:26

I made timezone not required if you don’t use it…but if you do, you need to add it to deps. I am trying to reduce what is always required

tony.kay04:11:32

(build size)

xceno10:11:55

Thew new fulcro-rad form debugger makes life so much easier! I used to (tap>) the form env into reveal or portal and inspect it there, but having it all on one page is a way better workflow

genekim22:11:32

🤯 Sounds amazing — any chance you can post a screenshot? That’s something I’d love to use! (I used to do the same: tap> and try to wade thru very large maps in Portal. 🙂

xceno10:12:37

Sure thing! I made a gif first, but I needed to redact some data, so here are some screenshots instead:

xceno10:12:28

It shows the form-state of all forms recursively. You get an overview of your RAD attributes, and on the bottom you see the actual computed diff. Also note the Notes column. It shows you those messages if something is wrong:

xceno10:12:16

Just explore the com.fulcrologic.rad.debuggingns a bit, to see what's going on. I'm rendering lot's of customized stuff, so I made my own little wrapper that works well in-place with my forms:

(defn form-debugger [form-instance props]
  (error-boundary
    (let [validator (comp/component-options form-instance fo/validator)]
      (r.debug/ui-form-info props {:form-instance form-instance
                                   :validator     validator}))))
I just attach it to the bottom of the form I want to debug, but theoretically you could also put it in another tab or something

sheluchin14:11:22

How can I set an initial selected-row in a RAD report? Do I have to alter the ro/machine based on the :initial state in https://github.com/fulcrologic/fulcro-rad/blob/952278690222ed38d09eb15b28f13f09726d04ce/src/main/com/fulcrologic/rad/report.cljc#L342?

Jakub Holý (HolyJak)15:11:18

That's often the right answer :-) Not sure whether there is a simpler way

sheluchin15:11:27

It seems like something that might also be possible through route params too but I'm not yet able to get it to work.

tony.kay16:11:15

Yes, you should be able to use r Params. Look at the current machine. It won't trigger an event though.

tony.kay16:11:48

Here’s a hint on figuring it out without reading code: The _rp_ query parameter is a map of the route-params for a given route, transit encoded + base64. There is a function in com.fulcrologic.rad.routing.html5-history/query-params (which is CLJC, by the way, so can be used from CLJ REPL and CLJS REPL) that can decode a copy/paste of the params from the URL. So, go to the report, do anything that will end up in this map (such as select a row, go to page 3, etc. and then decode the params.

sheluchin16:11:42

Ah, but I'm interested in initially loading the page with a row selected. There are no query params in the URL at that point.

tony.kay16:11:14

you pass that decoded map to route-to!

tony.kay16:11:22

that will encode them into the URL

tony.kay16:11:44

every action you do in RAD with html5-history installed puts the “state” of the UI into those params

tony.kay16:11:54

(if that state is tracked)

tony.kay16:11:17

and selected row is tracked, as is current page

sheluchin17:11:00

I'm presuming I can enter the decoded param map as the last param to change-route! here?

sheluchin17:11:01

But I think that line needs to be swapped with the very next line which installs html5-history.

tony.kay19:11:34

you should use RAD’s routing wrapper fn

sheluchin20:11:54

Thanks, yes, that worked. That decode function will probably come in handy again. I was reading through the code and tapping bits here and there but hadn't yet arrived at a solution.

Eric Dvorsak18:10:12

to load a route from the url I use

(history/install-route-history! app (html5-history/html5-history true))
  (html5-history/restore-route! app ui/CourseList {})
where you could have additional params in the empty map

mtnygard17:11:19

Hello all! I'm working on a RAD report. The main entity is a "group". It has attributes :group/leader and :group/members that are each refs to :person/id. The leader is a to-one and the members is to-many, as one might expect. I'd like to put the name of the leader into the report. So I need to get an attribute from a related entity. (But with the wrinkle that the attribute name itself doesn't uniquely describe the path to access it.) If I just add person/name to the ro/columns it is blank. I've tried a couple of forms of ro/row-query-inclusion but without much success. I have two questions related to this; first, how do I do this particular join for the report? Second, how do I debug the connections from report -> attributes -> Pathom -> Datomic in the future?

Jakub Holý (HolyJak)22:11:19

Great to see you here! I'm off computer now but could something here https://gist.github.com/holyjak/207ed33c9ee7e003b9a779fa47c32d91 help?

Jakub Holý (HolyJak)22:11:41

(I loved Release It, great book and learned a great deal from it, thanks a lot!)

💯 1
mtnygard04:11:15

Hi Jakub, thanks those notes look perfect. Also I'm glad you enjoyed Release It! I'm always happy to hear that people find it useful.

❤️ 1
mtnygard15:11:17

Reviving a dead thread after US Thanksgiving holiday... I'm still stuck on https://gist.github.com/holyjak/207ed33c9ee7e003b9a779fa47c32d91#displaying-to-one-ref-attributes. This is my top-level entity's attribute:

;; In slide.cljc
(defattr root :slide/root :ref
  {ao/identities #{:slide/id}
   ao/required?  false
   ao/schema     :production
   ao/target     :person/id})
Then I have this for the Person entity:
;; In person.cljc
(defattr id :person/id :uuid
  {ao/identity? true
   ao/schema    :production})

(defattr name :person/name :string
  {ao/identities #{:person/id}
   ao/required?  true
   ao/schema     :production})
In my report, I have this:
;; In slide_forms.cljc
(report/defsc-report SlideList [this props]
  {ro/title               "All Slides"
   suo/rendering-options  {suo/report-table-class "ui very compact celled selectable table"}
   ro/form-links          {slide/title SlideForm slide/root PersonForm}
   ro/columns             [slide/title person/name]
   ro/row-pk              slide/id
   ro/row-visible?        (constantly true)
   ro/source-attribute    :slide/all-slides
   ro/run-on-mount?       true
   ,,,  ;; controls, control layout elided
   ro/route               "slides"})

mtnygard15:11:38

The column for person/name appears blank. On the server side, I see this in the log:

Running [{:slide/root [:person/id]} :slide/title] on entities with  :slide/id : [[:slide/id #uuid "c68dce64-1889-4728-9586-fd9bfc29318e"]]
So the client side isn't even asking for person/name . If I look at the Network tab in Fulcro Inspect, I see this query being sent:
[({:slide/all-slides [:slide/id :person/id :slide/title :person/name]})
 :com.wsscode.pathom.core/errors]
Which is a bit weird since the join from Slide to Person is via slide/root which is not part of the query. The response, predictably, does not include person/id or person/name since those aren't available on the Slide entity:
{:slide/all-slides
 [{:slide/id #uuid "c68dce64-1889-4728-9586-fd9bfc29318e",
   :slide/title "Blank A"}]}

mtnygard15:11:51

Sorry for the wall of text. I'm trying to provide all the details for asynch communication. 🙂 At the moment I can't tell if the problem is in my attribute definitions, my report, or my resolvers.

mtnygard15:11:07

Looks like it was the resolvers. Following the example from fulcro-rad-demo with invoice.cljc, I added a resolver:

;; In slide.cljc
#?(:clj
   (pc/defresolver root-id [env {:slide/keys [id]}]
     {::pc/input #{:slide/id}
      ::pc/output [:person/id]}
     {:person/id (queries/get-slide-root-id env id)}))
Once I added that to my parser, the report column works great.

Jakub Holý (HolyJak)15:11:12

Sorry for late reply, I have been swamped with work and stuff. Great to hear you got it working!

Jakub Holý (HolyJak)09:11:25

I have a slightly different approach in https://github.com/holyjak/minimalist-fulcro-template-backendless/tree/pathom3 though I haven't yet sorted out error handling and indexes

👍 2
zeitstein10:11:29

Thanks for making me aware of this – I will take a look!