Fork me on GitHub
#fulcro
<
2020-08-27
>
dvingo02:08:32

Anyone have a clue as to what's going on here??

;; in the namespace: :be.produktiv.task-records.ui.task-record-item
  ;;  there is this component:
  (defsc TaskRecordItem
    [_ _]
    {:ident     :task-record/id
     :query     [:task-record/id
                 {:task-record/subtask-records '...}
                 :task-record/duration
                 :task-record/description
                 :task-record/date
                 :task-record/scheduled-at
                 :task-record/recorded-at
                 :task-record/state
                 :ui/expanded?]})

  ;; in a mutations namespace I have the following:
  
  (defn TaskRecordItem [] (c/registry-key->class :be.produktiv.task-records.ui.task-record-item/TaskRecordItem))

  ;; I'm trying to merge in a tree of task-records that have subtask-records.
  ;; note the incoming nested task-record has state :complete
  
  ;; The client db has the existing task-record in an incomplete state
  (merge/merge-component {:task-record/id {#uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127"
                                           {:task-record/state :incomplete
                                            :task-record/id    #uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127"}}}
    (TaskRecordItem)
    {:task-record/id    #uuid "9d366519-70eb-4303-aafd-b31a2c4ac8a4",
     :task-record/state :incomplete,
     :task-record/subtask-records
                        [{:task-record/id              #uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127",
                          :task-record/date            #time/date "2020-08-26",
                          :task-record/recorded-at     #time/date-time "2020-08-26T21:35:18.453",
                          :task-record/state           :complete,
                          :ui/expanded?                false,
                          :task-record/subtask-records []}]})

  ;; output =>

  {:task-record/id {#uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127" {:task-record/state :incomplete,
                                                                 :task-record/id #uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127",
                                                                 :ui/expanded? false,
                                                                 :task-record/date #time/date"2020-08-26",
                                                                 :task-record/recorded-at #time/date-time"2020-08-26T21:35:18.453",
                                                                 :task-record/subtask-records []},
                    #uuid"9d366519-70eb-4303-aafd-b31a2c4ac8a4" {:ui/expanded? false,
                                                                 :task-record/id #uuid"9d366519-70eb-4303-aafd-b31a2c4ac8a4",
                                                                 :task-record/state :incomplete,
                                                                 :task-record/subtask-records [[:task-record/id
                                                                                                #uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127"]]}}}
  ;; note the nested subtask-record is not getting updated (it is still :incomplete)
Now the weird(er) part: if I copy the component definition into the mutation file and do not use the component registry, the merge-component call works properly...

dvingo02:08:32

(defsc TaskRecordItem
    [_ _]
    {:ident     :task-record/id
     :query     [:task-record/id
                 {:task-record/subtask-records '...}
                 :task-record/duration
                 :task-record/description
                 :task-record/date
                 :task-record/scheduled-at
                 :task-record/recorded-at
                 :task-record/state
                 :ui/expanded?]})

(merge/merge-component {:task-record/id {#uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127"
                                           {:task-record/state :incomplete
                                            :task-record/id    #uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127"}}}

    TaskRecordItem ; <-- using the component defined in the mutations file.
    {:task-record/id    #uuid "9d366519-70eb-4303-aafd-b31a2c4ac8a4",
     :task-record/state :incomplete,
     :task-record/subtask-records
                        [{:task-record/id              #uuid "e1e6eff8-7443-4b9b-a77f-fa8db0578127",
                          :task-record/date            #time/date "2020-08-26",
                          :task-record/recorded-at     #time/date-time "2020-08-26T21:35:18.453",
                          :task-record/state           :complete,
                          :ui/expanded?                false,
                          :task-record/subtask-records []}]})
;; output =>
{:task-record/id {#uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127" {:task-record/state :complete, <---------- and the state is set correctly
                                                               :task-record/id #uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127",
                                                               :task-record/date #time/date"2020-08-26",
                                                               :task-record/recorded-at #time/date-time"2020-08-26T21:35:18.453",
                                                               :ui/expanded? false,
                                                               :task-record/subtask-records []},
                  #uuid"9d366519-70eb-4303-aafd-b31a2c4ac8a4" {:task-record/id #uuid"9d366519-70eb-4303-aafd-b31a2c4ac8a4",
                                                               :task-record/state :incomplete,
                                                               :task-record/subtask-records [[:task-record/id
                                                                                              #uuid"e1e6eff8-7443-4b9b-a77f-fa8db0578127"]]}}}
I am not even sure where to begin debugging this, but thought I'd bring it up. My strategy going forward is to make a shared namespace of queries and define the component definition twice...

dvingo02:08:26

I'm using 3.2.11 for what it's worth

dvingo13:08:41

I've got no idea what's going on anymore. I just replicated the tree of queries in the mutations namespace for now and things are working... What a mess

dvingo16:08:23

Still have no idea - but I'm instead computing a tree of data and then converting to db using tree->db and then assoc-in'ing the tables that I care about..

dvingo16:08:45

that way I don't have to worry about getting the components

bbss07:08:15

I'm looking in to using workspaces, eventually got some of the examples working with the com.github.awkay/workspaces version but two issues remain: • no inspector, even though my build includes the preload • every time I refresh workspaces, the layout is lost Am I missing something?

pserrano14:08:46

I had problems with inspector this week, maybe the thread will help you https://clojurians.slack.com/archives/C68M60S4F/p1598021142026100

Tyler Nisonoff21:08:00

I have a component for a "Project" with :route-segment ["project" :id] I can route to it via (rroute/route-to! this Project {:id id}) (rad router) just fine, However, I can't pageload to a project with just, say, /project/ffffffff-ffff-ffff-ffff-000000000300 it seems that the query params tacked on by route-to! are required -- how would one allow users to pageload to that view without query params?

Tyler Nisonoff22:08:55

i guess i could transform the url by hand to the expected route / param combo on start-up?

Jakub Holý (HolyJak)16:08:49

Fulcro routing is not hooked into URL at all. Look at RAD how it does it

Tyler Nisonoff16:08:26

could you say more about that? I'm based off of the RAD demo -- page-loading to URLs that correspond to route segments definitely takes me there

Tyler Nisonoff16:08:38

for example, if i go to , I'll get routed to the accounts report

Jakub Holý (HolyJak)20:08:56

Ah, ok, I didn't get that. Then it's just about studying the code...

Tyler Nisonoff20:08:20

tony responded below, it sounds like a bug, ive been working through the code

👍 3
tony.kay22:08:45

@tylernisonoff so this is a standing issue: params should not be required, but I have not had time to deal with it.

tony.kay22:08:02

is that a form or report?

Tyler Nisonoff22:08:28

its a standard component -- not a form/report

Tyler Nisonoff22:08:22

good to know its a standing issue! Any advise if of where to start if I wanted to look into fixing? (I know I still have the other PR to wrap up 😛, but maybe after)