Fork me on GitHub

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 was doing that I believe…


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…



(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...


@zilti glad you like it.


keep them small 🙂


Well, what is small? ^^ I ported over the login state machine from the template and plan to add TOTP to it


It is basically screen-filling as is


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


but it is meant for your use-case, of course


yeah, when you get to forms, look at how RAD does that.


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.


if they are orthogonal, then UISM is super nice for the stepwise load/save too


form-state? Is that part of RAD? Thanks for the heads-up


form-state is part of Fulcro


and you should know about it, for sure.


Ah, found it, chapter 19


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


One second thought, I am not sure what kind of outcome I'd expect there...


for roles, I do have a thing that generates a set of toggle buttons


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


don’t remember how to use it


Ah. True, that could be a way as well


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


but for entities, I don’t have that yet, I don’t think


i.e. select many from db


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.


sorry, you edit the code and break it, I can’t magically tell you what you did 🙂


the demo has the bits


You have to install history support (html5 in this case) and make sure you initialize it and trigger it properly.


Oh, I assumed that's on by default in rad-demo


no no…can’t be


might be native app


look in the post login handling…I think that’s where I read the URL and tell history to start


Yea, then that is probably the issue. Should be an easy fix then, thanks again


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


cool thanks that makes sense. So the AccountList-Row is the autogenerated one ?


got to have a component to hold a query/ident for the rows


but it is trivial to generate that if you don’t want to control the rendering of it


(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 keyand not the label, any idea what could be missing ?


could be a bug


in the to-one renderer


remember this stuff is super young


I don’t know that I’ve rendered to-one enums in a report yet 😜


but it is working in the rad-demo, its almost the same code, this is similar to the role attribute in the accounts form


is there a field formatter in the demo?


it is there for :account/name


not for role


ro/field-formatters      {:account/name (fn [this v] v)}


on the attr?


honestly no other ideas on my part 🙂


No problem, where should I look, which code is doing the rendering ?


also when I click on the formlink 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 I have specified the route-prefix key in my form, where should I look to find the problem ?


remember to add it to a router as a target


routers can’t route to something they don’t know is theirs


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 cancelbutton does not change into done , although the new entity gets transacted on the server.


proper save requires server to do proper things.


tempid remap in particular.


do I need to plugin a server side mutation for the save operation ?


it seems the resolution did happen, this was the server response -

{:account/id #uuid "7eb9913b-f32f-49fc-880a-4ee67c9c7441"
:account/name "abc"
:account/plan :account.plan/plan1}


not seeing tempids in that


sorry where should I look to correct the above, I have the following as my parser plugin (form/pathom-plugin save/middleware delete/middleware)


found it fulcro-rad-appprovides the tempids resolver fn as a default


@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-schemauses 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.