mirror of https://github.com/logseq/logseq
chore: merge 2 new property fns together
refactor possible since page-name-sanity-lc in common-utilpull/10981/head
parent
8f736e82c7
commit
28e637e855
|
@ -47,16 +47,6 @@
|
|||
(assoc :block/type #{"hidden"}
|
||||
:block/format :markdown))))
|
||||
|
||||
(defn new-property-tx
|
||||
"Provide attributes for a new built-in property given name, schema and uuid.
|
||||
TODO: Merge this with sqlite-util/build-new-property once common-util/page-name-sanity-lc
|
||||
is available to deps/db"
|
||||
[prop-name prop-schema prop-uuid]
|
||||
{:block/uuid prop-uuid
|
||||
:block/schema (merge {:type :default} prop-schema)
|
||||
:block/original-name (name prop-name)
|
||||
:block/name (common-util/page-name-sanity-lc (name prop-name))})
|
||||
|
||||
(defn build-closed-values
|
||||
"Builds all the tx needed for property with closed values including
|
||||
the hidden page and closed value blocks as needed"
|
||||
|
@ -76,8 +66,7 @@
|
|||
(:closed-values property)))
|
||||
property-schema (assoc (:block/schema property)
|
||||
:values (mapv :block/uuid closed-value-blocks-tx))
|
||||
property-tx (merge (sqlite-util/build-new-property
|
||||
(new-property-tx prop-name property-schema (:block/uuid property)))
|
||||
property-tx (merge (sqlite-util/build-new-property prop-name property-schema (:block/uuid property))
|
||||
property-attributes)]
|
||||
(into [property-tx page-tx]
|
||||
(when-not closed-value-page-uuids? closed-value-blocks-tx))))
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
{: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 (get default-property-uuids k-keyword (d/squuid))})])))
|
||||
(or original-name k-name)
|
||||
schema
|
||||
(get default-property-uuids k-keyword (d/squuid)))])))
|
||||
db-property/built-in-properties)))
|
||||
|
||||
(defn build-db-initial-data
|
||||
|
|
|
@ -35,12 +35,15 @@
|
|||
|
||||
(defn build-new-property
|
||||
"Build a standard new property so that it is is consistent across contexts"
|
||||
[block]
|
||||
[prop-name prop-schema prop-uuid]
|
||||
(block-with-timestamps
|
||||
(merge {:block/type "property"
|
||||
:block/journal? false
|
||||
:block/format :markdown}
|
||||
block)))
|
||||
{:block/type "property"
|
||||
:block/journal? false
|
||||
:block/format :markdown
|
||||
:block/uuid prop-uuid
|
||||
:block/schema (merge {:type :default} prop-schema)
|
||||
:block/original-name (name prop-name)
|
||||
:block/name (common-util/page-name-sanity-lc (name prop-name))}))
|
||||
|
||||
|
||||
(defn build-new-class
|
||||
|
|
|
@ -176,13 +176,13 @@
|
|||
:property-attributes
|
||||
{:db/id (or (property-db-ids (name prop-name))
|
||||
(throw (ex-info "No :db/id for property" {:property prop-name})))}})
|
||||
[(sqlite-util/build-new-property
|
||||
(merge (db-property-util/new-property-tx prop-name (get-in properties [prop-name :block/schema]) uuid)
|
||||
{:db/id (or (property-db-ids (name prop-name))
|
||||
(throw (ex-info "No :db/id for property" {:property prop-name})))}
|
||||
(when-let [props (not-empty (get-in properties [prop-name :properties]))]
|
||||
{:block/properties (->block-properties-tx props uuid-maps)
|
||||
:block/refs (build-property-refs props property-db-ids)})))]))
|
||||
[(merge
|
||||
(sqlite-util/build-new-property prop-name (get-in properties [prop-name :block/schema]) uuid)
|
||||
{:db/id (or (property-db-ids (name prop-name))
|
||||
(throw (ex-info "No :db/id for property" {:property prop-name})))}
|
||||
(when-let [props (not-empty (get-in properties [prop-name :properties]))]
|
||||
{:block/properties (->block-properties-tx props uuid-maps)
|
||||
:block/refs (build-property-refs props property-db-ids)}))]))
|
||||
property-uuids))
|
||||
pages-and-blocks-tx
|
||||
(vec
|
||||
|
|
|
@ -105,12 +105,7 @@
|
|||
:block/uuid property-uuid
|
||||
:block/type "property"})]
|
||||
{:outliner-op :save-block})
|
||||
(db/transact! repo [(sqlite-util/build-new-property
|
||||
(cond-> {:block/original-name k-name
|
||||
:block/name (util/page-name-sanity-lc k-name)
|
||||
:block/uuid property-uuid}
|
||||
(seq schema)
|
||||
(assoc :block/schema schema)))]
|
||||
(db/transact! repo [(sqlite-util/build-new-property k-name schema property-uuid)]
|
||||
{:outliner-op :insert-blocks}))))
|
||||
|
||||
(defn validate-property-value
|
||||
|
|
Loading…
Reference in New Issue