Fork me on GitHub
#fulcro
<
2020-03-29
>
tony.kay00:03:39

so, the “easy” workaround @roklenarcic is to use component-local state for full-name during typing, and do your state updates (transact) on blur

tony.kay02:03:52

@holyjak I added read-only form support (::form/read-only? on RAD master forms). So, now you can treat a form like a report. I’ll add the linkify stuff to it, as soon as I get some routing stuff added.

❤️ 4
tony.kay02:03:39

I should probably allow forms to just switch to read only mode based on the route param passed to them as well

tony.kay03:03:13

I just pushed 3.1.23-SNAPSHOT of Fulcro. I’ve added some long-needed bits to the dynamic router, and updated the book. This is in preparation for building more complete routing into RAD as well. The new features are: • You can resolve the path to a target with (dr/resolve-path). This allows you to dynamically look up the route (a vector of strings) to a target at runtime. It does, however, require that you are careful not to use the same target in more than one place in your application’s tree. Doing so, of course, will cause it to only find one of them, and “which one” will not be obvious. RAD will use this in order to allow you to move RAD components deeper into the tree, and not just place them in the root router. • Reworked how will-leave works. If you don’t change your app, it should be 100% bw compatible, but the new stuff allows you to ask, anywhere in the app, if an on-screen target would block routing without potentially triggering a reaction from will-leave. This, of course, requires you rework your targets. The new support adds a :allow-route-change? option. See http://book.fulcrologic.com/#_targets_denying_routes_v3_1_23

tony.kay03:03:22

This includes the new function can-change-route? as well, and also has a new component option :route-denied and helper retry-route!. The book explains how to use it all.

tony.kay03:03:37

There are probably still little bugs, so I’m not releasing this formally just yet. I don’t expect the API to change, but I have to think about the dynamic query aspects of this, and I’m not sure I got them right.

🎉 16
Jakub Holý (HolyJak)08:03:16

Any idea why my router is getting nil props? This is the relevant part of the Root query:

...
:tem-organization/organization-number
 {:tem-organization/latest-bill-run
  [:bill-run/id
   {:ui/subscribers-list-router
    [:com.fulcrologic.fulcro.routing.dynamic-routing/id
     [:com.fulcrologic.fulcro.ui-state-machines/asm-id
      :minbedrift.ui/SubscribersListRouter]
     {:com.fulcrologic.fulcro.routing.dynamic-routing/current-route
      [*]}
     {:alt0
      [{:bill-run/subscribers
        [:br-subscriber/subscriber-id]}
       [:ui.fulcro.client.data-fetch.load-markers/by-id _]]}]}]}]}]
but when I resolve it against the app state (`com.fulcrologic.fulcro.algorithms.denormalize/db->tree`), it completely lacks the :ui/subscribers-list-router part. :ui/* keys are removed only from server-side queries, no? The data I get includes:
...
{:tem-organization/organization-number "979199325",
:tem-organization/latest-bill-run
{:bill-run/id 47143}}
The router is in my DB (see the thread below). Thank you!!!

4
Jakub Holý (HolyJak)15:03:50

Ok, the problem is that I load! data for the parent component, which did not exist before and of course thus won't have the :ui/subscribers-list-router (which the server, providing the data, knows nothing about)

Jakub Holý (HolyJak)19:03:07

I fixed it by adding the router's initial state to the incoming data via :pre-merge

currentoor19:03:01

yeah that initial-state composition is easy to get wrong

currentoor19:03:17

happens a lot, i think that’s what @U0CKQ19AQ is hoping to address with the floating roots

👍 4
Jakub Holý (HolyJak)06:03:22

Thanks, I will look at those

roklenarcic16:03:49

Hm when I use StringBufferedInput component, the weird thing is that when the underlying model is nil my model->string function gets called with "" as the argument, which seem contrary to what you’d expect, I would expect the parameter to be nil.

theeternalpulse17:03:38

how would I get emacs to properly align all of fulcros element macros arguments. by default if I have the argument map next to the element, it aligns the child element against the map rather than like it does in the examples like this

(div {:className "a" :id "id" :style {:color "red"}}
    (p "Hello")))

Chris O’Donnell18:03:59

@U1CUUKHDL

(setq clojure-indent-style 'always-indent)

theeternalpulse18:03:08

Hmm, I remember this, I have it to align-arguments, I remember there being some issues. I know that you can specify how you want a macro indented, but not sure if that is externalized, I didn't want to change the style I'm used to in all cases.

Chris O’Donnell18:03:13

Seems like kind of a pain to do this for all the fulcro dom macros, personally. I switched over to always-indent a while back and have no regrets.

theeternalpulse19:03:00

I'll try it out, I already have that setting in my config. I think align arguments is great most of the time

cjsauer23:03:33

@U1CUUKHDL I solved this recently by adding the following to the .dir-locals.el file at the root of my project: https://gist.github.com/cjsauer/407a02529af6871bada5bdb6515ff8ac Using this exact file requires all elements use the aliased form (dom/div), but you can easily tweak it to meet your needs. You might :refer [div] for example, so you could add div to that file alongside dom/div

cjsauer23:03:41

I copied the elements from here: https://github.com/fulcrologic/fulcro/blob/f3d39173362e95a28e34d1f7417b1a2cbe2f05f5/src/main/com/fulcrologic/fulcro/dom.cljs#L16 There really aren’t that many DOM elements, so it’s pretty simple to just enumerate them.

theeternalpulse16:03:34

Oh nice. Does this also cover custom components?

tony.kay21:03:21

HTML5 routing just added to the RAD demo. Not super well-tested, but seems to work really well.

💯 20
tony.kay21:03:52

See @codonnell’s Blog post for some details that help understand the implementation if you read the source. https://chrisodonnell.dev/posts/giftlist/routing/ (this is on the develop branch of RAD demo)