This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-29
Channels
- # announcements (1)
- # babashka (83)
- # beginners (67)
- # chlorine-clover (22)
- # cider (11)
- # circleci (6)
- # clj-kondo (12)
- # cljs-dev (137)
- # cljsrn (15)
- # clojure (124)
- # clojure-europe (40)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-serbia (3)
- # clojure-spec (19)
- # clojure-uk (14)
- # clojuredesign-podcast (5)
- # clojurescript (80)
- # conjure (49)
- # core-async (62)
- # cursive (18)
- # datascript (1)
- # datomic (64)
- # docker (28)
- # emacs (20)
- # figwheel-main (249)
- # fulcro (95)
- # graalvm (2)
- # jobs-discuss (11)
- # joker (2)
- # juxt (4)
- # lambdaisland (9)
- # leiningen (1)
- # meander (14)
- # mount (6)
- # off-topic (16)
- # pathom (46)
- # re-frame (35)
- # reagent (6)
- # reitit (5)
- # shadow-cljs (28)
- # spacemacs (6)
- # sql (18)
- # tools-deps (26)
- # vim (8)
- # xtdb (23)
- # yada (1)
Really not sure what to do here: I’m constructing a favourites list, and if pathom returns this sort of thing:
{:avatar/id 354
:avatar/favourite-items [[:item/id 7]]}
Then Fulcro silently discards :avatar/favourite-items
…
However if I return this:
{:avatar/id 354
:avatar/favourite-items [{:item/id 7}]}
It doesn’t, but that’s not a valid join, so {:item/id 7}
doesn’t ever resolve into anything…The former is not correct. Results of queries are maps or sequences of maps. Idents are an artifact of normalization. The latter is fine, and will normalize…but has no data (other than an id). What do you expect?
You should be able to continue resolution with [{:item/id 7}]
. I have resolvers that return data in that shape, and they work fine.
Ah, never mind. I misunderstood.
I think if you have a component with an :item/id
ident composed into the query that's causing the load, then normalization should convert [{:item/id 7}]
into [[:item/id 7]]
. Does that make sense?
I managed to work around it by introducing a layer of nesting… (too many layers of nesting though, this feels like a patch, not a fix) >_<…
I’m having to do weird get-in
’s all over the place to grab the data I want, which feels very much against the spirit of what I’m trying to achieve using fulcro, but I’m really unclear what to do here…
eg:
(get-in props [[:component/id ::fav-item-list] :fav-item-list/avatar :avatar/favourite-items :items])
So that my :items
can know which things are favourites, so that it can correctly render UI buttons… I could push this stuff into pathom, 🤷:skin-tone-4:?I won't be able to look for a little bit, but it would be helpful to see your component queries/idents and the load you're using.
@folcon it should resolve itself and do the normalization if you have structured your components as nested ones.
@folcon you’re asking questions with incomplete information. I, nor anyone else, can answer these kinds of questions if we cannot see your components. We always need to see query/ident from each component to understand what to expect to happen…then you’re asking about get-in
…no context…where? in the UI? You not have to do a get-in
on this kind of thing in a properly structured UI
And you’re stacking on the expected behavior of pathom. That’s a lot of mixing of concerns
That’s fair, let me add in a bit of detail =)… I’m currently in the middle of a client call. But will update as soon as I can
cool, yeah, otherwise we’re just guessing, and that’s frustrating in both directions 🙂
Wow, I just used the UI State Machine for the first time now, and while I am pretty sure I haven't understood it 100% just yet, thanks for implementing that. It feels crazy to have something like that! 😄 Especially since my last project was the maintenance of a Symfony-based PHP page...
Well, what is small? ^^ I ported over the login state machine from the template and plan to add TOTP to it
I just mean it’s roughly a hybrid of FSM and my own invention. Don’t write whole programs as one SM 🙂
Ah, no, I won't do that, don't worry! But I will probably use it for things like multi-page forms
summary: if you can, load your multi-page as a single load (with form-state support), and use UI to show page by page from parent controller…then you can save it all at once and load it all at once.
I also wondered about :select-many, it seems to exist in RAD, yet is not implemented? I will take a look at the code there over the weekend I guess
select-many isn’t ringing a specific bell. Some things are definitely not implemented yet. You mean a form control that can allow you to do multi-select? I think at least one kind of that exists, but it isn’t there for everything.
Yes, I have the case that one user can have multiple roles, so I made the roles a separate "table", and made a RoleForm that has fo/field-styles {:role/label :pick-many}
. It renders the form title, but no selection field or anything. But it also doesn't give an error about it being an invalid field style.
I can’t keep it all in my head…that’s why I made the demo…it uses most of what is there
Yea. As I said, I'll probably take a look at the RAD code this weekend. Maybe it's something that just isn't finished yet
this is from my prod code:
(def employee-permission-labels {:employee.permissions/pos-config "POS Config"
:employee.permissions/pos-checkout "POS Checkout"
:employee.permissions/pos-settings "POS Settings"
:employee.permissions/pos-refund "POS Refund"})
(defattr permissions :employee/permissions :enum
{ao/schema :ucv
ao/cardinality :many
fo/default-value #{}
ao/identities #{:employee/id}
ao/enumerated-values (set (keys employee-permission-labels))
ao/enumerated-labels employee-permission-labels})
no addl config…that is the default rendering for to-many enums with predefined values
Interesting! Thanks! I will need to tinker a bit anyway, because not every user is supposed to be able to give every role. The whole concept probably needs some hammock development first on my end
right, at some pt you’ll get to cases where you just have to provide a plugin for your UI control
One last thing though, somewhat unrelated: it seems no matter the URL I give it, the application always goes straight to the landing page. I am using the MainRouter from RAD-demo, and the root has as initial-state {:router {}}
just like the demo. I removed all rad-auth stuff.
You have to install history support (html5 in this case) and make sure you initialize it and trigger it properly.
look in the post login handling…I think that’s where I read the URL and tell history to start
Hmm yes, it is in com.example.client/init
, history/install-route-history! app (html5-history)
In the rad-demo, in the account_forms.cljc
, there is the AccountListItem
component, however it is not used anywhere, is it dead code ?
Also there is AccountList-Row
component, which I see being pulled into the client DB, when inspecting it through FulcroInspect. However I dont see this component anywhere in the project. The only reference is in a comment block. So wondering how is this showing up in the client DB ?
So, you can hand a report a component to use for the rows. That is there so I can swap it in and out
when you don’t hand it one, it autogenerates one, which is the other one you’re seeing
(def account-plans {:account.plan/free "Free Plan"
:account.plan/plan1 "Paid Plan 1"
:account.plan/plan2 "Paid Plan 2"})
(defattr plan :account/plan :enum
{ao/cardinality :one
ao/enumerated-values (set (keys account-plans))
ao/enumerated-labels account-plans
ao/identities #{:account/id}
ao/schema :production})
When I pull this attribute in the rad-report, it shows the key
and not the label, any idea what could be missing ?but it is working in the rad-demo, its almost the same code, this is similar to the role
attribute in the accounts form
also when I click on the form
link from the report
, I get this error in the console, and the form doesnt open for editing / adding new account -
ERROR [com.fulcrologic.rad.routing:43] - Cannot find path for jra.ui.farm/AccountForm
I have specified the route-prefix
key in my form, where should I look to find the problem ?
rendering is all in semantic-ui rendering plugin. Start at semantic_ui_controls.cljc and follow the rabbit down the hole
thanks, that was the problem, it was not added to the router. Maybe the rendering for enums doesnt work for the report, for form it works. So just added a field formatter for the report.
On the form, when it is a new entry, after pressing save
button, the sate does not change, the cancel
button does not change into done
, although the new entity gets transacted on the server.
it seems the resolution did happen, this was the server response -
:com.fulcrologic.rad.form/save-form
{:account/id #uuid "7eb9913b-f32f-49fc-880a-4ee67c9c7441"
:account/name "abc"
:account/plan :account.plan/plan1}
sorry where should I look to correct the above, I have the following as my parser plugin (form/pathom-plugin save/middleware delete/middleware)
@murtaza52 if you have a suggestion for documenting what you ran into (i.e. remember to add tempid stuff here if you do blah) I’d be interested in that going in the RAD dev guide or something
@U0CKQ19AQ these are the problems I have faced -
1. There needs to be documentation regarding fulcro-rad-app
that is provides the tempids resolver and second it requires the csrf token js var in the index. Preferrably both of these should not even be here, maybe a default middleware somewhere to be plugged in for the parser. Just like ring-defaults lib.
2. Documentation that Router not only requires the top level forms but also sub forms for the router to work correctly.
3. Documentation that the install-ui-contrrols
provides default rendering for the form and needs to be run on init. Again preferably there needs to be a default lib, from which this can just be included.
4. this key used in models in rad-demo is invalid - :com.fulcrologic.rad.database-adapters.datomic/attribute-schema
, the correct key that automated-schema
uses is :com.fulcrologic.rad.database-adapters.datomic-cloud/attribute-schema
. Again better if this is made a property.
5. the generated resolver for fulcro sends only the ident back for an enum attribute, this needs to be documented. I had a custom resolver which was sending back the :db/id and ident for a enum ref attribute.
6. the bug where defsc-records does not play nice with enumerated-labels for an enum attribute.