mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
refactor: remove :name from built-in-properties
Remove it from built-in-properites as very few properties used it and no new properties will use. :name is only used for file graph property ids for looking up ids via get-pid or for the db graph import
This commit is contained in:
13
deps/db/src/logseq/db/common/property_util.cljs
vendored
13
deps/db/src/logseq/db/common/property_util.cljs
vendored
@@ -4,6 +4,17 @@
|
||||
[logseq.db.frontend.property :as db-property]
|
||||
[logseq.db.sqlite.util :as sqlite-util]))
|
||||
|
||||
(defn get-file-pid
|
||||
"Gets file graph property id given the db graph ident"
|
||||
[db-ident]
|
||||
;; Map of unique cases where the db graph keyword name is different than the file graph id
|
||||
(let [unique-file-ids {:logseq.property/order-list-type :logseq.order-list-type
|
||||
:logseq.property.tldraw/page :logseq.tldraw.page
|
||||
:logseq.property.tldraw/shape :logseq.tldraw.shape
|
||||
:logseq.property/publishing-public? :public}]
|
||||
(or (get unique-file-ids db-ident)
|
||||
(keyword (name db-ident)))))
|
||||
|
||||
;; TODO: replace repo with db later to remove this fn
|
||||
(defn get-pid
|
||||
"Get a built-in property's id (keyword name for file graph and db-ident for db
|
||||
@@ -11,7 +22,7 @@
|
||||
[repo db-ident]
|
||||
(if (sqlite-util/db-based-graph? repo)
|
||||
db-ident
|
||||
(get-in db-property/built-in-properties [db-ident :name] (name db-ident))))
|
||||
(get-file-pid db-ident)))
|
||||
|
||||
(defn lookup
|
||||
"Get the property value by a built-in property's db-ident from coll. For file and db graphs"
|
||||
|
||||
20
deps/db/src/logseq/db/frontend/property.cljs
vendored
20
deps/db/src/logseq/db/frontend/property.cljs
vendored
@@ -12,7 +12,7 @@
|
||||
;; Main property vars
|
||||
;; ==================
|
||||
|
||||
(def ^:large-vars/data-var built-in-properties*
|
||||
(def ^:large-vars/data-var built-in-properties
|
||||
"Map of built in properties for db graphs with their :db/ident as keys.
|
||||
Each property has a config map with the following keys:
|
||||
TODO: Move some of these keys to :properties since :schema is a deprecated concept
|
||||
@@ -26,8 +26,6 @@
|
||||
seen in when :public? is set. Valid values are :page, :block and :never. Property can
|
||||
be viewed in any context if not set
|
||||
* :title - Property's :block/title
|
||||
* :name - Property's :block/name as a keyword. If none given, one is derived from the db/ident.
|
||||
TODO: This is barely used for old properties. Deprecate this and move to gp-exporter
|
||||
* :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties
|
||||
* :queryable? - Boolean for whether property can be queried in the query builder
|
||||
* :closed-values - Vec of closed-value maps for properties with choices. Map
|
||||
@@ -241,7 +239,6 @@
|
||||
:schema {:type :map :hide? true}}
|
||||
;; FIXME: :logseq.property/order-list-type should updated to closed values
|
||||
:logseq.property/order-list-type {:title "List type"
|
||||
:name :logseq.order-list-type
|
||||
:schema {:type :default
|
||||
:hide? true}}
|
||||
:logseq.property.linked-references/includes {:title "Included references"
|
||||
@@ -253,10 +250,10 @@
|
||||
:schema {:type :node
|
||||
:cardinality :many
|
||||
:hide? true}}
|
||||
:logseq.property.tldraw/page {:name :logseq.tldraw.page
|
||||
:logseq.property.tldraw/page {:title "Tldraw Page"
|
||||
:schema {:type :map
|
||||
:hide? true}}
|
||||
:logseq.property.tldraw/shape {:name :logseq.tldraw.shape
|
||||
:logseq.property.tldraw/shape {:title "Tldraw Shape"
|
||||
:schema {:type :map
|
||||
:hide? true}}
|
||||
|
||||
@@ -567,17 +564,6 @@
|
||||
:public? true}
|
||||
:queryable? true})))
|
||||
|
||||
(def built-in-properties
|
||||
(->> built-in-properties*
|
||||
(map (fn [[k v]]
|
||||
(assert (and (keyword? k) (namespace k)))
|
||||
[k
|
||||
;; All built-ins must have a :name
|
||||
(if (:name v)
|
||||
v
|
||||
(assoc v :name (keyword (string/lower-case (name k)))))]))
|
||||
(into (ordered-map))))
|
||||
|
||||
(def db-attribute-properties
|
||||
"Internal properties that are also db schema attributes"
|
||||
#{:block/alias :block/tags :block/parent
|
||||
|
||||
@@ -51,20 +51,19 @@
|
||||
"Given a properties map in the format of db-property/built-in-properties, builds their properties tx"
|
||||
[built-in-properties]
|
||||
(mapcat
|
||||
(fn [[db-ident {:keys [attribute schema title closed-values properties] :as m}]]
|
||||
(fn [[db-ident {:keys [attribute schema title closed-values properties]}]]
|
||||
(let [db-ident (or attribute db-ident)
|
||||
prop-name (or title (name (:name m)))
|
||||
schema' (schema->qualified-property-keyword schema)
|
||||
[property & others] (if closed-values
|
||||
(db-property-build/build-closed-values
|
||||
db-ident
|
||||
prop-name
|
||||
title
|
||||
{:db/ident db-ident :schema schema' :closed-values closed-values}
|
||||
{})
|
||||
[(sqlite-util/build-new-property
|
||||
db-ident
|
||||
schema'
|
||||
{:title prop-name})])
|
||||
{:title title})])
|
||||
pvalue-tx-m (->property-value-tx-m
|
||||
(merge property
|
||||
;; This config is for :logseq.property/default-value and may need to
|
||||
|
||||
Reference in New Issue
Block a user