Fork me on GitHub
#fulcro
<
2022-10-21
>
sheluchin15:10:40

I have a component with a tab router. I'd like to include the different routes in the html history so when the user clicks a tab in the parent component, the tab content loads (ie the routing happens) and a new item gets pushed to the history stack. At present, the current tab is highlighted using :ui/selected-tab. This gets set in my tab-selected-handler in the state machine. The trouble is that this value doesn't get updated when hitting the browser's back/forward navigation buttons. I think the way to fix this is to hook up uism/trigger! ... :event/history-back inside a new route listener (`c.f.r.routing.history/add-route-listener!`). Does this sound like the correct approach, or is there something easier/better?

Grimgog17:10:17

I've tried to delete a form with a "delete-button". But there are only following functions: form/delete!, form/delete-entity. In form/delete! I have to provide [this id-key entity-id] whereas this is report-instance I guess and id-key is the uuid from my account. But what is entity-id and where to get it?

1
sheluchin18:10:04

Check the example https://github.com/awkay/fulcro-pwa-experiment/blob/f863ba1cca741d9b840978801ba4c14afe0c5d26/src/main/app/ui/invoice_forms.cljc#L65-L66. If you are doing this from ro/on-select-row or something like that, the second parameter to your function is going to be the row data and you can pull whatever data you need out of that to get your ID.

🙌 1
Grimgog18:10:08

oh this is nice and comfy! 😄 Thank you very much. Didn't expect that I can deconstruct just row-props and take what I need. It's working outstanding and even deletes my data in my xtdb db node. Nicu!

blob_thumbs_up 1
roklenarcic21:10:53

I have a form with props :category/id :category/title :category/parent the latter is a ref to the same entity (category). I specified the attribute to be :

(defattr parent ::parent :ref
  {ao/identities #{::id}
   ao/style :pick-one
   ao/schema :main
   ao/target ::id})
However when I navigate to form with (fn [] (form/create! this CategoryForm)), the following happens: • the parent property of the new entity is set to [:category/id nil] instead of being just nil • the DB table of :category/id gets nil entry

roklenarcic12:10:27

This seems very wrong.. what am I doing wrong?

roklenarcic12:10:15

Even worse, when I go to save the form, with title entered (it is required), I get the message that title is required and it won’t save the form. I think it’s referring to the parent (which is supposedly a subform).