Browse Source

enhance: add icons to task status

also adds support for properties in initial-data to reference each other
via uuid
Gabriel Horner 1 year ago
parent
commit
22ed198c29

+ 6 - 2
deps/db/src/logseq/db/frontend/property.cljs

@@ -51,8 +51,12 @@
             :schema
             {:type :default}
             :closed-values
-            (mapv #(hash-map :value % :uuid (random-uuid))
-                  ["Backlog" "Todo" "Doing" "In Review" "Done" "Canceled"])
+            (mapv (fn [[status icon]]
+                    {:value status
+                     :uuid (random-uuid)
+                     :icon {:type :tabler-icon :id icon :name icon}})
+                  [["Backlog" "Backlog"] ["Todo" "Todo"] ["Doing" "In Progress 50"]
+                   ["In Review" "In Review"] ["Done" "Done"] ["Canceled" "Cancelled"]])
             :visible true}
    :priority {:original-name "Priority"
               :schema

+ 5 - 3
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -26,6 +26,8 @@
                         :file/content ""
                         :file/last-modified-at (js/Date.)}]
         default-pages (ldb/build-default-pages-tx)
+        ;; Some uuids need to be pre-defined since they are referenced by other properties
+        default-property-uuids {:icon (d/squuid)}
         default-properties (mapcat
                             (fn [[k-keyword {:keys [schema original-name closed-values]}]]
                               (let [k-name (name k-keyword)]
@@ -33,12 +35,12 @@
                                   (db-property-util/build-closed-values
                                    (or original-name k-name)
                                    {:block/schema schema :block/uuid (d/squuid) :closed-values closed-values}
-                                   {})
+                                   {:icon-id (get default-property-uuids :icon)})
                                   [(sqlite-util/build-new-property
                                     {:block/schema schema
                                      :block/original-name (or original-name k-name)
                                      :block/name (common-util/page-name-sanity-lc k-name)
-                                     :block/uuid (d/squuid)})])))
+                                     :block/uuid (get default-property-uuids k-keyword (d/squuid))})])))
                             db-property/built-in-properties)
         name->properties (zipmap
                           (map :block/name default-properties)
@@ -58,4 +60,4 @@
                                                    id))
                                                (:properties schema))}})))
                          db-class/built-in-classes)]
-    (concat initial-data initial-files default-pages default-classes default-properties)))
+    (vec (concat initial-data initial-files default-pages default-classes default-properties))))