mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
chore: rename :property/* to :logseq.property/*
This commit is contained in:
4
deps/db/script/create_graph/inferred.edn
vendored
4
deps/db/script/create_graph/inferred.edn
vendored
@@ -10,10 +10,10 @@
|
||||
:classes {:Movie {:build/schema-properties [:actor :comment]}
|
||||
:Meeting {:build/schema-properties [:attendee :duration]}}
|
||||
:properties
|
||||
{:actor {:property/type :node
|
||||
{:actor {:logseq.property/type :node
|
||||
:db/cardinality :many
|
||||
:build/schema-classes [:Person]}
|
||||
:attendee {:property/type :node
|
||||
:attendee {:logseq.property/type :node
|
||||
:db/cardinality :many
|
||||
:build/schema-classes [:Person]}}
|
||||
:pages-and-blocks
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
;; property default value
|
||||
(when (qualified-keyword? k)
|
||||
(when-let [property (entity-memoized db k)]
|
||||
(let [property-type (lookup-entity property :property/type nil)]
|
||||
(let [property-type (lookup-entity property :logseq.property/type nil)]
|
||||
(if (= :checkbox property-type)
|
||||
(lookup-entity property :logseq.property/scalar-default-value nil)
|
||||
(lookup-entity property :logseq.property/default-value nil)))))))))
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
(if (string? page)
|
||||
(string/starts-with? page "$$$")
|
||||
(when (or (map? page) (de/entity? page))
|
||||
(:property/hide? page))))))
|
||||
(:logseq.property/hide? page))))))
|
||||
|
||||
(defn object?
|
||||
[node]
|
||||
|
||||
40
deps/db/src/logseq/db/frontend/malli_schema.cljs
vendored
40
deps/db/src/logseq/db/frontend/malli_schema.cljs
vendored
@@ -87,11 +87,11 @@
|
||||
[db validate-fn [property property-val] & {:keys [new-closed-value?]}]
|
||||
;; For debugging
|
||||
;; (when (not (internal-ident? (:db/ident property))) (prn :validate-val (dissoc property :property/closed-values) property-val))
|
||||
(let [validate-fn' (if (db-property-type/property-types-with-db (:property/type property))
|
||||
(let [validate-fn' (if (db-property-type/property-types-with-db (:logseq.property/type property))
|
||||
(fn [value]
|
||||
(validate-fn db value {:new-closed-value? new-closed-value?}))
|
||||
validate-fn)
|
||||
validate-fn'' (if (and (db-property-type/closed-value-property-types (:property/type property))
|
||||
validate-fn'' (if (and (db-property-type/closed-value-property-types (:logseq.property/type property))
|
||||
;; new closed values aren't associated with the property yet
|
||||
(not new-closed-value?)
|
||||
(seq (:property/closed-values property)))
|
||||
@@ -121,7 +121,7 @@
|
||||
[property]
|
||||
;; use explicit call to be nbb compatible
|
||||
(let [closed-values (entity-plus/lookup-kv-then-entity property :property/closed-values)]
|
||||
(cond-> (select-keys property [:db/ident :db/valueType :db/cardinality :property/type])
|
||||
(cond-> (select-keys property [:db/ident :db/valueType :db/cardinality :logseq.property/type])
|
||||
(seq closed-values)
|
||||
(assoc :property/closed-values closed-values))))
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||
(assert (every? #(re-find #"^(block|logseq\.)" (namespace %)) db-property/db-attribute-properties)
|
||||
"All db-attribute idents start with an internal namespace")
|
||||
(assert (every? #(or (re-find #"^logseq\." %) (contains? #{"property"} %)) logseq-ident-namespaces)
|
||||
(assert (every? #(re-find #"^logseq\." %) logseq-ident-namespaces)
|
||||
"All logseq idents start with an internal namespace")
|
||||
|
||||
;; Main malli schemas
|
||||
@@ -212,7 +212,7 @@
|
||||
(def property-tuple
|
||||
"A tuple of a property map and a property value"
|
||||
(into
|
||||
[:multi {:dispatch #(-> % first :property/type)}]
|
||||
[:multi {:dispatch #(-> % first :logseq.property/type)}]
|
||||
(map (fn [[prop-type value-schema]]
|
||||
[prop-type
|
||||
(let [schema-fn (if (vector? value-schema) (last value-schema) value-schema)]
|
||||
@@ -268,7 +268,7 @@
|
||||
[:db/valueType {:optional true} [:enum :db.type/ref]]
|
||||
[:db/cardinality {:optional true} [:enum :db.cardinality/many :db.cardinality/one]]
|
||||
[:block/order {:optional true} block-order]
|
||||
[:property/classes {:optional true} [:set :int]]])
|
||||
[:logseq.property/classes {:optional true} [:set :int]]])
|
||||
|
||||
(def normal-page
|
||||
(vec
|
||||
@@ -289,18 +289,18 @@
|
||||
|
||||
(def property-common-schema-attrs
|
||||
"Property :schema attributes common to all properties"
|
||||
[[:property/hide? {:optional true} :boolean]
|
||||
[:property/public? {:optional true} :boolean]
|
||||
[:property/ui-position {:optional true} [:enum :properties :block-left :block-right :block-below]]])
|
||||
[[:logseq.property/hide? {:optional true} :boolean]
|
||||
[:logseq.property/public? {:optional true} :boolean]
|
||||
[:logseq.property/ui-position {:optional true} [:enum :properties :block-left :block-right :block-below]]])
|
||||
|
||||
(def internal-property
|
||||
(vec
|
||||
(concat
|
||||
[:map
|
||||
[:db/ident internal-property-ident]
|
||||
[:property/type (apply vector :enum (into db-property-type/internal-built-in-property-types
|
||||
db-property-type/user-built-in-property-types))]
|
||||
[:property/view-context {:optional true} [:enum :page :block :class :property :never]]]
|
||||
[:logseq.property/type (apply vector :enum (into db-property-type/internal-built-in-property-types
|
||||
db-property-type/user-built-in-property-types))]
|
||||
[:logseq.property/view-context {:optional true} [:enum :page :block :class :property :never]]]
|
||||
property-common-schema-attrs
|
||||
property-attrs
|
||||
page-attrs
|
||||
@@ -312,7 +312,7 @@
|
||||
[:map
|
||||
;; class-ident allows for a class to be used as a property
|
||||
[:db/ident [:or user-property-ident class-ident]]
|
||||
[:property/type (apply vector :enum db-property-type/user-built-in-property-types)]]
|
||||
[:logseq.property/type (apply vector :enum db-property-type/user-built-in-property-types)]]
|
||||
property-common-schema-attrs
|
||||
property-attrs
|
||||
page-attrs
|
||||
@@ -331,7 +331,7 @@
|
||||
[:map
|
||||
;; pages from :default property uses this but closed-value pages don't
|
||||
[:block/order {:optional true} block-order]
|
||||
[:property/hide? [:enum true]]]
|
||||
[:logseq.property/hide? [:enum true]]]
|
||||
page-attrs
|
||||
page-or-block-attrs)))
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
(vec
|
||||
(concat
|
||||
[:map]
|
||||
[[:property/value [:or :string :double :boolean]]
|
||||
[[:logseq.property/value [:or :string :double :boolean]]
|
||||
[:logseq.property/created-from-property :int]]
|
||||
(remove #(#{:block/title :logseq.property/created-from-property} (first %)) block-attrs)
|
||||
page-or-block-attrs)))
|
||||
@@ -395,7 +395,7 @@
|
||||
[;; for built-in properties
|
||||
[:db/ident {:optional true} logseq-property-ident]
|
||||
[:block/title {:optional true} :string]
|
||||
[:property/value {:optional true} [:or :string :double]]
|
||||
[:logseq.property/value {:optional true} [:or :string :double]]
|
||||
[:logseq.property/created-from-property :int]
|
||||
[:block/closed-value-property {:optional true} [:set :int]]]
|
||||
(remove #(#{:block/title :logseq.property/created-from-property} (first %)) block-attrs)
|
||||
@@ -404,10 +404,10 @@
|
||||
(def closed-value-block
|
||||
"A closed value for a property with closed/allowed values"
|
||||
[:and closed-value-block*
|
||||
[:fn {:error/message ":block/title or :property/value required"
|
||||
:error/path [:property/value]}
|
||||
[:fn {:error/message ":block/title or :logseq.property/value required"
|
||||
:error/path [:logseq.property/value]}
|
||||
(fn [m]
|
||||
(or (:block/title m) (:property/value m)))]])
|
||||
(or (:block/title m) (:logseq.property/value m)))]])
|
||||
|
||||
(def normal-block
|
||||
"A block with content and no special type or tag behavior"
|
||||
@@ -485,7 +485,7 @@
|
||||
:closed-value-block
|
||||
|
||||
(and (:logseq.property/created-from-property d)
|
||||
(:property/value d))
|
||||
(:logseq.property/value d))
|
||||
:property-value-block
|
||||
|
||||
(:block/uuid d)
|
||||
|
||||
50
deps/db/src/logseq/db/frontend/property.cljs
vendored
50
deps/db/src/logseq/db/frontend/property.cljs
vendored
@@ -27,8 +27,8 @@
|
||||
block-id
|
||||
(or (:db/id property) {:db/ident (:db/ident property)}))
|
||||
:block/order (db-order/gen-key)}
|
||||
(if (db-property-type/property-value-content? (:property/type property) property)
|
||||
{:property/value value}
|
||||
(if (db-property-type/property-value-content? (:logseq.property/type property) property)
|
||||
{:logseq.property/value value}
|
||||
{:block/title value}))
|
||||
common-util/block-with-timestamps)))
|
||||
|
||||
@@ -58,34 +58,34 @@
|
||||
(apply
|
||||
ordered-map
|
||||
(defkeywords
|
||||
:property/type {:title "Property type"
|
||||
:logseq.property/type {:title "Property type"
|
||||
:schema {:type :keyword
|
||||
:hide? true}}
|
||||
:property/hide? {:title "Hide this property"
|
||||
:logseq.property/hide? {:title "Hide this property"
|
||||
:schema {:type :checkbox
|
||||
:hide? true}}
|
||||
:property/public? {:title "Property public?"
|
||||
:logseq.property/public? {:title "Property public?"
|
||||
:schema {:type :checkbox
|
||||
:hide? true}}
|
||||
:property/view-context {:title "Property view context"
|
||||
:logseq.property/view-context {:title "Property view context"
|
||||
:schema {:type :keyword
|
||||
:hide? true}}
|
||||
:property/ui-position {:title "Property position"
|
||||
:logseq.property/ui-position {:title "Property position"
|
||||
:schema {:type :keyword
|
||||
:hide? true}}
|
||||
:property/classes
|
||||
:logseq.property/classes
|
||||
{:title "Property classes"
|
||||
:schema {:type :entity
|
||||
:cardinality :many
|
||||
:public? false
|
||||
:hide? true}}
|
||||
:property/value
|
||||
:logseq.property/value
|
||||
{:title "Property value"
|
||||
:schema {:type :any
|
||||
:public? false
|
||||
:hide? true}}
|
||||
|
||||
:block/alias {:title "Alias"
|
||||
:block/alias {:title "Alias"
|
||||
:attribute :block/alias
|
||||
:schema {:type :page
|
||||
:cardinality :many
|
||||
@@ -278,20 +278,6 @@
|
||||
{:type :string
|
||||
:public? false}}
|
||||
|
||||
;; TODO: should we replace block/journal-day with those separate props?
|
||||
;; :logseq.property.journal/year {:title "Journal year"
|
||||
;; :schema
|
||||
;; {:type :raw-number
|
||||
;; :public? false}}
|
||||
;; :logseq.property.journal/month {:title "Journal month"
|
||||
;; :schema
|
||||
;; {:type :raw-number
|
||||
;; :public? false}}
|
||||
;; :logseq.property.journal/day {:title "Journal day"
|
||||
;; :schema
|
||||
;; {:type :raw-number
|
||||
;; :public? false}}
|
||||
|
||||
:logseq.property/choice-checkbox-state
|
||||
{:title "Choice checkbox state"
|
||||
:schema {:type :checkbox
|
||||
@@ -366,9 +352,9 @@
|
||||
{:title "Recur frequency"
|
||||
:schema schema
|
||||
:properties (let [block {:db/ident :logseq.task/recur-frequency
|
||||
:property/type :number}
|
||||
:logseq.property/type :number}
|
||||
property {:db/ident :logseq.property/default-value
|
||||
:property/type :number}
|
||||
:logseq.property/type :number}
|
||||
default-value (assoc (build-property-value-block block property 1) :db/id -1)]
|
||||
{:logseq.property/hide-empty-value true
|
||||
:logseq.property/default-value default-value})
|
||||
@@ -623,7 +609,7 @@
|
||||
"logseq.property.attribute"
|
||||
"logseq.property.journal" "logseq.property.class" "logseq.property.view"
|
||||
"logseq.property.user" "logseq.property.history"
|
||||
"property"})
|
||||
"logseq.property"})
|
||||
|
||||
(defn logseq-property?
|
||||
"Determines if keyword is a logseq property"
|
||||
@@ -678,14 +664,14 @@
|
||||
"Gets content/value of a given closed value ent/map. Works for all closed value types"
|
||||
[ent]
|
||||
(or (:block/title ent)
|
||||
(:property/value ent)))
|
||||
(:logseq.property/value ent)))
|
||||
|
||||
(defn property-value-content
|
||||
"Given an entity, gets the content for the property value of a ref type
|
||||
property i.e. what the user sees. For page types the content is the page name"
|
||||
[ent]
|
||||
(or (:block/title ent)
|
||||
(:property/value ent)))
|
||||
(:logseq.property/value ent)))
|
||||
|
||||
(defn ref->property-value-content
|
||||
"Given a ref from a pulled query e.g. `{:db/id X}`, gets a readable name for
|
||||
@@ -752,9 +738,9 @@
|
||||
"Indicates whether built-in property can be seen and edited by users"
|
||||
[entity]
|
||||
;; No need to do :built-in? check yet since user properties can't set this
|
||||
(:property/public? entity))
|
||||
(:logseq.property/public? entity))
|
||||
|
||||
(defn get-property-schema
|
||||
[property-m]
|
||||
(select-keys property-m [:db/cardinality :property/type :property/hide?
|
||||
:property/public? :property/view-context :property/ui-position]))
|
||||
(select-keys property-m [:db/cardinality :logseq.property/type :logseq.property/hide?
|
||||
:logseq.property/p:logseq.property/view-c:logseq.property/ui-positionty/ui-position]))
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
property-id)
|
||||
:block/parent property-id}
|
||||
(if (db-property-type/property-value-content? block-type property)
|
||||
{:property/value value}
|
||||
{:logseq.property/value value}
|
||||
{:block/title value}))))
|
||||
|
||||
(defn build-closed-value-block
|
||||
|
||||
@@ -44,18 +44,18 @@
|
||||
|
||||
(def original-value-ref-property-types
|
||||
"Property value ref types where the refed entity stores its value in
|
||||
:property/value e.g. :number is stored as a number. new value-ref-property-types
|
||||
:logseq.property/value 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})
|
||||
|
||||
(def value-ref-property-types
|
||||
"Property value ref types where the refed entities either store their value in
|
||||
:property/value or :block/title (for :default)"
|
||||
:logseq.property/value or :block/title (for :default)"
|
||||
(into #{:default :url} original-value-ref-property-types))
|
||||
|
||||
(def user-ref-property-types
|
||||
"User ref types. Property values that users see are stored in either
|
||||
:property/value or :block/title. :block/title is for all the page related types"
|
||||
:logseq.property/value or :block/title. :block/title is for all the page related types"
|
||||
(into #{:date :node} value-ref-property-types))
|
||||
|
||||
(assert (set/subset? user-ref-property-types
|
||||
@@ -120,7 +120,7 @@
|
||||
(if new-closed-value?
|
||||
(number? id-or-value)
|
||||
(when-let [entity (d/entity db id-or-value)]
|
||||
(number? (:property/value entity)))))
|
||||
(number? (:logseq.property/value entity)))))
|
||||
|
||||
(defn- text-entity?
|
||||
[db s {:keys [new-closed-value?]}]
|
||||
@@ -206,9 +206,9 @@
|
||||
:else :default))
|
||||
|
||||
(defn property-value-content?
|
||||
"Whether property value should be stored in :property/value"
|
||||
"Whether property value should be stored in :logseq.property/value"
|
||||
[block-type property]
|
||||
(or
|
||||
(original-value-ref-property-types (:property/type property))
|
||||
(original-value-ref-property-types (:logseq.property/type property))
|
||||
(and (= (:db/ident property) :logseq.property/default-value)
|
||||
(original-value-ref-property-types block-type))))
|
||||
|
||||
22
deps/db/src/logseq/db/frontend/rules.cljc
vendored
22
deps/db/src/logseq/db/frontend/rules.cljc
vendored
@@ -178,7 +178,7 @@
|
||||
[?prop-e :db/valueType :db.type/ref]
|
||||
[?b ?prop ?pv]
|
||||
(or [?pv :block/title ?val]
|
||||
[?pv :property/value ?val])]]
|
||||
[?pv :logseq.property/value ?val])]]
|
||||
|
||||
:property-missing-value
|
||||
'[(property-missing-value ?b ?prop-e ?default-p ?default-v)
|
||||
@@ -202,7 +202,7 @@
|
||||
(property-missing-value ?b ?prop-e ?default-p ?default-v)
|
||||
(or
|
||||
[?default-v :block/title ?val]
|
||||
[?default-v :property/value ?val])]
|
||||
[?default-v :logseq.property/value ?val])]
|
||||
|
||||
:property-value
|
||||
'[[(property-value ?b ?prop-e ?val)
|
||||
@@ -242,8 +242,8 @@
|
||||
[?prop-e :block/tags :logseq.class/Property]
|
||||
(has-property-or-default-value? ?b ?prop)
|
||||
(or
|
||||
[(missing? $ ?prop-e :property/public?)]
|
||||
[?prop-e :property/public? true])]
|
||||
[(missing? $ ?prop-e :logseq.property/public?)]
|
||||
[?prop-e :logseq.property/public? true])]
|
||||
|
||||
;; Same as has-simple-query-property except it returns public and private properties like :block/title
|
||||
:has-private-simple-query-property
|
||||
@@ -259,8 +259,8 @@
|
||||
[?prop-e :db/ident ?prop]
|
||||
[?prop-e :block/tags :logseq.class/Property]
|
||||
(or
|
||||
[(missing? $ ?prop-e :property/public?)]
|
||||
[?prop-e :property/public? true])]
|
||||
[(missing? $ ?prop-e :logseq.property/public?)]
|
||||
[?prop-e :logseq.property/public? true])]
|
||||
|
||||
;; Checks if a property has a value for any features that are not simple queries
|
||||
:property
|
||||
@@ -268,8 +268,8 @@
|
||||
[?prop-e :db/ident ?prop]
|
||||
[?prop-e :block/tags :logseq.class/Property]
|
||||
(or
|
||||
[(missing? $ ?prop-e :property/public?)]
|
||||
[?prop-e :property/public? true])
|
||||
[(missing? $ ?prop-e :logseq.property/public?)]
|
||||
[?prop-e :logseq.property/public? true])
|
||||
[?b ?prop ?pv]
|
||||
(or
|
||||
;; non-ref value
|
||||
@@ -280,7 +280,7 @@
|
||||
(and
|
||||
[?prop-e :db/valueType :db.type/ref]
|
||||
(or [?pv :block/title ?val]
|
||||
[?pv :property/value ?val])))]
|
||||
[?pv :logseq.property/value ?val])))]
|
||||
|
||||
;; Checks if a property has a value for simple queries. Supports default values
|
||||
:simple-query-property
|
||||
@@ -288,8 +288,8 @@
|
||||
[?prop-e :db/ident ?prop]
|
||||
[?prop-e :block/tags :logseq.class/Property]
|
||||
(or
|
||||
[(missing? $ ?prop-e :property/public?)]
|
||||
[?prop-e :property/public? true])
|
||||
[(missing? $ ?prop-e :logseq.property/public?)]
|
||||
[?prop-e :logseq.property/public? true])
|
||||
(property-value ?b ?prop-e ?val)]
|
||||
|
||||
;; Same as property except it returns public and private properties like :block/title
|
||||
|
||||
20
deps/db/src/logseq/db/sqlite/build.cljs
vendored
20
deps/db/src/logseq/db/sqlite/build.cljs
vendored
@@ -87,19 +87,19 @@
|
||||
;; closed values are referenced by their :db/ident so no need to create values
|
||||
(not (get-in db-property/built-in-properties [k :closed-values])))
|
||||
(let [property-map {:db/ident k
|
||||
:property/type built-in-type}]
|
||||
:logseq.property/type built-in-type}]
|
||||
[property-map v])
|
||||
(when-let [built-in-type' (get (:build/properties-ref-types new-block) built-in-type)]
|
||||
(let [property-map {:db/ident k
|
||||
:property/type built-in-type'}]
|
||||
:logseq.property/type built-in-type'}]
|
||||
[property-map v])))
|
||||
(when (and (db-property-type/value-ref-property-types (get-in properties-config [k :property/type]))
|
||||
(when (and (db-property-type/value-ref-property-types (get-in properties-config [k :logseq.property/type]))
|
||||
;; TODO: Support translate-property-value without this hack
|
||||
(not (vector? v)))
|
||||
(let [prop-type (get-in properties-config [k :property/type])
|
||||
(let [prop-type (get-in properties-config [k :logseq.property/type])
|
||||
property-map {:db/ident (get-ident all-idents k)
|
||||
:original-property-id k
|
||||
:property/type prop-type}]
|
||||
:logseq.property/type prop-type}]
|
||||
[property-map v])))))
|
||||
(db-property-build/build-property-values-tx-m new-block)))
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
(when-let [props (not-empty (:build/properties prop-m))]
|
||||
(->block-properties (merge props (db-property-build/build-properties-with-ref-values pvalue-tx-m)) page-uuids all-idents))
|
||||
(when (seq schema-classes)
|
||||
{:property/classes
|
||||
{:logseq.property/classes
|
||||
(mapv #(hash-map :db/ident (get-ident all-idents %))
|
||||
schema-classes)})))
|
||||
true
|
||||
@@ -500,7 +500,7 @@
|
||||
:node
|
||||
(db-property-type/infer-property-type-from-value prop-value'))
|
||||
:default)]
|
||||
(cond-> {:property/type prop-type}
|
||||
(cond-> {:logseq.property/type prop-type}
|
||||
(coll? prop-value)
|
||||
(assoc :db/cardinality :many))))
|
||||
|
||||
@@ -539,8 +539,8 @@
|
||||
class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {}))
|
||||
;; Replace idents with db-ids to avoid any upsert issues
|
||||
properties-tx' (mapv (fn [m]
|
||||
(if (:property/classes m)
|
||||
(update m :property/classes
|
||||
(if (:logseq.property/classes m)
|
||||
(update m :logseq.property/classes
|
||||
(fn [cs]
|
||||
(mapv #(or (some->> (:db/ident %) class-ident->id (hash-map :db/id))
|
||||
(throw (ex-info (str "No :db/id found for :db/ident " (pr-str (:db/ident %))) {})))
|
||||
@@ -578,7 +578,7 @@
|
||||
Allows for outlines to be expressed to whatever depth
|
||||
* :build/properties - Defines properties on a block
|
||||
* :properties - This is a map to configure properties where the keys are property name keywords
|
||||
and the values are maps of datascript attributes e.g. `{:property/type :checkbox}`.
|
||||
and the values are maps of datascript attributes e.g. `{:logseq.property/type :checkbox}`.
|
||||
Additional keys available:
|
||||
* :build/properties - Define properties on a property page.
|
||||
* :build/closed-values - Define closed values with a vec of maps. A map contains keys :uuid, :value and :icon.
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
:block/name common-config/views-page-name
|
||||
:block/title common-config/views-page-name
|
||||
:block/tags [:logseq.class/Page]
|
||||
:property/hide? true
|
||||
:logseq.property/hide? true
|
||||
:logseq.property/built-in? true})
|
||||
(sqlite-util/block-with-timestamps
|
||||
{:block/uuid (common-uuid/gen-uuid)
|
||||
@@ -151,7 +151,7 @@
|
||||
:block/name common-config/favorites-page-name
|
||||
:block/title common-config/favorites-page-name
|
||||
:block/tags [:logseq.class/Page]
|
||||
:property/hide? true
|
||||
:logseq.property/hide? true
|
||||
:logseq.property/built-in? true})])
|
||||
|
||||
(defn build-db-initial-data
|
||||
|
||||
8
deps/db/src/logseq/db/sqlite/util.cljs
vendored
8
deps/db/src/logseq/db/sqlite/util.cljs
vendored
@@ -76,9 +76,9 @@
|
||||
(= k :cardinality)
|
||||
(assoc r :db/cardinality v)
|
||||
(= k :classes)
|
||||
(assoc r :property/classes v)
|
||||
(assoc r :logseq.property/classes v)
|
||||
(= k :position)
|
||||
(assoc r :property/ui-position v)
|
||||
(assoc r :logseq.property/ui-position v)
|
||||
:else
|
||||
(assoc r (keyword "property" k) v))))
|
||||
{}
|
||||
@@ -97,14 +97,14 @@
|
||||
(db-property/create-user-property-ident-from-name (name db-ident)))
|
||||
prop-name (or title (name db-ident'))
|
||||
prop-schema (schema->qualified-property-keyword prop-schema')
|
||||
prop-type (get prop-schema :property/type :default)]
|
||||
prop-type (get prop-schema :logseq.property/type :default)]
|
||||
(merge
|
||||
(dissoc prop-schema :db/cardinality)
|
||||
(block-with-timestamps
|
||||
(cond->
|
||||
{:db/ident db-ident'
|
||||
:block/tags #{:logseq.class/Property}
|
||||
:property/type prop-type
|
||||
: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)
|
||||
|
||||
12
deps/db/test/logseq/db/frontend/rules_test.cljs
vendored
12
deps/db/test/logseq/db/frontend/rules_test.cljs
vendored
@@ -28,8 +28,8 @@
|
||||
|
||||
(deftest has-property-rule
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:foo {:property/type :default}
|
||||
:foo2 {:property/type :default}}
|
||||
{:properties {:foo {:logseq.property/type :default}
|
||||
:foo2 {:logseq.property/type :default}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "Page1"
|
||||
:build/properties {:foo "bar"}}}]})]
|
||||
@@ -52,11 +52,11 @@
|
||||
|
||||
(deftest property-rule
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:foo {:property/type :default}
|
||||
:foo2 {:property/type :default}
|
||||
:number-many {:property/type :number
|
||||
{:properties {:foo {:logseq.property/type :default}
|
||||
:foo2 {:logseq.property/type :default}
|
||||
:number-many {:logseq.property/type :number
|
||||
:db/cardinality :many}
|
||||
:page-many {:property/type :node
|
||||
:page-many {:logseq.property/type :node
|
||||
:db/cardinality :many}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "Page1"
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
(testing ":url property"
|
||||
(sqlite-build/create-blocks
|
||||
conn
|
||||
{:properties {:url {:property/type :url}}
|
||||
{:properties {:url {:logseq.property/type :url}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/title "b1" :build/properties {:url "https://logseq.com"}}
|
||||
|
||||
8
deps/db/test/logseq/db_test.cljs
vendored
8
deps/db/test/logseq/db_test.cljs
vendored
@@ -55,8 +55,8 @@
|
||||
(deftest get-case-page
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties
|
||||
{:foo {:property/type :default}
|
||||
:Foo {:property/type :default}}
|
||||
{:foo {:logseq.property/type :default}
|
||||
:Foo {:logseq.property/type :default}}
|
||||
:classes {:movie {} :Movie {}}})]
|
||||
;; Case sensitive properties
|
||||
(is (= "foo" (:block/title (ldb/get-case-page @conn "foo"))))
|
||||
@@ -68,8 +68,8 @@
|
||||
(deftest page-exists
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties
|
||||
{:foo {:property/type :default}
|
||||
:Foo {:property/type :default}}
|
||||
{:foo {:logseq.property/type :default}
|
||||
:Foo {:logseq.property/type :default}}
|
||||
:classes {:movie {} :Movie {}}})]
|
||||
(is (= ["foo"]
|
||||
(map #(:block/title (d/entity @conn %)) (ldb/page-exists? @conn "foo" #{:logseq.class/Property})))
|
||||
|
||||
@@ -604,7 +604,7 @@
|
||||
;; closed values are referenced by their :db/ident so no need to create values
|
||||
(not (get-in db-property/built-in-properties [k :closed-values])))
|
||||
(let [property-map {:db/ident k
|
||||
:property/type built-in-type}]
|
||||
:logseq.property/type built-in-type}]
|
||||
[property-map v]))
|
||||
(when (db-property-type/value-ref-property-types (:type (get-schema-fn k)))
|
||||
(let [schema (get-schema-fn k)
|
||||
@@ -1169,7 +1169,7 @@
|
||||
{:title (name kw-name)})
|
||||
property-keys (filter (fn [k] (= "property" (namespace k))) (keys new-prop))]
|
||||
(assert existing-page-uuid)
|
||||
(merge (select-keys new-prop (into [:block/tags :db/ident :property/type :db/index :db/cardinality :db/valueType] property-keys))
|
||||
(merge (select-keys new-prop (into [:block/tags :db/ident :logseq.property/type :db/index :db/cardinality :db/valueType] property-keys))
|
||||
{:block/uuid existing-page-uuid})))
|
||||
(set/intersection new-properties (set (map keyword (keys existing-pages)))))
|
||||
;; Could do this only for existing pages but the added complexity isn't worth reducing the tx noise
|
||||
|
||||
@@ -230,24 +230,24 @@
|
||||
(remove #(db-malli-schema/internal-ident? (:db/ident %)))
|
||||
count))
|
||||
"Correct number of user properties")
|
||||
(is (= #{{:db/ident :user.property/prop-bool :property/type :checkbox}
|
||||
{:db/ident :user.property/prop-string :property/type :default}
|
||||
{:db/ident :user.property/prop-num :property/type :number}
|
||||
{:db/ident :user.property/sameas :property/type :url}
|
||||
{:db/ident :user.property/rangeincludes :property/type :node}
|
||||
{:db/ident :user.property/startedat :property/type :date}}
|
||||
(is (= #{{:db/ident :user.property/prop-bool :logseq.property/type :checkbox}
|
||||
{:db/ident :user.property/prop-string :logseq.property/type :default}
|
||||
{:db/ident :user.property/prop-num :logseq.property/type :number}
|
||||
{:db/ident :user.property/sameas :logseq.property/type :url}
|
||||
{:db/ident :user.property/rangeincludes :logseq.property/type :node}
|
||||
{:db/ident :user.property/startedat :logseq.property/type :date}}
|
||||
(->> @conn
|
||||
(d/q '[:find [(pull ?b [:db/ident :property/type]) ...]
|
||||
(d/q '[:find [(pull ?b [:db/ident :logseq.property/type]) ...]
|
||||
:where [?b :block/tags :logseq.class/Property]])
|
||||
(filter #(contains? #{:prop-bool :prop-string :prop-num :rangeincludes :sameas :startedat}
|
||||
(keyword (name (:db/ident %)))))
|
||||
set))
|
||||
"Main property types have correct inferred :type")
|
||||
(is (= :default
|
||||
(:property/type (d/entity @conn :user.property/description)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/description)))
|
||||
"Property value consisting of text and refs is inferred as :default")
|
||||
(is (= :url
|
||||
(:property/type (d/entity @conn :user.property/url)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/url)))
|
||||
"Property value with a macro correctly inferred as :url")
|
||||
|
||||
(is (= {:user.property/prop-bool true
|
||||
@@ -429,14 +429,14 @@
|
||||
|
||||
(testing "property :type changes"
|
||||
(is (= :node
|
||||
(:property/type (d/entity @conn :user.property/finishedat)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/finishedat)))
|
||||
":date property to :node value changes to :node")
|
||||
(is (= :node
|
||||
(:property/type (d/entity @conn :user.property/participants)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/participants)))
|
||||
":node property to :date value remains :node")
|
||||
|
||||
(is (= :default
|
||||
(:property/type (d/entity @conn :user.property/description)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/description)))
|
||||
":default property to :node (or any non :default value) remains :default")
|
||||
(is (= "[[Jakob]]"
|
||||
(:user.property/description (readable-properties @conn (db-test/find-block-by-content @conn #":default to :node"))))
|
||||
@@ -444,14 +444,14 @@
|
||||
|
||||
(testing "with changes to upstream/existing property value"
|
||||
(is (= :default
|
||||
(:property/type (d/entity @conn :user.property/duration)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/duration)))
|
||||
":number property to :default value changes to :default")
|
||||
(is (= "20"
|
||||
(:user.property/duration (readable-properties @conn (db-test/find-block-by-content @conn "existing :number to :default"))))
|
||||
"existing :number property value correctly saved as :default")
|
||||
|
||||
(is (= {:property/type :default :db/cardinality :db.cardinality/many}
|
||||
(select-keys (d/entity @conn :user.property/people) [:property/type :db/cardinality]))
|
||||
(is (= {:logseq.property/type :default :db/cardinality :db.cardinality/many}
|
||||
(select-keys (d/entity @conn :user.property/people) [:logseq.property/type :db/cardinality]))
|
||||
":node property to :default value changes to :default and keeps existing cardinality")
|
||||
(is (= #{"[[Jakob]] [[Gabriel]]"}
|
||||
(:user.property/people (readable-properties @conn (db-test/find-block-by-content @conn ":node people"))))
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
(keep (fn [id]
|
||||
(when-let [entity (d/entity db-after [:block/uuid id])]
|
||||
(let [from-property (:logseq.property/created-from-property entity)
|
||||
default? (= :default (:property/type from-property))
|
||||
default? (= :default (:logseq.property/type from-property))
|
||||
page? (ldb/page? entity)]
|
||||
(when-not (or page? (and from-property (not default?)))
|
||||
[(:db/id entity)
|
||||
@@ -68,7 +68,7 @@
|
||||
(let [*computed-ids (atom #{})
|
||||
blocks (remove (fn [block]
|
||||
(let [from-property (:logseq.property/created-from-property block)
|
||||
default? (= :default (:property/type from-property))]
|
||||
default? (= :default (:logseq.property/type from-property))]
|
||||
(and from-property (not default?))))
|
||||
blocks*)]
|
||||
(->>
|
||||
@@ -181,7 +181,7 @@
|
||||
(map :db/id v)
|
||||
|
||||
:else
|
||||
(let [datetime? (= :datetime (:property/type (d/entity db property)))]
|
||||
(let [datetime? (= :datetime (:logseq.property/type (d/entity db property)))]
|
||||
(cond
|
||||
(and datetime? (coll? v))
|
||||
(keep #(get-journal-day-from-long db %) v)
|
||||
|
||||
36
deps/outliner/src/logseq/outliner/property.cljs
vendored
36
deps/outliner/src/logseq/outliner/property.cljs
vendored
@@ -74,7 +74,7 @@
|
||||
|
||||
(defn ^:api convert-property-input-string
|
||||
[block-type property v-str]
|
||||
(let [schema-type (:property/type property)]
|
||||
(let [schema-type (:logseq.property/type property)]
|
||||
(if (and (or (= :number schema-type)
|
||||
(and (= (:db/ident property) :logseq.property/default-value)
|
||||
(= :number block-type)))
|
||||
@@ -84,11 +84,11 @@
|
||||
|
||||
(defn- update-datascript-schema
|
||||
[property schema]
|
||||
(let [type' (:property/type schema)
|
||||
(let [type' (:logseq.property/type schema)
|
||||
cardinality (:db/cardinality schema)
|
||||
ident (:db/ident property)
|
||||
cardinality (if (= cardinality :many) :db.cardinality/many :db.cardinality/one)
|
||||
old-type (:property/type property)
|
||||
old-type (:logseq.property/type property)
|
||||
old-ref-type? (db-property-type/user-ref-property-types old-type)
|
||||
ref-type? (db-property-type/user-ref-property-types type')]
|
||||
[(cond->
|
||||
@@ -121,9 +121,9 @@
|
||||
(conj (outliner-core/block-with-updated-at
|
||||
(merge {:db/ident db-ident}
|
||||
changed-property-attrs)))
|
||||
(or (not= (:property/type schema) (:property/type property))
|
||||
(or (not= (:logseq.property/type schema) (:logseq.property/type property))
|
||||
(and (:db/cardinality schema) (not= (:db/cardinality schema) (keyword (name (:db/cardinality property)))))
|
||||
(and (= :default (:property/type schema)) (not= :db.type/ref (:db/valueType property)))
|
||||
(and (= :default (:logseq.property/type schema)) (not= :db.type/ref (:db/valueType property)))
|
||||
(seq (:property/closed-values property)))
|
||||
(concat (update-datascript-schema property schema)))
|
||||
tx-data (concat property-tx-data
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
(defn validate-property-value
|
||||
[db property value]
|
||||
(let [property-type (:property/type property)
|
||||
(let [property-type (:logseq.property/type property)
|
||||
many? (= :db.cardinality/many (:db/cardinality property))
|
||||
schema (get-property-value-schema db property-type property)]
|
||||
(validate-property-value-aux schema value {:many? many?})))
|
||||
@@ -216,7 +216,7 @@
|
||||
(let [property (d/entity @conn property-id)
|
||||
block (when block-id (d/entity @conn block-id))
|
||||
_ (assert (some? property) (str "Property " property-id " doesn't exist yet"))
|
||||
value' (convert-property-input-string (:property/type block)
|
||||
value' (convert-property-input-string (:logseq.property/type block)
|
||||
property value)
|
||||
new-value-block (cond-> (db-property-build/build-property-value-block (or block property) property value')
|
||||
new-block-id
|
||||
@@ -225,7 +225,7 @@
|
||||
(let [property-id (:db/ident property)]
|
||||
(when (and property-id block)
|
||||
(when-let [block-id (:db/id (d/entity @conn [:block/uuid (:block/uuid new-value-block)]))]
|
||||
(raw-set-block-property! conn block property (:property/type property) block-id)))
|
||||
(raw-set-block-property! conn block property (:logseq.property/type property) block-id)))
|
||||
(:block/uuid new-value-block))))
|
||||
|
||||
(defn- get-property-value-eid
|
||||
@@ -236,7 +236,7 @@
|
||||
:where
|
||||
[?b ?property-id ?v]
|
||||
(or [?v :block/title ?raw-value]
|
||||
[?v :property/value ?raw-value])]
|
||||
[?v :logseq.property/value ?raw-value])]
|
||||
db
|
||||
property-id
|
||||
raw-value)))
|
||||
@@ -246,7 +246,7 @@
|
||||
[conn property-id v]
|
||||
(let [property (d/entity @conn property-id)
|
||||
closed-values? (seq (:property/closed-values property))
|
||||
default-type? (= :default (:property/type property))]
|
||||
default-type? (= :default (:logseq.property/type property))]
|
||||
(cond
|
||||
closed-values?
|
||||
(get-property-value-eid @conn property-id v)
|
||||
@@ -299,7 +299,7 @@
|
||||
:else
|
||||
(let [property (d/entity @conn property-id)
|
||||
_ (assert (some? property) (str "Property " property-id " doesn't exist yet"))
|
||||
property-type (get property :property/type :default)
|
||||
property-type (get property :logseq.property/type :default)
|
||||
new-value (if (db-property-type/all-ref-property-types property-type)
|
||||
(convert-ref-property-value conn property-id v property-type)
|
||||
v)
|
||||
@@ -322,7 +322,7 @@
|
||||
(if (number? v) (d/entity @conn v) v)
|
||||
(map #(d/entity @conn %) block-eids)))
|
||||
_ (assert (some? property) (str "Property " property-id " doesn't exist yet"))
|
||||
property-type (get property :property/type :default)
|
||||
property-type (get property :logseq.property/type :default)
|
||||
_ (assert (some? v) "Can't set a nil property value must be not nil")
|
||||
v' (if (db-property-type/value-ref-property-types property-type)
|
||||
(convert-ref-property-value conn property-id v property-type)
|
||||
@@ -465,19 +465,19 @@
|
||||
(defn- property-with-position?
|
||||
[db property-id block position]
|
||||
(let [property (entity-plus/entity-memoized db property-id)
|
||||
property-position (:property/ui-position property)]
|
||||
property-position (:logseq.property/ui-position property)]
|
||||
(and
|
||||
(= property-position position)
|
||||
(not (and (:logseq.property/hide-empty-value property)
|
||||
(nil? (get block property-id))))
|
||||
(not (:property/hide? property))
|
||||
(not (:logseq.property/hide? property))
|
||||
(not (and
|
||||
(= property-position :block-below)
|
||||
(nil? (get block property-id)))))))
|
||||
|
||||
(defn property-with-other-position?
|
||||
[property]
|
||||
(not (contains? #{:properties nil} (:property/ui-position property))))
|
||||
(not (contains? #{:properties nil} (:logseq.property/ui-position property))))
|
||||
|
||||
(defn get-block-positioned-properties
|
||||
[db eid position]
|
||||
@@ -503,8 +503,8 @@
|
||||
(merge
|
||||
{:block/uuid id
|
||||
:block/closed-value-property (:db/id property)}
|
||||
(if (db-property-type/property-value-content? (:property/type block) property)
|
||||
{:property/value resolved-value}
|
||||
(if (db-property-type/property-value-content? (:logseq.property/type block) property)
|
||||
{:logseq.property/value resolved-value}
|
||||
{:block/title resolved-value})))
|
||||
icon
|
||||
(assoc :logseq.property/icon icon))]
|
||||
@@ -526,7 +526,7 @@
|
||||
(assert (or (nil? id) (uuid? id)))
|
||||
(let [db @conn
|
||||
property (d/entity db property-id)
|
||||
property-type (:property/type property)]
|
||||
property-type (:logseq.property/type property)]
|
||||
(when (contains? db-property-type/closed-value-property-types property-type)
|
||||
(let [value' (if (string? value) (string/trim value) value)
|
||||
resolved-value (convert-property-input-string nil property value')
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
(let [conn (db-test/create-conn-with-blocks [])
|
||||
_ (outliner-property/upsert-property! conn nil {:type :number} {:property-name "num"})]
|
||||
(is (= :number
|
||||
(:property/type (d/entity @conn :user.property/num)))
|
||||
(:logseq.property/type (d/entity @conn :user.property/num)))
|
||||
"Creates property with property-name")))
|
||||
|
||||
(testing "Updates a property"
|
||||
(let [conn (db-test/create-conn-with-blocks {:properties {:num {:property/type :number}}})
|
||||
(let [conn (db-test/create-conn-with-blocks {:properties {:num {:logseq.property/type :number}}})
|
||||
_ (outliner-property/upsert-property! conn :user.property/num {:type :default :cardinality :many} {})]
|
||||
(is (db-property/many? (d/entity @conn :user.property/num)))))
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
(outliner-property/upsert-property! conn nil {} {:property-name "p1"})
|
||||
(outliner-property/upsert-property! conn nil {} {:property-name "p1"})
|
||||
|
||||
(is (= {:block/name "p1" :block/title "p1" :property/type :default}
|
||||
(select-keys (d/entity @conn :user.property/p1) [:block/name :block/title :property/type]))
|
||||
(is (= {:block/name "p1" :block/title "p1" :logseq.property/type :default}
|
||||
(select-keys (d/entity @conn :user.property/p1) [:block/name :block/title :logseq.property/type]))
|
||||
"Existing db/ident does not get modified")
|
||||
(is (= "p1"
|
||||
(:block/title (d/entity @conn :user.property/p1-1)))
|
||||
@@ -40,7 +40,7 @@
|
||||
(let [test-uuid (random-uuid)]
|
||||
(are [x y]
|
||||
(= (let [[schema-type value] x]
|
||||
(outliner-property/convert-property-input-string nil {:property/type schema-type} value)) y)
|
||||
(outliner-property/convert-property-input-string nil {:logseq.property/type schema-type} value)) y)
|
||||
[:number "1"] 1
|
||||
[:number "1.2"] 1.2
|
||||
[:url test-uuid] test-uuid
|
||||
@@ -210,7 +210,7 @@
|
||||
(deftest upsert-closed-value!
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:num {:build/closed-values [{:uuid (random-uuid) :value 2}]
|
||||
:property/type :number}}})]
|
||||
:logseq.property/type :number}}})]
|
||||
|
||||
(testing "Add non-number choice shouldn't work"
|
||||
(is
|
||||
@@ -228,13 +228,13 @@
|
||||
|
||||
(testing "Add choice successfully"
|
||||
(let [_ (outliner-property/upsert-closed-value! conn :user.property/num {:value 3})
|
||||
b (first (d/q '[:find [(pull ?b [*]) ...] :where [?b :property/value 3]] @conn))]
|
||||
b (first (d/q '[:find [(pull ?b [*]) ...] :where [?b :logseq.property/value 3]] @conn))]
|
||||
(is (ldb/closed-value? (d/entity @conn (:db/id b))))
|
||||
(is (= [2 3]
|
||||
(map db-property/closed-value-content (:block/_closed-value-property (d/entity @conn :user.property/num)))))))
|
||||
|
||||
(testing "Update choice successfully"
|
||||
(let [b (first (d/q '[:find [(pull ?b [*]) ...] :where [?b :property/value 2]] @conn))
|
||||
(let [b (first (d/q '[:find [(pull ?b [*]) ...] :where [?b :logseq.property/value 2]] @conn))
|
||||
_ (outliner-property/upsert-closed-value! conn :user.property/num {:id (:block/uuid b)
|
||||
:value 4
|
||||
:description "choice 4"})
|
||||
@@ -248,7 +248,7 @@
|
||||
conn (db-test/create-conn-with-blocks
|
||||
{:properties {:default {:build/closed-values [{:uuid closed-value-uuid :value "foo"}
|
||||
{:uuid used-closed-value-uuid :value "bar"}]
|
||||
:property/type :default}}
|
||||
:logseq.property/type :default}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/title "b1" :user.property/default [:block/uuid used-closed-value-uuid]}]}]})
|
||||
@@ -260,8 +260,8 @@
|
||||
(deftest class-add-property!
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:classes {:c1 {}}
|
||||
:properties {:p1 {:property/type :default}
|
||||
:p2 {:property/type :default}}})
|
||||
:properties {:p1 {:logseq.property/type :default}
|
||||
:p2 {:logseq.property/type :default}}})
|
||||
_ (outliner-property/class-add-property! conn :user.class/c1 :user.property/p1)
|
||||
_ (outliner-property/class-add-property! conn :user.class/c1 :user.property/p2)]
|
||||
(is (= [:user.property/p1 :user.property/p2]
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
(deftest validate-block-title-unique-for-properties
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:color {:property/type :default}
|
||||
:color2 {:property/type :default}}})]
|
||||
{:properties {:color {:logseq.property/type :default}
|
||||
:color2 {:logseq.property/type :default}}})]
|
||||
|
||||
(is (nil?
|
||||
(outliner-validate/validate-unique-by-name-tag-and-block-type
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
(deftest validate-parent-property
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:prop1 {:property/type :default}}
|
||||
{:properties {:prop1 {:logseq.property/type :default}}
|
||||
:classes {:Class1 {} :Class2 {}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "page1"}}
|
||||
|
||||
@@ -170,17 +170,17 @@
|
||||
:properties
|
||||
(->> db-property-type/user-built-in-property-types
|
||||
(mapcat #(cond-> (if (= :node %)
|
||||
[[% {:property/type % :build/schema-classes [:TestClass]}]
|
||||
[:node-without-classes {:property/type %}]]
|
||||
[[% {:property/type %}]])
|
||||
[[% {:logseq.property/type % :build/schema-classes [:TestClass]}]
|
||||
[:node-without-classes {:logseq.property/type %}]]
|
||||
[[% {:logseq.property/type %}]])
|
||||
(contains? db-property-type/cardinality-property-types %)
|
||||
(conj [(keyword (str (name %) "-many"))
|
||||
(cond-> {:property/type %
|
||||
(cond-> {:logseq.property/type %
|
||||
:db/cardinality :many}
|
||||
(= :node %)
|
||||
(assoc :build/schema-classes [:TestClass]))])))
|
||||
(into (mapv #(vector (keyword (str (name %) "-closed"))
|
||||
{:property/type %
|
||||
{:logseq.property/type %
|
||||
:build/closed-values (closed-values-config (keyword (str (name %) "-closed")))})
|
||||
[:default :url :number]))
|
||||
(into {}))}))
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
class-name (strip-schema-prefix (property-m "@id"))
|
||||
url (str "https://schema.org/" (get inverted-renamed-properties class-name class-name))]
|
||||
{(keyword (strip-schema-prefix (property-m "@id")))
|
||||
(cond-> {:property/type schema-type
|
||||
(cond-> {:logseq.property/type schema-type
|
||||
:build/properties (cond-> {:url url}
|
||||
(property-m "rdfs:comment")
|
||||
(assoc :logseq.property/description (get-comment-string (property-m "rdfs:comment") renamed-pages)))}
|
||||
@@ -259,8 +259,8 @@
|
||||
(apply merge
|
||||
(mapv #(->property-page % class-map options) select-properties))
|
||||
;; Have to update schema for now as validation doesn't take into account existing properties
|
||||
:logseq.property/description {:property/public? true
|
||||
:property/type :default
|
||||
:logseq.property/description {:logseq.property/public? true
|
||||
:logseq.property/type :default
|
||||
:build/properties {:url "https://schema.org/description"
|
||||
:logseq.property/description "A description of the item."}}))
|
||||
|
||||
@@ -364,7 +364,7 @@
|
||||
(let [ents (remove #(db-malli-schema/internal-ident? (:db/ident %))
|
||||
(d/q '[:find [(pull ?b [*
|
||||
{:logseq.property.class/properties [:block/title]}
|
||||
{:property/classes [:block/title]}
|
||||
{:logseq.property/classes [:block/title]}
|
||||
{:logseq.property/parent [:block/title]}
|
||||
{:block/tags [:block/title]}
|
||||
{:block/refs [:block/title]}]) ...]
|
||||
@@ -377,9 +377,9 @@
|
||||
(map (fn [m]
|
||||
(let [props (->> (db-property/properties m)
|
||||
(into {}))]
|
||||
(cond-> (select-keys m [:block/name :block/tags :block/title :property/type :db/cardinality :db/ident
|
||||
(cond-> (select-keys m [:block/name :block/tags :block/title :logseq.property/type :db/cardinality :db/ident
|
||||
:logseq.property.class/properties :logseq.property/parent
|
||||
:db/cardinality :property/classes :block/refs])
|
||||
:db/cardinality :logseq.property/classes :block/refs])
|
||||
(seq props)
|
||||
(assoc :block/properties (-> (update-keys props name)
|
||||
(dissoc "tags")
|
||||
@@ -391,8 +391,8 @@
|
||||
(update :logseq.property.class/properties #(set (map :block/title %)))
|
||||
(some? (:logseq.property/parent m))
|
||||
(update :logseq.property/parent :block/title)
|
||||
(seq (:property/classes m))
|
||||
(update :property/classes #(set (map :block/title %)))
|
||||
(seq (:logseq.property/classes m))
|
||||
(update :logseq.property/classes #(set (map :block/title %)))
|
||||
(seq (:block/tags m))
|
||||
(update :block/tags #(set (map :block/title %)))
|
||||
(seq (:block/refs m))
|
||||
|
||||
@@ -2349,7 +2349,7 @@
|
||||
[:span.w-full
|
||||
(text-block-title config block)
|
||||
(when-let [property (:logseq.property/created-from-property block)]
|
||||
(when-let [message (when (= :url (:property/type property))
|
||||
(when-let [message (when (= :url (:logseq.property/type property))
|
||||
(first (outliner-property/validate-property-value (db/get-db) property (:db/id block))))]
|
||||
(ui/tooltip
|
||||
(shui/button
|
||||
|
||||
@@ -685,7 +685,7 @@
|
||||
page' (db/entity repo [:block/uuid (:block/uuid page)])
|
||||
link (if (config/db-based-graph? repo)
|
||||
(some (fn [[k v]]
|
||||
(when (= :url (:property/type (db/entity repo k)))
|
||||
(when (= :url (:logseq.property/type (db/entity repo k)))
|
||||
(:block/title v)))
|
||||
(:block/properties page'))
|
||||
(some #(re-find editor-handler/url-regex (val %)) (:block/properties page')))]
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
:as opts}]
|
||||
(let [property-name (or (and *property-name @*property-name) (:block/title property))
|
||||
property-schema (or (and *property-schema @*property-schema)
|
||||
(select-keys property [:property/type]))
|
||||
(select-keys property [:logseq.property/type]))
|
||||
schema-types (->> (concat db-property-type/user-built-in-property-types
|
||||
(when built-in?
|
||||
db-property-type/internal-built-in-property-types))
|
||||
@@ -88,7 +88,7 @@
|
||||
:on-value-change
|
||||
(fn [v]
|
||||
(let [type (keyword (string/lower-case v))
|
||||
update-schema-fn #(assoc % :property/type type)]
|
||||
update-schema-fn #(assoc % :logseq.property/type type)]
|
||||
(when *property-schema
|
||||
(swap! *property-schema update-schema-fn))
|
||||
(let [schema (or (and *property-schema @*property-schema)
|
||||
@@ -102,7 +102,7 @@
|
||||
(p/do!
|
||||
(when *show-new-property-config?
|
||||
(reset! *show-new-property-config? false))
|
||||
(when (= (:property/type schema) :node) (reset! *show-class-select? true))
|
||||
(when (= (:logseq.property/type schema) :node) (reset! *show-class-select? true))
|
||||
(db-property-handler/upsert-property!
|
||||
(:db/ident property)
|
||||
schema
|
||||
@@ -128,8 +128,8 @@
|
||||
(pv/<create-new-block! block property "")))))))}
|
||||
|
||||
;; only set when in property configure modal
|
||||
(and *property-name (:property/type property-schema))
|
||||
(assoc :default-value (name (:property/type property-schema))))
|
||||
(and *property-name (:logseq.property/type property-schema))
|
||||
(assoc :default-value (name (:logseq.property/type property-schema))))
|
||||
(shui/select-trigger
|
||||
{:class "!px-2 !py-0 !h-8"}
|
||||
(shui/select-value
|
||||
@@ -187,7 +187,7 @@
|
||||
|
||||
(rum/defc property-icon
|
||||
[property property-type]
|
||||
(let [type (or (:property/type property) property-type :default)
|
||||
(let [type (or (:logseq.property/type property) property-type :default)
|
||||
ident (:db/ident property)
|
||||
icon (cond
|
||||
(= ident :block/tags)
|
||||
@@ -217,7 +217,7 @@
|
||||
(reset! *property property)
|
||||
(when property
|
||||
(let [add-class-property? (and (ldb/class? block) class-schema?)
|
||||
type (:property/type property)]
|
||||
type (:logseq.property/type property)]
|
||||
(cond
|
||||
add-class-property?
|
||||
(p/do!
|
||||
@@ -363,7 +363,7 @@
|
||||
(empty? types)
|
||||
#{:block}))
|
||||
exclude-properties (fn [m]
|
||||
(let [view-context (get m :property/view-context :all)]
|
||||
(let [view-context (get m :logseq.property/view-context :all)]
|
||||
(or (contains? #{:logseq.property/query} (:db/ident m))
|
||||
(and (not page?) (contains? #{:block/alias} (:db/ident m)))
|
||||
;; Filters out properties from being in wrong :view-context and :never view-contexts
|
||||
@@ -376,7 +376,7 @@
|
||||
(if property-key
|
||||
[:div.ls-property-add.gap-1.flex.flex-1.flex-row.items-center
|
||||
[:div.flex.flex-row.items-center.property-key.gap-1
|
||||
(when-not (:db/id property) (property-icon property (:property/type @*property-schema)))
|
||||
(when-not (:db/id property) (property-icon property (:logseq.property/type @*property-schema)))
|
||||
(if (:db/id property) ; property exists already
|
||||
(property-key-cp block property opts)
|
||||
[:div property-key])]
|
||||
@@ -449,7 +449,7 @@
|
||||
[block k v {:keys [inline-text page-cp sortable-opts] :as opts}]
|
||||
(when (keyword? k)
|
||||
(when-let [property (db/sub-block (:db/id (db/entity k)))]
|
||||
(let [type (get property :property/type :default)
|
||||
(let [type (get property :logseq.property/type :default)
|
||||
closed-values? (seq (:property/closed-values property))
|
||||
block? (and v
|
||||
(not closed-values?)
|
||||
@@ -629,7 +629,7 @@
|
||||
state-hide-empty-properties?
|
||||
(nil? (get block property-id))
|
||||
:else
|
||||
(boolean (:property/hide? property)))))
|
||||
(boolean (:logseq.property/hide? property)))))
|
||||
property-hide-f (cond
|
||||
config/publishing?
|
||||
;; Publishing is read only so hide all blank properties as they
|
||||
@@ -640,7 +640,7 @@
|
||||
state-hide-empty-properties?
|
||||
(fn [[property-id property-value]]
|
||||
;; User's selection takes precedence over config
|
||||
(if (:property/hide? (db/entity property-id))
|
||||
(if (:logseq.property/hide? (db/entity property-id))
|
||||
(hide-with-property-id property-id)
|
||||
(nil? property-value)))
|
||||
:else
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
(some-> (rum/deref *ref)
|
||||
(.click))))
|
||||
[default-open?])
|
||||
(let [schema-classes (:property/classes property)]
|
||||
(let [schema-classes (:logseq.property/classes property)]
|
||||
[:div.flex.flex-1.col-span-3
|
||||
(let [content-fn
|
||||
(fn [{:keys [id]}]
|
||||
@@ -129,7 +129,7 @@
|
||||
(toggle-fn)
|
||||
(p/let [result (<create-class-if-not-exists! value)
|
||||
value' (or result value)
|
||||
tx-data [[(if select? :db/add :db/retract) (:db/id property) :property/classes [:block/uuid value']]]
|
||||
tx-data [[(if select? :db/add :db/retract) (:db/id property) :logseq.property/classes [:block/uuid value']]]
|
||||
_ (db/transact! (state/get-current-repo) tx-data {:outliner-op :update-property})]
|
||||
(when-not multiple-choices? (toggle-fn)))))}]
|
||||
|
||||
@@ -337,7 +337,7 @@
|
||||
(shui/tabler-icon "dots" {:size 16})))
|
||||
(shui/dropdown-menu-content
|
||||
;; default choice
|
||||
(let [property-type (:property/type property)
|
||||
(let [property-type (:logseq.property/type property)
|
||||
property (db/sub-block (:db/id property))
|
||||
default-type? (contains? #{:default :number} property-type)
|
||||
default-value (when default-type? (:logseq.property/default-value property))
|
||||
@@ -440,7 +440,7 @@
|
||||
(shui/popup-show! (.-target e)
|
||||
(fn [{:keys [id]}]
|
||||
(let [opts {:toggle-fn (fn [] (shui/popup-hide! id))}
|
||||
values' (->> (if (contains? db-property-type/all-ref-property-types (:property/type property))
|
||||
values' (->> (if (contains? db-property-type/all-ref-property-types (:logseq.property/type property))
|
||||
(->> values
|
||||
(map db/entity)
|
||||
(remove (fn [e]
|
||||
@@ -506,7 +506,7 @@
|
||||
(when-let [v (some-> (.-target e) (.-dataset) (.-value))]
|
||||
(db-property-handler/set-block-property!
|
||||
(:db/id property)
|
||||
:property/ui-position
|
||||
:logseq.property/ui-position
|
||||
(keyword v))
|
||||
(set-sub-open! false)
|
||||
(restore-root-highlight-item! id)))
|
||||
@@ -552,7 +552,7 @@
|
||||
(p/do!
|
||||
(db-property-handler/set-block-property!
|
||||
(:db/id property)
|
||||
:property/type
|
||||
:logseq.property/type
|
||||
(keyword v))
|
||||
(set-sub-open! false)
|
||||
(restore-root-highlight-item! id))))
|
||||
@@ -571,7 +571,7 @@
|
||||
|
||||
(rum/defc default-value-subitem
|
||||
[property]
|
||||
(let [property-type (:property/type property)
|
||||
(let [property-type (:logseq.property/type property)
|
||||
option (if (= :checkbox property-type)
|
||||
(let [default-value (:logseq.property/scalar-default-value property)]
|
||||
{:icon :settings-2
|
||||
@@ -590,7 +590,7 @@
|
||||
"property: block entity"
|
||||
[property owner-block values {:keys [class-schema? debug?]}]
|
||||
(let [title (:block/title property)
|
||||
property-type (:property/type property)
|
||||
property-type (:logseq.property/type property)
|
||||
property-type-label' (some-> property-type (property-type-label))
|
||||
enable-closed-values? (contains? db-property-type/closed-value-property-types
|
||||
(or property-type :default))
|
||||
@@ -665,24 +665,24 @@
|
||||
(update-cardinality-fn))))})))
|
||||
|
||||
(when (not= :logseq.property/enable-history? (:db/ident property))
|
||||
(let [property-type (:property/type property)
|
||||
(let [property-type (:logseq.property/type property)
|
||||
group' (->> [(when (and (not (contains? #{:logseq.property/parent :logseq.property.class/properties} (:db/ident property)))
|
||||
(contains? #{:default :number :date :checkbox :node} property-type)
|
||||
(not
|
||||
(and (= :default property-type)
|
||||
(empty? (:property/closed-values property))
|
||||
(contains? #{nil :properties} (:property/ui-position property)))))
|
||||
(let [position (:property/ui-position property)]
|
||||
(contains? #{nil :properties} (:logseq.property/ui-position property)))))
|
||||
(let [position (:logseq.property/ui-position property)]
|
||||
(dropdown-editor-menuitem {:icon :float-left :title "UI position" :desc (some->> position (get position-labels) (:title))
|
||||
:item-props {:class "ui__position-trigger-item"}
|
||||
:disabled? config/publishing?
|
||||
:submenu-content (fn [ops] (ui-position-sub-pane property (assoc ops :ui-position position)))})))
|
||||
|
||||
(when (not (contains? #{:logseq.property/parent :logseq.property.class/properties} (:db/ident property)))
|
||||
(dropdown-editor-menuitem {:icon :eye-off :title "Hide by default" :toggle-checked? (boolean (:property/hide? property))
|
||||
(dropdown-editor-menuitem {:icon :eye-off :title "Hide by default" :toggle-checked? (boolean (:logseq.property/hide? property))
|
||||
:disabled? config/publishing?
|
||||
:on-toggle-checked-change #(db-property-handler/set-block-property! (:db/id property)
|
||||
:property/hide?
|
||||
:logseq.property/hide?
|
||||
%)}))
|
||||
(when (not (contains? #{:logseq.property/parent :logseq.property.class/properties} (:db/ident property)))
|
||||
(dropdown-editor-menuitem {:icon :eye-off :title "Hide empty value" :toggle-checked? (boolean (:logseq.property/hide-empty-value property))
|
||||
|
||||
@@ -112,17 +112,17 @@
|
||||
;; closed values
|
||||
(seq (:property/closed-values property))
|
||||
(and (= (:db/ident property) :logseq.property/default-value)
|
||||
(= (:property/type block) :number))))
|
||||
(= (:logseq.property/type block) :number))))
|
||||
|
||||
(defn <create-new-block!
|
||||
[block property value & {:keys [edit-block?]
|
||||
:or {edit-block? true}}]
|
||||
(when-not (or (:property/hide? property)
|
||||
(when-not (or (:logseq.property/hide? property)
|
||||
(= (:db/ident property) :logseq.property/default-value))
|
||||
(ui/hide-popups-until-preview-popup!)
|
||||
(shui/dialog-close!))
|
||||
(p/let [block
|
||||
(if (and (contains? #{:default :url} (:property/type property))
|
||||
(if (and (contains? #{:default :url} (:logseq.property/type property))
|
||||
(not (db-property/many? property)))
|
||||
(p/let [existing-value (get block (:db/ident property))
|
||||
default-value (:logseq.property/default-value property)
|
||||
@@ -169,8 +169,8 @@
|
||||
:db/valueType :db.type/ref
|
||||
:db/index true
|
||||
:block/tags :logseq.class/Property
|
||||
:property/type :node
|
||||
:property/classes (:db/id property)}]
|
||||
:logseq.property/type :node
|
||||
:logseq.property/classes (:db/id property)}]
|
||||
{:outliner-op :save-block}))
|
||||
|
||||
(defn <add-property!
|
||||
@@ -183,7 +183,7 @@
|
||||
class? (ldb/class? block)
|
||||
property (db/entity property-id)
|
||||
many? (db-property/many? property)
|
||||
checkbox? (= :checkbox (:property/type property))
|
||||
checkbox? (= :checkbox (:logseq.property/type property))
|
||||
blocks (get-operating-blocks block)]
|
||||
(assert (qualified-keyword? property-id) "property to add must be a keyword")
|
||||
(p/do!
|
||||
@@ -193,7 +193,7 @@
|
||||
(<set-class-as-property! repo property))
|
||||
(db-property-handler/class-add-property! (:db/id block) property-id))
|
||||
(let [block-ids (map :block/uuid blocks)]
|
||||
(if (and (db-property-type/all-ref-property-types (:property/type property))
|
||||
(if (and (db-property-type/all-ref-property-types (:logseq.property/type property))
|
||||
(string? property-value))
|
||||
(p/let [new-block (<create-new-block! block (db/entity property-id) property-value {:edit-block? false})]
|
||||
(when (seq (remove #{(:db/id block)} (map :db/id block)))
|
||||
@@ -254,7 +254,7 @@
|
||||
:logseq.task/scheduled-on-property)))))]
|
||||
(if (= :logseq.task/deadline (:db/ident property))
|
||||
[:div "Set as repeated task"]
|
||||
[:div "Repeat " (if (= :date (:property/type property)) "date" "datetime")])]]
|
||||
[:div "Repeat " (if (= :date (:logseq.property/type property)) "date" "datetime")])]]
|
||||
[:div.flex.flex-row.gap-2
|
||||
[:div.flex.text-muted-foreground.mr-4
|
||||
"Every"]
|
||||
@@ -496,7 +496,7 @@
|
||||
[block property value opts]
|
||||
(let [multiple-values? (db-property/many? property)
|
||||
repo (state/get-current-repo)
|
||||
datetime? (= :datetime (:property/type property))]
|
||||
datetime? (= :datetime (:logseq.property/type property))]
|
||||
(date-picker value
|
||||
(merge opts
|
||||
{:block block
|
||||
@@ -615,7 +615,7 @@
|
||||
result]
|
||||
(let [[refresh-count set-refresh-count!] (rum/use-state 0)
|
||||
repo (state/get-current-repo)
|
||||
classes (:property/classes property)
|
||||
classes (:logseq.property/classes property)
|
||||
tags? (= :block/tags (:db/ident property))
|
||||
alias? (= :block/alias (:db/ident property))
|
||||
tags-or-alias? (or tags? alias?)
|
||||
@@ -655,7 +655,7 @@
|
||||
distinct)
|
||||
|
||||
:else
|
||||
(let [property-type (:property/type property)]
|
||||
(let [property-type (:logseq.property/type property)]
|
||||
(if (empty? result)
|
||||
(let [v (get block (:db/ident property))]
|
||||
(remove #(= :logseq.property/empty-placeholder (:db/ident %))
|
||||
@@ -675,7 +675,7 @@
|
||||
options (map (fn [node]
|
||||
(let [id (or (:value node) (:db/id node))
|
||||
[header label] (if (integer? id)
|
||||
(let [node-title (if (seq (:property/classes property))
|
||||
(let [node-title (if (seq (:logseq.property/classes property))
|
||||
(:block/title node)
|
||||
(block-handler/block-unique-title node))
|
||||
title (subs node-title 0 256)
|
||||
@@ -686,7 +686,7 @@
|
||||
[:div.text-xs.opacity-70
|
||||
(breadcrumb {:search? true} (state/get-current-repo) (:block/uuid block) {})]))
|
||||
label [:div.flex.flex-row.items-center.gap-1
|
||||
(when-not (:property/classes property)
|
||||
(when-not (:logseq.property/classes property)
|
||||
(ui/icon icon {:size 14}))
|
||||
[:div title]]]
|
||||
[header label])
|
||||
@@ -781,7 +781,7 @@
|
||||
:built-in? false})]
|
||||
(set-result! result)))))
|
||||
repo (state/get-current-repo)
|
||||
classes (:property/classes property)
|
||||
classes (:logseq.property/classes property)
|
||||
non-root-classes (remove (fn [c] (= (:db/ident c) :logseq.class/Root)) classes)
|
||||
parent-property? (= (:db/ident property) :logseq.property/parent)]
|
||||
(when (and (not parent-property?) (seq non-root-classes))
|
||||
@@ -817,13 +817,13 @@
|
||||
values (rum/react *values)
|
||||
block (db/sub-block (:db/id block))]
|
||||
(when-not (= :loading values)
|
||||
(let [type (:property/type property)
|
||||
(let [type (:logseq.property/type property)
|
||||
closed-values? (seq (:property/closed-values property))
|
||||
ref-type? (db-property-type/all-ref-property-types type)
|
||||
items (if closed-values?
|
||||
(let [date? (and
|
||||
(= (:db/ident property) :logseq.task/recur-unit)
|
||||
(= :date (:property/type (:property opts))))
|
||||
(= :date (:logseq.property/type (:property opts))))
|
||||
values (cond->> (:property/closed-values property)
|
||||
date?
|
||||
(remove (fn [b] (contains? #{:logseq.task/recur-unit.minute :logseq.task/recur-unit.hour} (:db/ident b)))))]
|
||||
@@ -1030,7 +1030,7 @@
|
||||
(when (:editing? opts)
|
||||
(.click (rum/deref *el))))
|
||||
[(:editing? opts)])
|
||||
(let [type (:property/type property)
|
||||
(let [type (:logseq.property/type property)
|
||||
select-opts' (assoc select-opts :multiple-choices? false)
|
||||
popup-content (fn content-fn [_]
|
||||
[:div.property-select
|
||||
@@ -1072,7 +1072,7 @@
|
||||
(let [multiple-values? (db-property/many? property)
|
||||
class (str (when-not row? "flex flex-1 ")
|
||||
(when multiple-values? "property-value-content"))
|
||||
type (:property/type property)
|
||||
type (:logseq.property/type property)
|
||||
text-ref-type? (db-property-type/text-ref-property-types type)]
|
||||
[:div.cursor-text
|
||||
{:id (or dom-id (random-uuid))
|
||||
@@ -1099,7 +1099,7 @@
|
||||
[state block property value* {:keys [container-id editing? on-chosen]
|
||||
:as opts}]
|
||||
(let [property (model/sub-block (:db/id property))
|
||||
type (:property/type property)
|
||||
type (:logseq.property/type property)
|
||||
editing? (or editing?
|
||||
(and (state/sub-editing? [container-id (:block/uuid block)])
|
||||
(= (:db/id property) (:db/id (:property (state/get-editor-action-data))))))
|
||||
@@ -1160,7 +1160,7 @@
|
||||
|
||||
(rum/defc multiple-values-inner
|
||||
[block property v {:keys [on-chosen editing?] :as opts}]
|
||||
(let [type (:property/type property)
|
||||
(let [type (:logseq.property/type property)
|
||||
date? (= type :date)
|
||||
*el (rum/use-ref nil)
|
||||
items (cond->> (if (de/entity? v) #{v} v)
|
||||
@@ -1238,7 +1238,7 @@
|
||||
:properties-cp :properties-cp})
|
||||
dom-id (str "ls-property-" (:db/id block) "-" (:db/id property))
|
||||
editor-id (str dom-id "-editor")
|
||||
type (:property/type property)
|
||||
type (:logseq.property/type property)
|
||||
multiple-values? (db-property/many? property)
|
||||
v (get block (:db/ident property))
|
||||
v (cond
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
(rum/defc property-value-select
|
||||
[repo *property *private-property? *find *tree opts loc]
|
||||
(let [db-graph? (sqlite-util/db-based-graph? repo)
|
||||
property-type (when db-graph? (:property/type (db/entity repo @*property)))
|
||||
property-type (when db-graph? (:logseq.property/type (db/entity repo @*property)))
|
||||
ref-property? (and db-graph? (contains? db-property-type/all-ref-property-types property-type))
|
||||
[values set-values!] (rum/use-state nil)]
|
||||
(hooks/use-effect!
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
(defn- get-property-value-for-search
|
||||
[block property]
|
||||
(let [type (:property/type property)
|
||||
(let [type (:logseq.property/type property)
|
||||
many? (= :db.cardinality/many (get property :db/cardinality))
|
||||
number-type? (= :number type)
|
||||
v (get block (:db/ident property))
|
||||
@@ -194,7 +194,7 @@
|
||||
:logseq.property/created-from-property}
|
||||
ident)
|
||||
(and with-object-name? (= :block/title ident))
|
||||
(contains? #{:map :entity} (:property/type property)))
|
||||
(contains? #{:map :entity} (:logseq.property/type property)))
|
||||
(let [property (if (de/entity? property)
|
||||
property
|
||||
(or (merge (db/entity ident) property) property)) ; otherwise, :cell/:header/etc. will be removed
|
||||
@@ -555,7 +555,7 @@
|
||||
(defn datetime-property?
|
||||
[property]
|
||||
(or
|
||||
(= :datetime (:property/type property))
|
||||
(= :datetime (:logseq.property/type property))
|
||||
(contains? #{:block/created-at :block/updated-at} (:db/ident property))))
|
||||
|
||||
(def timestamp-options
|
||||
@@ -608,7 +608,7 @@
|
||||
property (db/entity id)
|
||||
internal-property {:db/ident (:id column)
|
||||
:block/title (:name column)
|
||||
:property/type (:type column)}]
|
||||
:logseq.property/type (:type column)}]
|
||||
(if (or property
|
||||
(= :db.cardinality/many (:db/cardinality (get schema id)))
|
||||
(not= (:type column) :string))
|
||||
@@ -631,7 +631,7 @@
|
||||
(let [filters' (conj filters [(:db/ident property) :after value])]
|
||||
(set-filters! filters')))})
|
||||
property
|
||||
(if (= :checkbox (:property/type property))
|
||||
(if (= :checkbox (:logseq.property/type property))
|
||||
(let [items [{:value true :label "true"}
|
||||
{:value false :label "false"}]]
|
||||
(merge option
|
||||
@@ -694,7 +694,7 @@
|
||||
[:before :after]
|
||||
(concat
|
||||
[:is :is-not]
|
||||
(case (:property/type property)
|
||||
(case (:logseq.property/type property)
|
||||
(:default :url :node)
|
||||
[:text-contains :text-not-contains]
|
||||
(:date)
|
||||
@@ -787,7 +787,7 @@
|
||||
|
||||
(rum/defc filter-value-select < rum/static
|
||||
[{:keys [data-fns] :as table} property value operator idx]
|
||||
(let [type (:property/type property)
|
||||
(let [type (:logseq.property/type property)
|
||||
items (cond
|
||||
(contains? #{:before :after} operator)
|
||||
timestamp-options
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
[?b ?property-id ?vid]
|
||||
[(not= ?vid :logseq.property/empty-placeholder)]
|
||||
(or
|
||||
[?vid :property/value ?value]
|
||||
[?vid :logseq.property/value ?value]
|
||||
[?vid :block/title ?value])]
|
||||
property-id
|
||||
value)]
|
||||
|
||||
@@ -303,7 +303,7 @@
|
||||
(subs v' 1)
|
||||
(or (page-ref/get-page-name v') v'))
|
||||
;; Convert number pages to string
|
||||
(and (double? v) (= :node (:property/type (db-utils/entity k))))
|
||||
(and (double? v) (= :node (:logseq.property/type (db-utils/entity k))))
|
||||
(str v)
|
||||
:else
|
||||
v')))
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
(->> properties
|
||||
(keep (fn [[k v]]
|
||||
;; Don't inject hidden props like created-from-property
|
||||
(when-not (:property/hide? (db/entity repo k))
|
||||
(when-not (:logseq.property/hide? (db/entity repo k))
|
||||
[k
|
||||
(if (:db/id v)
|
||||
;; Can't use db-property-util/lookup b/c vals aren't entities
|
||||
|
||||
@@ -26,4 +26,4 @@
|
||||
(remove ldb/hidden?)
|
||||
(remove (fn [e]
|
||||
(and (ldb/property? e)
|
||||
(true? (:property/hide? e)))))))
|
||||
(true? (:logseq.property/hide? e)))))))
|
||||
|
||||
@@ -2738,7 +2738,7 @@
|
||||
(cursor/move-cursor-to-start input)
|
||||
|
||||
(and property? right? (cursor/end? input)
|
||||
(or (not= (:property/type block) :default)
|
||||
(or (not= (:logseq.property/type block) :default)
|
||||
(seq (:property/closed-values block))))
|
||||
(let [pair (util/rec-get-node input "property-pair")
|
||||
jtrigger (when pair (dom/sel1 pair ".property-value-container .jtrigger"))]
|
||||
@@ -3472,7 +3472,7 @@
|
||||
(concat class-properties)
|
||||
(remove (fn [e] (db-property/db-attribute-properties (:db/ident e))))
|
||||
(remove outliner-property/property-with-other-position?)
|
||||
(remove (fn [e] (:property/hide? e)))
|
||||
(remove (fn [e] (:logseq.property/hide? e)))
|
||||
(remove nil?))]
|
||||
(or (seq properties)
|
||||
(ldb/class-instance? (entity-plus/entity-memoized db :logseq.class/Query) block))))
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
(or
|
||||
(let [p (:logseq.task/recur-status-property entity)
|
||||
choices (:property/closed-values p)
|
||||
checkbox? (= :checkbox (:property/type p))]
|
||||
checkbox? (= :checkbox (:logseq.property/type p))]
|
||||
(if checkbox?
|
||||
true
|
||||
(some (fn [choice]
|
||||
@@ -54,7 +54,7 @@
|
||||
(or
|
||||
(let [p (:logseq.task/recur-status-property entity)
|
||||
choices (:property/closed-values p)
|
||||
checkbox? (= :checkbox (:property/type p))]
|
||||
checkbox? (= :checkbox (:logseq.property/type p))]
|
||||
(if checkbox?
|
||||
false
|
||||
(some (fn [choice]
|
||||
@@ -71,7 +71,7 @@
|
||||
value' (get-value entity property value)]
|
||||
(when-let [property-entity (d/entity db property')]
|
||||
(let [value-matches? (fn [datom-value]
|
||||
(let [ref? (contains? db-property-type/all-ref-property-types (:property/type property-entity))
|
||||
(let [ref? (contains? db-property-type/all-ref-property-types (:logseq.property/type property-entity))
|
||||
db-value (cond
|
||||
;; entity-conditions
|
||||
(nil? datom-value)
|
||||
@@ -155,7 +155,7 @@
|
||||
frequency (db-property/property-value-content (:logseq.task/recur-frequency entity))
|
||||
unit (:logseq.task/recur-unit entity)
|
||||
property (d/entity db property-ident)
|
||||
date? (= :date (:property/type property))
|
||||
date? (= :date (:logseq.property/type property))
|
||||
current-value (cond->
|
||||
(get entity property-ident)
|
||||
date?
|
||||
|
||||
@@ -551,7 +551,7 @@
|
||||
(:block/title entity))
|
||||
m (assoc schema-properties :db/id eid)
|
||||
m' (if hidden-page?
|
||||
(-> m (assoc :property/hide? true) (dissoc :property/public?))
|
||||
(-> m (assoc :logseq.property/hide? true) (dissoc :logseq.property/public?))
|
||||
m)]
|
||||
(concat
|
||||
[m'
|
||||
@@ -653,9 +653,9 @@
|
||||
:logseq.property.history/ref-value :logseq.property.history/scalar-value]}]
|
||||
[58 {:fix remove-duplicated-contents-page}]
|
||||
[59 {:properties [:logseq.property/created-by]}]
|
||||
[60 {:properties [:property/type :property/hide? :property/public? :property/view-context :property/ui-position]
|
||||
:fix (rename-properties {:property/schema.classes :property/classes
|
||||
:property.value/content :property/value})}]
|
||||
[60 {:properties [:logseq.property/type :logseq.property/hide? :logseq.property/public? :logseq.property/view-context :logseq.property/ui-position]
|
||||
:fix (rename-properties {:property/schema.classes :logseq.property/classes
|
||||
:property.value/content :logseq.property/value})}]
|
||||
[61 {:fix remove-block-schema}]])
|
||||
|
||||
(let [max-schema-version (apply max (map first schema-version->updates))]
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
(def ^:private watched-attrs
|
||||
#{:block/title :block/created-at :block/updated-at :block/alias
|
||||
:block/tags :block/link :block/journal-day
|
||||
:property/classes :property/value
|
||||
:logseq.property/classes :logseq.property/value
|
||||
:db/index :db/valueType :db/cardinality})
|
||||
|
||||
(def ^:private watched-attr-ns
|
||||
|
||||
@@ -370,8 +370,8 @@ so need to pull earlier remote-data from websocket."})
|
||||
:block/tags
|
||||
:block/link
|
||||
:block/journal-day
|
||||
:property/classes
|
||||
:property/value})
|
||||
:logseq.property/classes
|
||||
:logseq.property/value})
|
||||
|
||||
(def ^:private watched-attr-ns
|
||||
(conj db-property/logseq-property-namespaces "logseq.class"))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -56,7 +56,7 @@
|
||||
|
||||
(deftest get-classes-with-property-test
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:prop1 {:property/type :default}}
|
||||
{:properties {:prop1 {:logseq.property/type :default}}
|
||||
:classes
|
||||
{:Class1 {:build/schema-properties [:prop1]}
|
||||
:Class2 {:build/schema-properties [:prop1]}}})
|
||||
|
||||
@@ -183,7 +183,7 @@ prop-d:: [[nada]]"}])
|
||||
(deftest db-only-block-property-queries
|
||||
(load-test-files-for-db-graph
|
||||
{:properties
|
||||
{:zzz {:property/type :default
|
||||
{:zzz {:logseq.property/type :default
|
||||
:block/title "zzz name!"}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/title "page1"}
|
||||
@@ -208,7 +208,7 @@ prop-d:: [[nada]]"}])
|
||||
(deftest property-default-type-default-value-queries
|
||||
(load-test-files-for-db-graph
|
||||
{:properties
|
||||
{:default {:property/type :default
|
||||
{:default {:logseq.property/type :default
|
||||
:build/properties
|
||||
{:logseq.property/default-value "foo"}
|
||||
:build/properties-ref-types {:entity :number}}}
|
||||
@@ -235,7 +235,7 @@ prop-d:: [[nada]]"}])
|
||||
(deftest property-checkbox-type-default-value-queries
|
||||
(load-test-files-for-db-graph
|
||||
{:properties
|
||||
{:checkbox {:property/type :checkbox
|
||||
{:checkbox {:logseq.property/type :checkbox
|
||||
:build/properties
|
||||
{:logseq.property/scalar-default-value true}}}
|
||||
:classes {:Class1 {:build/schema-properties [:checkbox]}}
|
||||
@@ -261,7 +261,7 @@ prop-d:: [[nada]]"}])
|
||||
(deftest closed-property-default-value-queries
|
||||
(load-test-files-for-db-graph
|
||||
{:properties
|
||||
{:status {:property/type :default
|
||||
{:status {:logseq.property/type :default
|
||||
:build/closed-values
|
||||
[{:value "Todo" :uuid (random-uuid)}
|
||||
{:value "Doing" :uuid (random-uuid)}]
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
(deftest create-namespace-pages
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:properties {:property1 {:property/type :default}}
|
||||
{:properties {:property1 {:logseq.property/type :default}}
|
||||
:classes {:class1 {}}
|
||||
:pages-and-blocks [{:page {:block/title "page1"}}]})]
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
:db/valueType :db.type/ref
|
||||
:block/updated-at 1716880036491
|
||||
:block/created-at 1716880036491
|
||||
:property/type :number
|
||||
:logseq.property/type :number
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/ident :user.property/xxx,
|
||||
:block/type "property",
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
[:db/add 1000000 :db/valueType :db.type/ref]
|
||||
[:db/add 1000000 :block/updated-at 1716882111476]
|
||||
[:db/add 1000000 :block/created-at 1716882111476]
|
||||
[:db/add 1000000 :property/type :number]
|
||||
[:db/add 1000000 :logseq.property/type :number]
|
||||
[:db/add 1000000 :db/cardinality :db.cardinality/one]
|
||||
[:db/add 1000000 :db/ident :user.property/qqq]
|
||||
[:db/add 1000000 :block/tags :logseq.class/Property]
|
||||
@@ -71,7 +71,7 @@
|
||||
[:db/valueType "[\"~#'\",\"~:db.type/ref\"]"]
|
||||
[:block/updated-at "[\"~#'\",1716882111476]"]
|
||||
[:block/created-at "[\"~#'\",1716882111476]"]
|
||||
[:property/type "[\"~#'\",\"~:number\"]"]
|
||||
[:logseq.property/type "[\"~#'\",\"~:number\"]"]
|
||||
[:block/tags #uuid "00000002-1038-7670-4800-000000000000"]
|
||||
[:block/title "[\"~#'\",\"qqq\"]"]
|
||||
[:db/cardinality "[\"~#'\",\"~:db.cardinality/one\"]"]
|
||||
|
||||
Reference in New Issue
Block a user