diff --git a/deps/db/src/logseq/db.cljs b/deps/db/src/logseq/db.cljs index 78b47266d..8f335b221 100644 --- a/deps/db/src/logseq/db.cljs +++ b/deps/db/src/logseq/db.cljs @@ -442,7 +442,7 @@ (defn built-in? "Built-in page or block" [entity] - (db-property/property-value-content (:logseq.property/built-in? entity))) + (:logseq.property/built-in? entity)) (defn built-in-class-property? "Whether property a built-in property for the specific class" diff --git a/deps/db/src/logseq/db/frontend/property/type.cljs b/deps/db/src/logseq/db/frontend/property/type.cljs index 98cdb601a..d55741d38 100644 --- a/deps/db/src/logseq/db/frontend/property/type.cljs +++ b/deps/db/src/logseq/db/frontend/property/type.cljs @@ -33,7 +33,7 @@ "Property value ref types where the refed entity stores its value in :property.value/content e.g. :number is stored as a number. new value-ref-property-types should default to this as it allows for more querying power" - #{:number :url :checkbox}) + #{:number :url}) (def value-ref-property-types "Property value ref types where the refed entities either store their value in @@ -105,10 +105,6 @@ (when-let [entity (d/entity db id-or-value)] (number? (:property.value/content entity))))) -(defn- checkbox-entity? - [db id] - (boolean? (:property.value/content (d/entity db id)))) - (defn- text-entity? [db s {:keys [new-closed-value?]}] (if new-closed-value? @@ -128,7 +124,6 @@ (and (some? (:block/title ent)) (contains? (:block/type ent) "journal")))) - (def built-in-validation-schemas "Map of types to malli validation schemas that validate a property value for that type" {:default [:fn @@ -140,7 +135,7 @@ :date [:fn {:error/message "should be a journal date"} date?] - :checkbox checkbox-entity? + :checkbox boolean? :url [:fn {:error/message "should be a URL"} url-entity?] @@ -165,7 +160,7 @@ (def property-types-with-db "Property types whose validation fn requires a datascript db" - #{:default :checkbox :url :number :date :node :entity}) + #{:default :url :number :date :node :entity}) ;; Helper fns ;; ========== diff --git a/deps/db/src/logseq/db/frontend/rules.cljc b/deps/db/src/logseq/db/frontend/rules.cljc index 7e2f34595..2d9490ae8 100644 --- a/deps/db/src/logseq/db/frontend/rules.cljc +++ b/deps/db/src/logseq/db/frontend/rules.cljc @@ -169,10 +169,12 @@ :page-property '[(page-property ?p ?prop ?val) - [?p :block/name] [?p ?prop ?pv] - (or [?pv :block/title ?val] - [?pv :property.value/content ?val]) + [?p :block/name] + (or + [?pv :block/title ?val] + [?pv :property.value/content ?val] + [(= ?pv ?val)]) [?prop-e :db/ident ?prop] [?prop-e :block/type "property"]] @@ -186,8 +188,10 @@ :property '[(property ?b ?prop ?val) [?b ?prop ?pv] - (or [?pv :block/title ?val] - [?pv :property.value/content ?val]) + (or + [?pv :block/title ?val] + [?pv :property.value/content ?val] + [(= ?pv ?val)]) [(missing? $ ?b :block/name)] [?prop-e :db/ident ?prop] [?prop-e :block/type "property"]] diff --git a/deps/db/src/logseq/db/sqlite/common_db.cljs b/deps/db/src/logseq/db/sqlite/common_db.cljs index dc3792399..8a6fb4c3e 100644 --- a/deps/db/src/logseq/db/sqlite/common_db.cljs +++ b/deps/db/src/logseq/db/sqlite/common_db.cljs @@ -256,8 +256,6 @@ _ (when db-graph? (reset! db-order/*max-key (db-order/get-max-order db))) schema (:schema db) - built-in-value (when-let [id (:db/id (:logseq.property/built-in? (d/entity db :logseq.class/Root)))] - (d/datoms db :eavt id)) idents (mapcat (fn [id] (when-let [e (d/entity db id)] (d/datoms db :eavt (:db/id e)))) @@ -269,8 +267,7 @@ all-pages (get-all-pages db) structured-datoms (when db-graph? (get-structured-datoms db)) - data (concat built-in-value - idents + data (concat idents all-pages structured-datoms favorites diff --git a/deps/db/src/logseq/db/sqlite/create_graph.cljs b/deps/db/src/logseq/db/sqlite/create_graph.cljs index 37cf9a48b..dc846580e 100644 --- a/deps/db/src/logseq/db/sqlite/create_graph.cljs +++ b/deps/db/src/logseq/db/sqlite/create_graph.cljs @@ -10,8 +10,8 @@ [logseq.db.frontend.schema :as db-schema] [logseq.db.sqlite.util :as sqlite-util])) -(defn- mark-block-as-built-in [block built-in-prop-value] - (assoc block :logseq.property/built-in? [:block/uuid (:block/uuid built-in-prop-value)])) +(defn- mark-block-as-built-in [block] + (assoc block :logseq.property/built-in? true)) (defn build-initial-properties* [built-in-properties] @@ -40,19 +40,13 @@ :logseq.property/built-in? built-in-property-schema {:title (name :logseq.property/built-in?)}) - built-in-prop-value (db-property-build/build-property-value-block - {:db/id [:block/uuid (:block/uuid built-in-property)]} - {:db/ident :logseq.property/built-in? - :block/schema built-in-property-schema} - true) mark-block-as-built-in' (fn [block] - (mark-block-as-built-in {:block/uuid (:block/uuid block)} built-in-prop-value)) + (mark-block-as-built-in {:block/uuid (:block/uuid block)})) properties (build-initial-properties* db-property/built-in-properties) ;; Tx order matters. built-in-property must come first as all properties depend on it. tx (concat [built-in-property] properties - [built-in-prop-value] - ;; Adding built-ins must come after initial properties and built-in-prop-value + ;; Adding built-ins must come after initial properties [(mark-block-as-built-in' built-in-property)] (map mark-block-as-built-in' properties) (keep #(when (= #{"closed value"} (:block/type %)) (mark-block-as-built-in' %)) @@ -62,8 +56,7 @@ (assert (string/starts-with? (str block-uuid) "00000002") m))) {:tx tx - :properties (filter #(contains? (:block/type %) "property") properties) - :built-in-prop-value built-in-prop-value})) + :properties (filter #(contains? (:block/type %) "property") properties)})) (defn kv "Creates a key-value pair tx with the key and value respectively stored under @@ -87,7 +80,7 @@ (vec conflicting-idents)) {:idents conflicting-idents})))) -(defn- build-initial-classes [db-ident->properties built-in-prop-value] +(defn- build-initial-classes [db-ident->properties] (map (fn [[db-ident {:keys [schema title]}]] (let [title' (or title (name db-ident))] @@ -105,8 +98,7 @@ :db/ident db-ident :block/uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident)} (seq properties) - (assoc :class/schema.properties properties)))) - built-in-prop-value))) + (assoc :class/schema.properties properties))))))) db-class/built-in-classes)) (defn build-db-initial-data @@ -133,11 +125,11 @@ :file/content "" :file/created-at (js/Date.) :file/last-modified-at (js/Date.)}] - {properties-tx :tx :keys [built-in-prop-value properties]} (build-initial-properties) + {properties-tx :tx :keys [properties]} (build-initial-properties) db-ident->properties (zipmap (map :db/ident properties) properties) - default-classes (build-initial-classes db-ident->properties built-in-prop-value) + default-classes (build-initial-classes db-ident->properties) default-pages (->> (map sqlite-util/build-new-page built-in-pages-names) - (map #(mark-block-as-built-in % built-in-prop-value))) + (map mark-block-as-built-in)) tx (vec (concat initial-data properties-tx default-classes initial-files default-pages))] (validate-tx-for-duplicate-idents tx) diff --git a/src/main/frontend/components/db_based/page.cljs b/src/main/frontend/components/db_based/page.cljs index 9d1691132..2bc2cd52a 100644 --- a/src/main/frontend/components/db_based/page.cljs +++ b/src/main/frontend/components/db_based/page.cljs @@ -25,7 +25,7 @@ configure-opts {:selected? false :page-configure? configure?} has-viewable-properties? (outliner-property/block-has-viewable-properties? page) - hide-properties? (db-property/property-value-content (:logseq.property/hide-properties? page))] + hide-properties? (:logseq.property/hide-properties? page)] (when (or configure? (and (not hide-properties?) has-viewable-properties?)) [:div.ls-page-properties {:class (util/classnames [{:no-properties (not has-viewable-properties?)}])} diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index 0e4186e78..5ec4f97b3 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/src/main/frontend/components/page_menu.cljs @@ -100,7 +100,7 @@ (when-not (or contents? config/publishing? (and db-based? - (db-property/property-value-content (:logseq.property/built-in? page)))) + (:logseq.property/built-in? page))) {:title (t :page/delete) :options {:on-click #(delete-page-confirm! page)}}) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index 03dfd6404..e7d41faeb 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -756,14 +756,12 @@ (property-value-date-picker block property value (merge opts {:editing? editing?})) :checkbox - (let [add-property! (fn [] - ( db-schema/version version-in-db) (let [db-based? (ldb/db-based-graph? @conn) - built-in-value (:db/id (get (d/entity db :logseq.class/Root) :logseq.property/built-in?)) updates (keep (fn [[v updates]] (when (and (< version-in-db v) (<= v db-schema/version)) updates)) @@ -94,7 +93,7 @@ (assert (str "DB migration: property already exists " k))))) (into {}) sqlite-create-graph/build-initial-properties* - (map (fn [b] (assoc b :logseq.property/built-in? built-in-value)))) + (map (fn [b] (assoc b :logseq.property/built-in? true)))) fixes (mapcat (fn [update] (when-let [fix (:fix update)]