Fork me on GitHub
#fulcro
<
2020-03-25
>
zilti00:03:38

With fulcro-template, I am getting an exception in app.model.session, the compiler says java.lang.RuntimeException: Invalid token: ::m/returning

zilti00:03:47

I also have to say that I updated the dependencies in deps.edn, so I guess something changed in Fulcro?

tony.kay00:03:08

you sure the alias m is namespaced?

tony.kay00:03:24

could be in a comment

tony.kay00:03:41

clj(s) won’t compile a comment that uses an alias if the alias is removed from the requires

tony.kay00:03:34

(comment ::m/a) and #_:this-kind)

tony.kay00:03:46

things that follow ; are completely ignored

codonnell01:03:59

Just published a post about implementing client-side routing in fulcro at https://chrisodonnell.dev/posts/giftlist/routing/. I haven't blogged before and wouldn't consider myself a fulcro expert; I'm happy to hear any constructive feedback.

❤️ 12
Piotr Roterski10:03:45

Thanks @U0DUNNKT2, that's a really well written and focused post! I submitted a link to it on /r/fulcro https://www.reddit.com/r/fulcro/comments/fonu9c/fulcro_dynamic_router_pushy_chriss_blog/ Feel free to post there as well. Even though Fulcro has an extensive documentation, I think these kind of blog posts are essential in community building and make learning it much more approachable. I love that you share this neatly organised repo alongside. Definitely looking forward for more stuff like this!

zilti11:03:16

Oh neat, I will read this. I'm gonna need this sort of routing. I will probably use it together with reitit

tvaughan12:03:28

💡So that’s how you handle query params in the url! Thanks!

Jakub Holý (HolyJak)16:03:16

In RAD, how do I fetch the initial data for a report? I have assumed that with ::report/run-on-mount? true it would run the query automatically but it isn't the case, the report shows empty. Do I need to df/load! manually, as with standard Fulcro? How? Thank you! When I run (df/load! app :kostnadsdeling/all-organizations ui/OrgList), the report will show the data but it does not look correct in the DB - the root key :kostnadsdeling/all-organizations is a vector of many [:component/id :OrgList] . I wanted it to be what in practice is under :tem-organization/organization-number, i.e. ["org1" {:tem-organization/organization-number "org1"},..]. The LOADed query is

[{:kostnadsdeling/all-organizations
  [{:kostnadsdeling/all-organizations ;; twice ?!
    [:tem-organization/organization-number
     :tem-organization/organization-number]}
   [:ui.fulcro.client.data-fetch.load-markers/by-id _]]}]
The report has ::report/source-attribute :kostnadsdeling/all-organizations and I have
(defattr all-organizations :kostnadsdeling/all-organizations :ref
  {::attr/target    :tem-organization/organization-number
   ::pc/output      [{:kostnadsdeling/all-organizations [:tem-organization/organization-number]}]
   ::pc/resolve     (fn [{:keys [query-params] :as env} _]
                      #?(:clj
                         {:kostnadsdeling/all-organizations (queries/get-all-ksd-organizations env query-params)}))})

tony.kay18:03:40

@holyjak It does auto run with that option. Sure you have data?

tony.kay18:03:49

look in inspect

tony.kay18:03:23

you should not use load!…you can trigger a refresh from UI in the report with (`report/reload! reportinstance)`

tony.kay18:03:23

Use inspect to verify that your network request is sending the right query, and that you’re repsonding with right value

tony.kay18:03:32

NOTE: on current SNAPSHOT I’m actively working on report

tony.kay18:03:42

and I’ve renamed a few more things 😜

tony.kay18:03:56

I’ll push an update shortly…just polishing it off

tony.kay18:03:02

added a bunch of cool stuff

parrot 4
Jakub Holý (HolyJak)18:03:19

I looked in inspect - network and the only request there is

[{(com.example.model.account/check-session)
  [:com.fulcrologic.rad.authorization/provider
   :com.fulcrologic.rad.authorization/status 
   * 
   :tempids]}]
i.e. it is not sending the query at all. I am on 434725f - (origin/develop, origin/HEAD) Merge tag '0.0.1-alpha' into develop (22 hours ago)
(report/reload!
   (comp/class->any com.example.client/app OrgList))
returns nil and no new log in the Inspect - Network appears. And there is an error and a warning logged: > ERROR [com.fulcrologic.fulcro.ui-state-machines:?] - Attemped to trigger event :event/run on state machine [:component/id :OrgList] , but that state machine has not been started (call begin! first). > WARN [com.fulcrologic.fulcro.ui-state-machines:?] - UNEXPECTED EVENT: Did not find a way to handle event :event/run in the current active state: null (I took the RAD demo, added a new Root component that includes a single report component: (report/defsc-report OrgList ..) (def ui-org-list (comp/factory OrgList)) (defsc Root ... (ui-org-list org-list))))) )

tony.kay18:03:27

ok, RAD demo pushed, along with new snapshot versions of libs. • ::report/edit-form became ::report/form-links (see demo). Allows you to create links to many diff things on a single row. NOTE, this works by leveraging a resolver that can give the correct ids from the back end . In the demo case (invoice list) the :account/id has a resolver on an :invoice/id input. This allows the report to automatically get both IDs for each row. See https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/src/shared/com/example/model/invoice.cljc#L50::report/column-key was the wrong name, renamed to ::report/row-pk • Added ::report/actions and ::report/row-actions. See demo. • ::report/BodyItem is no longer needed in reports, unless you want to custom render, but then it simply needs query/ident, NO report params • ::report/row-style and ::report/layout-style now exist for choosing (or plugging in) custom report layouts and row renderers. See demo. Predefined values for these are :list and :table. If you use :list, then only (up to) two columns are supported. • MANY of the keys in things now accept either scalars or functions. I still need to make the parameters consistent. This allows for things like easy i18n, computed labels, etc.

tony.kay18:03:36

@holyjak No, you cannot use a report CLASS, it must be a report instance…and you should probably not be calling it unless you’re writing a custom renderer (it must be called from such a renderer, since that’s where you’ll get the on-screen instance)

Jakub Holý (HolyJak)18:03:33

Well, doesn't this turn the CLASS into an INSTANCE? (comp/class->any com.example.client/app OrgList)

tony.kay18:03:51

if it is on-screen, yes

4
tony.kay18:03:12

Reports start when they are routed to. Make a landing page, then route to the report.

tony.kay18:03:27

I don’t have a hook for you to start with a report on screen at app load

Jakub Holý (HolyJak)18:03:59

ok, that explains it, thanks!

tony.kay18:03:04

See report.cljc…this line:

(uism/begin! app report-machine report-ident {:actor/report report-class}
          {:route-params route-params})

tony.kay18:03:10

that’s what you do to start a report

tony.kay18:03:22

(route params can be empty in this case)

👍 4
tony.kay18:03:59

so:

(uism/begin! app report/report-machine [:component/id :OrgList] {:actor/report OrgList})

❤️ 4
tony.kay18:03:01

should work

4
tony.kay18:03:07

I’ll make a helper function

tony.kay18:03:50

snapshot pushed with helper: (report/start-report! app OrgList)

tony.kay19:03:42

I wish I had time to make more videos…alas, have to work and pay the bills 😞