This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-22
Channels
- # announcements (7)
- # babashka (17)
- # beginners (45)
- # biff (2)
- # cider (16)
- # clj-on-windows (3)
- # cljs-dev (12)
- # clojure (27)
- # clojure-austin (1)
- # clojure-europe (18)
- # clojure-norway (5)
- # clojurescript (36)
- # conjure (35)
- # core-async (2)
- # datascript (4)
- # datomic (4)
- # emacs (15)
- # fulcro (23)
- # holy-lambda (12)
- # hyperfiddle (1)
- # introduce-yourself (5)
- # nbb (11)
- # off-topic (37)
- # pathom (34)
- # pedestal (9)
- # reitit (4)
- # releases (1)
- # remote-jobs (1)
- # sci (5)
- # scittle (3)
- # shadow-cljs (88)
- # tools-build (4)
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.
This is the report logic that governs that: https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/report.cljc#L145
it’s a little complicated because controls can be local or shared (e.g. in containers)
and their value can come from the URL, app state, route parameters, default values, or the retained value.
I’m using enc/nnil to make sure non-nil values win, but perhaps there is a logic error you can spot/fix
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?
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 🙂
I think it is a perfectly valid approach 🙂 I would love to see an implementation 😉
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.
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))))
Thank you. That's really helpful.
@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?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?