spike: properties and classes work without :block/name

* db tests pass
* new graph created
* can use class and property on blocks and with each other
* can nav to class and property pages fine
* can use and query all property types on blocks and pages
This commit is contained in:
Gabriel Horner
2025-05-09 15:41:43 -04:00
parent 2c67b6de11
commit 94abe924b0
6 changed files with 15 additions and 15 deletions

View File

@@ -286,7 +286,7 @@
(concat
[:map
[:db/ident class-ident]]
page-attrs
(remove #(= :block/name (first %)) page-attrs)
page-or-block-attrs)))
(def property-common-schema-attrs
@@ -305,7 +305,7 @@
[:logseq.property/view-context {:optional true} [:enum :page :block :class :property :never]]]
property-common-schema-attrs
property-attrs
page-attrs
(remove #(= :block/name (first %)) page-attrs)
page-or-block-attrs)))
(def user-property
@@ -317,7 +317,7 @@
[:logseq.property/type (apply vector :enum db-property-type/user-built-in-property-types)]]
property-common-schema-attrs
property-attrs
page-attrs
(remove #(= :block/name (first %)) page-attrs)
page-or-block-attrs)))
(def property-page

View File

@@ -261,8 +261,7 @@
(let [db-ident (get-ident all-idents class-name)
new-block
(sqlite-util/build-new-class
{:block/name (common-util/page-name-sanity-lc (name class-name))
:block/title (name class-name)
{:block/title (name class-name)
:block/uuid (or (:block/uuid class-m)
(common-uuid/gen-uuid :db-ident-block-uuid db-ident))
:db/ident db-ident

View File

@@ -156,7 +156,6 @@
(:properties schema))]
(cond->
{:block/title title'
:block/name (common-util/page-name-sanity-lc title')
:db/ident db-ident
:block/uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident)}
(seq class-properties)

View File

@@ -78,7 +78,6 @@
{:db/ident db-ident'
:block/tags #{:logseq.class/Property}
:logseq.property/type prop-type
:block/name (common-util/page-name-sanity-lc (name prop-name))
:block/uuid (or block-uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident'))
:block/title (name prop-name)
:db/index true

View File

@@ -357,7 +357,7 @@
(not db-based?)
(assoc :block/type "journal"))
{}))]
[page page-entity]))
[(cond-> page (and db-based? class?) (dissoc :block/name)) page-entity]))
(defn sanitize-hashtag-name
"This must be kept in sync with its reverse operation in logseq.db.frontend.content"

View File

@@ -44,6 +44,7 @@
[logseq.common.util :as common-util]
[logseq.common.util.page-ref :as page-ref]
[logseq.db :as ldb]
[logseq.db.frontend.entity-util :as entity-util]
[logseq.graph-parser.mldoc :as gp-mldoc]
[logseq.shui.hooks :as hooks]
[logseq.shui.ui :as shui]
@@ -192,13 +193,15 @@
(rum/defcs page-blocks-cp < rum/reactive db-mixins/query
{:will-mount (fn [state]
(when-not (config/db-based-graph?)
(let [page-e (first (:rum/args state))
page-name (:block/name page-e)]
(when (and page-name
(db/journal-page? page-name)
(>= (date/journal-title->int page-name)
(date/journal-title->int (date/today))))
(state/pub-event! [:journal/insert-template page-name]))))
(let [page-e (first (:rum/args state))
page-name (or (:block/name page-e)
(when (or (entity-util/class? page-e) (entity-util/property? page-e))
(:block/title page-e)))]
(when (and page-name
(db/journal-page? page-name)
(>= (date/journal-title->int page-name)
(date/journal-title->int (date/today))))
(state/pub-event! [:journal/insert-template page-name]))))
state)}
[state block* {:keys [sidebar? whiteboard?] :as config}]
(when-let [id (:db/id block*)]