Fork me on GitHub
#fulcro
<
2022-07-22
>
janezj16:07:01

Hi I have a problem with report params, just boolean values Param are defined in controls and visible ... ro/controls {:only-active {:label "Active" :type :boolean} ...} This works ok, and :only-active is passed to resolver report/start-report! SPA lst/StationReport {:route-params {:only-active false} }) This works also ok, and :only-active true is passed to resolver and ui-control in report is updated report/start-report! SPA lst/StationReport {:route-params {:only-active true} }) But after that point the value will remain set, and passed to the gui unless it is changed in ui report/start-report! SPA lst/StationReport {:route-params {:only-active false} }) so :only-active true is passed to backend.

tony.kay20:07:23

RAD 1.2.6 adds :retain? to controls as an option. Look at that and see if it helps.

tony.kay20:07:32

historically it has defaulted to true

tony.kay20:07:10

or are you saying that “false” isn’t properly handled…that is also a possible bug 😄

tony.kay20:07:11

it’s a little complicated because controls can be local or shared (e.g. in containers)

tony.kay20:07:43

and their value can come from the URL, app state, route parameters, default values, or the retained value.

tony.kay20:07:42

I’m using enc/nnil to make sure non-nil values win, but perhaps there is a logic error you can spot/fix

janezj10:07:05

It was a bug in 1.2.2. it works in 1.2.7

Mark Wardle21:07:16

Hi all. Has anyone foregone fulcro dynamic routing in favour of using a standard router (e.g. reitit) and performing loads / setting up internal state as part of the routing, leaving rendering to the components based on that updated internal state? This has been prompted by trying to pass through routing information from one router to another, in which routes are parameterised, (e.g. /projects/5/patients/3563/home . I can see I might forego some nice properties such as preventing routing (but I generally do that using modal dialogs) and I sort of see why co-locating data fetch within a component's 'will-enter' might be useful, but I am at least a little bit drawn to separating these concerns and making configuring state from route through a traditional set of explicit routes. Am I being daft in thinking this way?

Mark Wardle21:07:10

Thanks in advance for any advice, and apologies in advance if I am slow to reply as currently on a boat with very patchy networking). But it's been a good place to sit back and code 🙂

nivekuil21:07:37

I use reitit with a slightly patched dynamic routing system, works great

👍 1
Jakub Holý (HolyJak)21:07:03

I think it is a perfectly valid approach 🙂 I would love to see an implementation 😉

👍 1
Mark Wardle21:07:48

Thanks both. I will give it a try. I have a feeling it will make simple routing based on the user interface more difficult (e.g. panels / settings etc), but make it a bit easier to reason about parameterised paths and disconnect URLs from the user interface and so potentially keep a URL scheme that can remain backwards compatible even if the UI changes.

tony.kay21:07:50

Just as a note: the DR system doesn’t tie to the URL itself. This was an intentional design decision because it can be used in apps that are not web-based. The URL scheme of mapping certain routes to URLs is therefore a user-defineable function. So the idea of bw compat is already designed in. In fact, it is trivial to make a helper (as RAD has) so you can route to a target component, so you could easily just keep a map from URL to target component, and route that way. Just sayin 🙂 See rad.routing:

(defn route-to!
  "Change the UI to display the route to the specified class, with the additional parameter map as route params. If
  route history is installed, then it will be notified of the change. This function is also integrated into the RAD
  authorization system.

  The `RouteTarget` should be a _leaf_ target. Fulcro will correctly route through all the parent routers - just
  make sure that `route-params` includes all the params that are needed.

  You may include `::rad-routing/replace-route? true` in route-params as a hint to the history that you'd prefer to
  replace the top history element instead of pushing a new one."
  [app-or-component RouteTarget route-params]
  (if-let [path (absolute-path app-or-component RouteTarget route-params)]
    (do
      (when-not (every? string? path)
        (log/warn "Insufficient route parameters passed. Resulting route is probably invalid."
          (comp/component-name RouteTarget) route-params))
      (when (not= :denied (dr/change-route! app-or-component path route-params))
        (if (::replace-route? route-params)
          (history/replace-route! app-or-component path route-params)
          (history/push-route! app-or-component path route-params))))
    (log/error "Cannot find path for" (comp/component-name RouteTarget))))

❤️ 1
tony.kay21:07:27

So,

{"/some/path" SomeComponent
 ...}
is a pretty easy step away

❤️ 2
Mark Wardle07:07:07

Thank you. That's really helpful.

Jakub Holý (HolyJak)21:07:16

@tony.kay I am confused. The RAD parser elides not found https://github.com/fulcrologic/fulcro-rad/blob/fulcro-rad-1.1.6/src/main/com/fulcrologic/rad/pathom.clj#L140 but when I run EQL like this in RAD Demo:

[{[:account/id #uuid "no such id"]
  [:account/id
   :account/name
   :account/role ...
I get back there
{[:account/id #uuid "no such id"]
 {:account/role :com.wsscode.pathom.core/not-found,
  :account/id #uuid "no such id", 
  ; ...
  :account/name :com.wsscode.pathom.core/not-found}, 
:com.wsscode.pathom.core/errors :com.wsscode.pathom.core/not-found}
i.e. not-found is returned both for the properties and in the ::p/errors. Why?

tony.kay21:07:05

Good question 😛 I don’t know.

tony.kay21:07:27

seems like they should not make it back onto the wire

sheluchin17:10:37

I notice that :not-found values get returned in Inspect, even though I'm using Pathom3, which doesn't use the :not-found key at all. Is it possible your observation is related, @U0522TWDA?

🤷 1