Fork me on GitHub
#fulcro
<
2020-03-27
>
Jakub Holý (HolyJak)09:03:20

Does Fulcro/Transit not support BigDecimals? When I send 123Mfrom a Pathom resolver, the Inspect - Query view shows the value as #object[UX [TaggedValue: f, 123]] Or is this OK and will work just fine in the UI?

4
souenzzo12:03:44

It's a transit issue. Once JS do not have BigDec, it just decode as a Tagged I usually create a handler that turns BigDec into JS strings]

souenzzo12:03:53

(transit handler)

Jakub Holý (HolyJak)12:03:33

Thanks! Could you be so kind and share how you do it? Or I can just search for it...

souenzzo13:03:55

(t/reader :json 
          {:handlers {"f" (fn [x] (.-rep x))}})
Something like it. Would be nice a blogpost about that

Jakub Holý (HolyJak)14:03:53

Thanks, @UCHV4JZ7A! So when I actually display it in the UI, it will look just fine and I can use the math ns to work with it?

adamfeldman14:03:41

👍 I don’t know, sorry — the extent of my knowledge is that what I sent exists 🙂

👍 4
Jakub Holý (HolyJak)12:03:49

Reading the RAD book's docs for ::report/source-attribute, it seems that the data must be under a top-level key in the DB, right? So I cannot have a list (report) invoices with the action "show invoice rows" that would show another report with the invoice's details, without loading them into a top-level key first? Actually I have a standard defsc for LatestInvoice and would like to have it display also an on-demand list of the invoice rows. But it is the same problem - I have a parent component that has the data and wants to display them in a report but has to put them under a top key first.

Jakub Holý (HolyJak)13:03:03

BTW, since I already have all the attributes defined, it would be nice to be able to leverage them also for a single-entity display, ie say this component should display these attributes of account, in the given order, using the default layout (likely a table)

Jakub Holý (HolyJak)14:03:24

Regarding ::attr/identity? - what if the DB table has a composed primary key, i.e. it is formed by 2+ columns and there is no single-column id? I guess so far out of scope?

alex-eberts15:03:49

Hi all - I’m exploring the fulcro-rad-demo and compilation with shadow-cljs watch main fails with a Use of undeclared Var com.fulcrologic.rad.application/install-ui-controls! error. Any idea what I’m doing wrong? Submitted a bug here: https://github.com/fulcrologic/fulcro-rad-demo/issues/7

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

which version do you use? I am on commit 87b53c8 (2d ago) and it works just fine.

Jakub Holý (HolyJak)15:03:00

and if you try the same as me?

alex-eberts15:03:11

I’ll give it a try - pls give me a few mins…

alex-eberts15:03:52

87b53c8 is working on my machine. Thanks @U0522TWDA

👍 4
Jakub Holý (HolyJak)16:03:14

I am trying but failing to find out how to use a Report to show "rows" of a selected item. I have a list (report, actually) of invoices with a "Details" button. When the button is pressed, I want to somehow load rows for the selected invoice and show them in a report. Reports work fine when the data is at the top level of the DB / there is a pathom resolver for its ::report/source-attribute but using to show the details of a selected entity escapes me...

tony.kay16:03:12

You’re trying to embed the details in the row? I.e. line items? That isn’t there yet. Best you can do is link to the invoice itself, as I do in the demo.

tony.kay16:03:31

I’ve literally done ilke 3 days of work on reports…they are very very young

tony.kay16:03:05

Well, actually, there is a way to do it in the current version: Write a custom layout renderer that supports it, and install a custom machine. 🙂

tony.kay16:03:19

Latest SNAPSHOT technically supports both, but I have no demo of that yet.

tony.kay16:03:28

probably don’t need the custom machine, now that I think about it…assuming you’re ok having the line items loaded in advance and just hidden.

tony.kay16:03:01

well, no, the query building will have to be augmented for that.

tony.kay16:03:19

Good use-case though, I should add that to the TODO list

Jakub Holý (HolyJak)16:03:33

Yes and no. I have independent components. When you select an invoice from the list, I hide the list and show the invoice's details including its rows report. So data-wise you could say it is embedded but not physically.

tony.kay16:03:57

Oh, you’re trying to show the invoice as a report?

tony.kay16:03:53

That’s still a nested report, which isn’t supported yet…the hooks just aren’t designed yet

👍 4
tony.kay16:03:26

The best you could do is write a form, and mark all of the field “read only”…i.e. InvoiceDisplayForm.

tony.kay16:03:48

that has layout options and everything, and supports nesting.

tony.kay17:03:10

The current report stuff is “tabular report”…what you want is more of a “entity report” that has a design similar to forms. Not sure those will combine nicely into the same concept. I might need to make two kinds of reports. We’ll see. Might just be an option on defsc-report

Jakub Holý (HolyJak)17:03:05

Having an entity report for the invoice would be nice, as I could reuse the work with attribute definitions. Currently I have a standard defsc for displaying the invoice but inside it I want to include a report with the invoice rows.

tony.kay16:03:18

To all and @alex-eberts make sure if you try out RAD demo that you use the master branch. develop is in flux and uses snapshot versions that I sometimes forget to publish. I did a bunch of cleanup and normalization yesterday, including moving some things around and renaming some keys. I’ll change the default in GH so no one else makes that mistake. Contributors to the demo should branch FROM develop. Master is always a stable release (if I do things right)

👍 8
tvaughan17:03:34

I can run a mutation (both server and broswer -side), and see the network request and response in Fulcro Inspect -> Network. Everything works. However, when I use "Send to query" to send the request to Fulcro Inspect -> Query, and then run the query. The response is:

{fulcro-app.db.mutations/update-team!
 {:com.wsscode.pathom.core/reader-error
  "Mutation not found - {:mutation fulcro-app.db.mutations/update-team!}"}}
This is the correct namespace. Both clj and cljs mutations exist and work when run in the server and browser. What am I doing wrong?

tony.kay19:03:41

mutations are not supported in the query tab

tvaughan20:03:37

Cool. Thanks!

dvingo19:03:57

I'm struggling to get a list of data in a component one level down the tree from root. Here's my example:

(defsc Person [this {name :person/name id :person/id}]
  {:query [:person/name :person/id]
   :ident :person/id}
  (dom/div (dom/p "Name: " name)))

(defsc People [this {:keys [all-people]}]
  {:query [ {:all-people (comp/get-query Person)}]}
  (dom/div "HI all people"))

(def ui-people (comp/factory People))

(defsc Root [this {:keys [list-component all-people]}]
  {:query [{:list-component (comp/get-query People)}
           {:all-people (comp/get-query Person)}]
   :componentDidMount (fn [this] (df/load! this :all-people Person))}
  (println "list-component: " list-component) ; <- this is nil
  (println "all-people: " all-people)         ; <- this has data
  (dom/div (ui-people list-component)))

;; After network load, db has:
;; :all-people [[ :person/id #uuid "a097e870-2a91-4497-ae0d-72f7e178c7f1" ]]
;; :person/id {#uuid "a097e870-2a91-4497-ae0d-72f7e178c7f1"  {:person/name "test" :person/id #uuid "a097e870-2a91-4497-ae0d-72f7e178c7f1" }}
if i query for all people from the root, the data is resolved, but asking for the data in the People component returns nil. anyone have an idea of how to get this People query from root to return data?

tony.kay19:03:15

@danvingo add :target [:list-component] to your load

dvingo20:03:25

ah thank you!

tony.kay20:03:37

and you don’t need the all-people thjing in your root query. You’re using that as a made-up name for network API…the only thing you need in the UI query is stuff that the UI will use. The confusion comes in when you want both: query for network purposes vs UI, and there is often overlap.

dvingo20:03:25

i see now. it clicked after adding the target bit that the list needs to get it's data from somewhere

roklenarcic23:03:59

I have a workspaces card that shows a form, but I don’t know where to put my add-form-config

tony.kay23:03:52

@roklenarcic not sure what you mean

tony.kay23:03:05

you could put it in initial state

tony.kay23:03:31

(fs/add-form-config Cls (get-initial-state Cls {}))

tony.kay23:03:45

I think that’s what you’re asking

tony.kay23:03:07

there is a tree version and a normalized version of that function. The tree version is for cases where you ahve a tree of data, like in initial state

roklenarcic23:03:11

add form config expects to get the root tree, right?

roklenarcic23:03:32

because in workspaces the component of the card is not at root

tony.kay23:03:04

@roklenarcic You can ask ws to either make a mock root for you, or trust you on the root. add-form-config expects the tree of the form itself.

tony.kay23:03:01

so, you could make your own root so you can wrap the get initial state…I don’t remember if ws has an option for specifying initial state…I mean, you could pass app options to the card if you’re embedding an app and set initial state manually.

tony.kay23:03:14

I usually just write the root in these cases so I’m in control

tony.kay23:03:43

you could also do it as a mutation in the app-did-mount thingy

roklenarcic23:03:36

hm OK, I will try it, I got a weird state when I did (fs/add-form-config Cls (comp/get-initial-state Cls…. , so I thought it needed to be root, will investigate further

roklenarcic23:03:39

yeah I was using wrong add-form-config