Fork me on GitHub
#fulcro
<
2022-07-28
>
Jakub Holý (HolyJak)06:07:49

ANN: https://github.com/holyjak/fulcro-rad-asami, the Asami backend for RAD, has reached Alpha status and is ready for a test drive. So please try it out and let me know how it works (or not) for you! You can see it used in https://github.com/fulcrologic/fulcro-rad-demo/pull/37/files

🎉 6
❤️ 2
janezj13:07:50

I am still wresting with reports, I tried many cases but in my case :default-value is always ignored. Is it just me again, or default-value must be false, nil or empty string? 🙂 There is initailize-paramters in report.cljc but I think it there a simple way to call it from the repl? Could be a problem that I have reports inside a component, and the component is route target?

ro/controls {:company {:type :picker
                           po/query-key :search/companies
                           po/query-component Company
                           po/options-xform (fn [normalized-result raw-result]
                                              (for [{:company/keys [id name]} raw-result] {:value id :text name}))
                           :default-value "1"
                           :label "Company"}
                 :ps {     :label "pos"
                           :default-value "z"
                           :type :string}
                 :locker { :label "locker"
                           :default-value true
                           :type :boolean}
                 :xxx {    :type :picker 
                           :options [{:text "a" :value "100"} {:text "b" :value "101"}]
                           :default-value "100"
                           :label "xxx"
                       }}

roklenarcic11:07:27

if you look at source, default value is used by initialize-parameters function which is called when report is initialized and when :event/set-ui-parameters is triggered

roklenarcic11:07:02

the actual value used will be first non-nil of: • from event params • from url params • from fulcro state (if retain? isn’t false) • default-value

roklenarcic11:07:14

at least that’s my reading of the source

roklenarcic11:07:04

a smart thing to do when developing with fulcro rad, is to checkout the repository and then change your deps to point to your local copy of fulcro-rad

1
roklenarcic11:07:34

then you can modify rad code (such as adding console log statements) and it will reload and work in real-time

roklenarcic11:07:49

and you can see which values you get in these nested components

janezj16:07:48

I have found that report controls are visible, but state machine (:com.fulcrologic.fulcro.ui-state-machines/asm-id) is not there yet, so it is logical, that default-values are not set. • run-on-mount? true • but picker-data in loaded in db by the report !!!! there are values in picker • at start of app there is route set directly to the report (rr/route-to! app lst/StationReport {}) after the first run-report! the state machine is finally there in :state/gathering-parameters There are two warnings: • WARN [com.fulcrologic.rad.picker-options:141] - No options cache found in props for app.ui.listing/StationReport . This could mean options have not been loaded, or that you forgot to put [::picker-options/options-cache '_] on your query. NOTE: This warning can be a false alarm if the application just started and no picker options have yet been loaded. • WARN [com.fulcrologic.fulcro.ui-state-machines:?] - cljs$core$ExceptionInfo {message: '', data: {…}, cause: null, name: 'Error', description: undefined, …} Attempt to get an ASM path {meta: null, cnt: 2, shift: 5, root: {…}, tail: Array(2), …} for a state machine that is not in Fulcro state. ASM ID: {ns: 'app.ui.root', name: 'MainRouter', fqn: 'app.ui.root/MainRouter', hash: 730525377, cljs$lang$protocolmask$partition0$: 2153775105, …} See https://book.fulcrologic.com/#warn-uism-sm-not-in-state

roklenarcic16:07:29

I am not a computer but you broke something

janezj17:07:32

I found the solution. I put report directly into the router, outside of parent component. And state machine is started. So I it works. I used to add report to app like ordinary component. (def ui-station-report (comp/factory StationReport)) Now I have to find a way to initialize report, when parent got :will-enter.

Jakub Holý (HolyJak)18:07:33

Just call the start function to start the SM. See what the default will enter does.

bmaddy20:07:40

How are people handling authorization in RAD these days? I came up with two solutions but haven't figured out which way to go yet. 1. Outside of Pathom, look at the incoming query and remove parts the current user shouldn't see (probably using edn-query-language.core/mask-query) 2. Add the user's permissions onto the pathom environment and have each resolver handle it individually I'm leaning towards #1 becuase attributes are disabled by default. Is there anything better? Any gotchas I should be aware of?

janezj08:07:48

I have my apps behind https://github.com/oauth2-proxy/oauth2-proxy and resolvers are checking :groups in jwt token. Frontend is aware of jwt groups.

👍 1
Jakub Holý (HolyJak)18:07:54

Beware : you might be running a tiny bit of my code there 😅

😁 1