How to view a block's property and marker in query-table mode

With the help of @gatoniel, I’ve completed a query that rearranges blocks within a page in chronological order, and as shown in the screen capture, I’ve verified that it works properly. However, I’d like to further see the status of the Task (DONE, LATER, CANCELED, etc.) along with the attributes of each block (including SCHEDULED) in the query-table mode, just like in the query-list mode. Also, I don’t want to see the parent and child blocks of the given block. Is there a way to do this?

#+BEGIN_QUERY
{
	  :title [:h4 "TIMELINE"]
	   :query
	  [
	  :find (pull ?b [*]) ?date
	  :keys block date
	  :in $ ?current-page
	   :where
	   [?p :block/name ?current-page]
	   [?b :block/page ?p]
	   (or-join [?b ?date]
	    (and 
	      [?b :block/refs ?ref]
	      [?ref :block/journal? true]
	      [?ref :block/journal-day ?date]
	     )
	     [?b :block/scheduled ?date]
	    )
	  ]
	  :inputs [:current-page]
	  :result-transform (fn [result] 
	                      (for [row (sort-by :date result)] 
	                        (let [block-map (get row :block)
	                              updated-properties (assoc (:block/properties block-map) :date (:date row))]
	                          (assoc block-map :block/properties updated-properties))))
	  :collapsed? true
	  }
#+END_QUERY

1 Like

The properties are already shown in table view:


Check the gear/cogwheel :gear: (top-right) if any of them is hidden.

As about the status of the task:

  • read it like
    [?b :block/marker ?marker]
    
  • pass it around like
    :find (pull ?b [*]) ?date ?marker
    :keys block date marker
    
  • append it like
    (assoc updated-properties :marker (:marker row))
    

It seems like there might have been some parts of my question that were prone to being misread. What I wanted was for the visual representation of a block in query-list mode to appear exactly the same in query-table mode (as shown in the capture below).

capture2

It appears that @mentaloid’s answer deals with a case where a SCHEDULED property, having a link to a journal page as its value, is added to a block. However, my question pertains to a case where a SCHEDULED date is added using the /scheduled command. In the former, the date is added to :block/properties, while in the latter, it is added to :block/scheduled.

If there’s no way to display the visual representation of a block in query-table mode exactly as it appears in query-list mode, I think one method could be to adopt @mentaloid’s answer: at the :result-transform stage, add necessary data like the scheduled date and marker to :block/properties, and then check this data in separate columns.

  • My bad for confusing :block/scheduled with a property.
    • But a query-table is primarily about properties.
  • If you want it to look exactly like a query-list, why don’t you use the query-list?
    • If the issue is the parent and child blocks, there are some options:
      • For parent: :breadcrumb-show? false
      • For children: a drastic css rule, e.g.:
        .custom-query .block-children-container {
          display: none;
        }
        
  • For a more customized output, should use :view

@mentaloid, thank you for the valuable information. Below is the final version of the query I have chosen. I have added necessary items, such as marker and scheduled, to :block/properties so that they can be viewed in query-table mode. Additionally, I have set :breadcrumb-show to false to ensure that the parent block is not displayed in query-list mode.

#+BEGIN_QUERY
{
:title [:h4 "TIMELINE"]
:query
[
:find (pull ?b [*]) ?date
:keys block date
:in $ ?current-page
:where
[?p :block/name ?current-page]
[?b :block/page ?p]
(or-join [?b ?date]
  (and 
    [?b :block/refs ?ref]
    [?ref :block/journal? true]
    [?ref :block/journal-day ?date]
   )
   [?b :block/scheduled ?date]
  )
]
:inputs [:current-page]
:result-transform (fn [result] 
                    (for [row (sort-by :date result)] 
                      (let [block-map (get row :block)
				               marker (:block/marker block-map)
                              deadline (:block/deadline block-map)
     						  scheduled (:block/scheduled block-map)
                              current-properties (:block/properties block-map)
                              updated-properties (assoc current-properties :date (:date row) :marker marker :scheduled scheduled :deadline deadline)]
                        (assoc block-map
                               :block/properties updated-properties))))
:collapsed? true
:breadcrumb-show? false
}
#+END_QUERY