wip: replace :block/schema with corresponding properties

This commit is contained in:
Tienson Qin
2025-01-06 11:41:38 +08:00
parent caa9d4cb30
commit 9b751126d2
26 changed files with 187 additions and 251 deletions

View File

@@ -2348,7 +2348,7 @@
[:span.w-full
(text-block-title config block)
(when-let [property (:logseq.property/created-from-property block)]
(when-let [message (when (= :url (get-in property [:block/schema :type]))
(when-let [message (when (= :url (:property/type property))
(first (outliner-property/validate-property-value (db/get-db) property (:db/id block))))]
(ui/tooltip
(shui/button

View File

@@ -10,6 +10,7 @@
[frontend.db.async :as db-async]
[frontend.db.model :as model]
[frontend.extensions.pdf.utils :as pdf-utils]
[frontend.handler.block :as block-handler]
[frontend.handler.command-palette :as cp-handler]
[frontend.handler.db-based.page :as db-page-handler]
[frontend.handler.editor :as editor-handler]
@@ -17,7 +18,6 @@
[frontend.handler.page :as page-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.whiteboard :as whiteboard-handler]
[frontend.handler.block :as block-handler]
[frontend.mixins :as mixins]
[frontend.modules.shortcut.core :as shortcut]
[frontend.modules.shortcut.utils :as shortcut-utils]
@@ -684,7 +684,7 @@
page' (db/entity repo [:block/uuid (:block/uuid page)])
link (if (config/db-based-graph? repo)
(some (fn [[k v]]
(when (= :url (get-in (db/entity repo k) [:block/schema :type]))
(when (= :url (:property/type (db/entity repo k)))
(:block/title v)))
(:block/properties page'))
(some #(re-find editor-handler/url-regex (val %)) (:block/properties page')))]

View File

@@ -182,7 +182,7 @@
(rum/defc property-icon
[property property-type]
(let [type (or (get-in property [:block/schema :type] property-type) :default)
(let [type (or (:property/type property) property-type :default)
ident (:db/ident property)
icon (cond
(= ident :block/tags)
@@ -212,7 +212,7 @@
(reset! *property property)
(when property
(let [add-class-property? (and (ldb/class? block) class-schema?)
type (get-in property [:block/schema :type])]
type (:property/type property)]
(cond
add-class-property?
(p/do!
@@ -285,9 +285,8 @@
{:on-chosen
(fn [_e icon]
(if icon
(db-property-handler/upsert-property! (:db/ident property)
(:block/schema property)
{:properties {:logseq.property/icon icon}})
(db-property-handler/set-block-property! (:db/id property)
:logseq.property/icon icon)
(db-property-handler/remove-block-property! (:db/id property)
(pu/get-pid :logseq.property/icon)))
(shui/popup-hide! id))
@@ -359,7 +358,7 @@
(empty? types)
#{:block}))
exclude-properties (fn [m]
(let [view-context (get-in m [:block/schema :view-context] :all)]
(let [view-context (get m :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
@@ -445,7 +444,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-in property [:block/schema :type] :default)
(let [type (get property :property/type :default)
closed-values? (seq (:property/closed-values property))
block? (and v
(not closed-values?)
@@ -625,7 +624,7 @@
state-hide-empty-properties?
(nil? (get block property-id))
:else
(boolean (:hide? (:block/schema property))))))
(boolean (:property/hide? property)))))
property-hide-f (cond
config/publishing?
;; Publishing is read only so hide all blank properties as they
@@ -636,7 +635,7 @@
state-hide-empty-properties?
(fn [[property-id property-value]]
;; User's selection takes precedence over config
(if (contains? (:block/schema (db/entity property-id)) :hide?)
(if (:property/hide? (db/entity property-id))
(hide-with-property-id property-id)
(nil? property-value)))
:else

View File

@@ -187,11 +187,9 @@
:variant (if dirty? :default :secondary)
:on-click (fn []
(set-saving! true)
(-> [(db-property-handler/upsert-property!
(:db/ident property)
(:block/schema property)
{:property-name title
:properties {:logseq.property/icon (:icon form-data)}})
(-> [(db-property-handler/set-block-property!
(:db/id property)
:logseq.property/icon (:icon form-data))
(when (not= description (:description (rum/deref *form-data)))
(set-property-description! property description))]
(p/all)
@@ -338,7 +336,7 @@
(shui/tabler-icon "dots" {:size 16})))
(shui/dropdown-menu-content
;; default choice
(let [property-type (get-in property [:block/schema :type])
(let [property-type (: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))
@@ -441,7 +439,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 (get-in property [:block/schema :type]))
values' (->> (if (contains? db-property-type/all-ref-property-types (:property/type property))
(->> values
(map db/entity)
(remove (fn [e]
@@ -499,10 +497,10 @@
[property {:keys [id set-sub-open! _position]}]
(let [handle-select! (fn [^js e]
(when-let [v (some-> (.-target e) (.-dataset) (.-value))]
(db-property-handler/upsert-property!
(:db/ident property)
(assoc (:block/schema property) :position (keyword v))
{:property-name (:block/title property)})
(db-property-handler/set-block-property!
(:db/id property)
:property/ui-position
(keyword v))
(set-sub-open! false)
(restore-root-highlight-item! id)))
item-props {:on-select handle-select!}]
@@ -545,10 +543,10 @@
(let [handle-select! (fn [^js e]
(when-let [v (some-> (.-target e) (.-dataset) (.-value))]
(p/do!
(db-property-handler/upsert-property!
(:db/ident property)
(assoc (:block/schema property) :type (keyword v))
{})
(db-property-handler/set-block-property!
(:db/id property)
:property/type
(keyword v))
(set-sub-open! false)
(restore-root-highlight-item! id))))
item-props {:on-select handle-select!}
@@ -566,7 +564,7 @@
(rum/defc default-value-subitem
[property]
(let [property-type (get-in property [:block/schema :type])
(let [property-type (:property/type property)
option (if (= :checkbox property-type)
(let [default-value (:logseq.property/scalar-default-value property)]
{:icon :settings-2
@@ -585,8 +583,7 @@
"property: block entity"
[property owner-block values {:keys [class-schema? debug?]}]
(let [title (:block/title property)
property-schema (:block/schema property)
property-type (get property-schema :type)
property-type (: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))
@@ -663,7 +660,8 @@
:on-toggle-checked-change
(fn []
(let [update-cardinality-fn #(db-property-handler/upsert-property! (:db/ident property)
(assoc property-schema :cardinality (if many? :one :many)) {})]
{:cardinality (if many? :one :many)}
{})]
;; Only show dialog for existing values as it can be reversed for unused properties
(if (and (seq values) (not many?))
(-> (shui/dialog-confirm!
@@ -672,24 +670,25 @@
(update-cardinality-fn))))})))
(when (not= :logseq.property/enable-history? (:db/ident property))
(let [property-type (get-in property [:block/schema :type])
(let [property-type (: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} (:position property-schema)))))
(let [position (:position property-schema)]
(contains? #{nil :properties} (:property/ui-position property)))))
(let [position (: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 :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 (:hide? property-schema))
(dropdown-editor-menuitem {:icon :eye-off :title "Hide by default" :toggle-checked? (boolean (:property/hide? property))
:disabled? config/publishing?
:on-toggle-checked-change #(db-property-handler/upsert-property! (:db/ident property)
(assoc property-schema :hide? %) {})}))
:on-toggle-checked-change #(db-property-handler/set-block-property! (:db/id property)
: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))
:disabled? config/publishing?

View File

@@ -111,17 +111,17 @@
;; closed values
(seq (:property/closed-values property))
(and (= (:db/ident property) :logseq.property/default-value)
(= (get-in block [:block/schema :type]) :number))))
(= (:property/type block) :number))))
(defn <create-new-block!
[block property value & {:keys [edit-block?]
:or {edit-block? true}}]
(when-not (or (get-in property [:block/schema :hide?])
(when-not (or (: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} (get-in property [:block/schema :type]))
(if (and (contains? #{:default :url} (:property/type property))
(not (db-property/many? property)))
(p/let [existing-value (get block (:db/ident property))
default-value (:logseq.property/default-value property)
@@ -168,8 +168,7 @@
:db/valueType :db.type/ref
:db/index true
:block/tags :logseq.class/Property
:block/schema (assoc (:block/schema property)
:type :node)
:property/type :node
:property/schema.classes (:db/id property)}]
{:outliner-op :save-block}))
@@ -183,7 +182,7 @@
class? (ldb/class? block)
property (db/entity property-id)
many? (db-property/many? property)
checkbox? (= :checkbox (get-in property [:block/schema :type]))
checkbox? (= :checkbox (:property/type property))
blocks (get-operating-blocks block)]
(assert (qualified-keyword? property-id) "property to add must be a keyword")
(p/do!
@@ -193,7 +192,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 (get-in property [:block/schema :type]))
(if (and (db-property-type/all-ref-property-types (: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)))
@@ -502,7 +501,7 @@
[block property value opts]
(let [multiple-values? (db-property/many? property)
repo (state/get-current-repo)
datetime? (= :datetime (get-in property [:block/schema :type]))]
datetime? (= :datetime (:property/type property))]
(date-picker value
(merge opts
{:block block
@@ -661,7 +660,7 @@
distinct)
:else
(let [property-type (get-in property [:block/schema :type])]
(let [property-type (:property/type property)]
(if (empty? result)
(let [v (get block (:db/ident property))]
(remove #(= :logseq.property/empty-placeholder (:db/ident %))
@@ -823,14 +822,13 @@
values (rum/react *values)
block (db/sub-block (:db/id block))]
(when-not (= :loading values)
(let [schema (:block/schema property)
type (:type schema)
(let [type (: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 (get-in (:property opts) [:block/schema :type])))
(= :date (: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)))))]
@@ -1037,8 +1035,7 @@
(when (:editing? opts)
(.click (rum/deref *el))))
[(:editing? opts)])
(let [schema (:block/schema property)
type (get schema :type :default)
(let [type (:property/type property)
select-opts' (assoc select-opts :multiple-choices? false)
popup-content (fn content-fn [_]
[:div.property-select
@@ -1077,11 +1074,10 @@
(defn- property-value-inner
[block property value {:keys [inline-text page-cp
dom-id row?]}]
(let [schema (:block/schema property)
multiple-values? (db-property/many? property)
(let [multiple-values? (db-property/many? property)
class (str (when-not row? "flex flex-1 ")
(when multiple-values? "property-value-content"))
type (:type schema)
type (:property/type property)
text-ref-type? (db-property-type/text-ref-property-types type)]
[:div.cursor-text
{:id (or dom-id (random-uuid))
@@ -1108,8 +1104,7 @@
[state block property value* {:keys [container-id editing? on-chosen]
:as opts}]
(let [property (model/sub-block (:db/id property))
schema (:block/schema property)
type (get schema :type :default)
type (: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))))))
@@ -1169,8 +1164,8 @@
(property-value-inner block property value opts)])))))
(rum/defc multiple-values-inner
[block property v {:keys [on-chosen editing?] :as opts} schema]
(let [type (get schema :type :default)
[block property v {:keys [on-chosen editing?] :as opts}]
(let [type (:property/type property)
date? (= type :date)
*el (rum/use-ref nil)
items (cond->> (if (de/entity? v) #{v} v)
@@ -1225,12 +1220,12 @@
(property-empty-text-value property opts))))]))))
(rum/defc multiple-values < rum/reactive db-mixins/query
[block property opts schema]
[block property opts]
(let [block (db/sub-block (:db/id block))
value (get block (:db/ident property))
value' (if (coll? value) value
(when (some? value) #{value}))]
(multiple-values-inner block property value' opts schema)))
(multiple-values-inner block property value' opts)))
(rum/defcs property-value < rum/reactive db-mixins/query
[state block property {:keys [show-tooltip?]
@@ -1248,8 +1243,7 @@
:properties-cp :properties-cp})
dom-id (str "ls-property-" (:db/id block) "-" (:db/id property))
editor-id (str dom-id "-editor")
schema (:block/schema property)
type (some-> schema (get :type :default))
type (:property/type property)
multiple-values? (db-property/many? property)
v (get block (:db/ident property))
v (cond
@@ -1277,7 +1271,7 @@
(property-normal-block-value block property v)
multiple-values?
(multiple-values block property opts schema)
(multiple-values block property opts)
:else
(let [parent? (= property-ident :logseq.property/parent)

View File

@@ -1,30 +1,30 @@
(ns frontend.components.query.builder
"DSL query builder."
(:require [frontend.date :as date]
[frontend.ui :as ui]
(:require [clojure.string :as string]
[frontend.components.select :as component-select]
[frontend.config :as config]
[frontend.date :as date]
[frontend.db :as db]
[frontend.db-mixins :as db-mixins]
[frontend.db.async :as db-async]
[frontend.db.model :as db-model]
[frontend.db.query-dsl :as query-dsl]
[frontend.handler.editor :as editor-handler]
[frontend.handler.query.builder :as query-builder]
[frontend.components.select :as component-select]
[frontend.state :as state]
[frontend.util :as util]
[logseq.shui.ui :as shui]
[frontend.mixins :as mixins]
[logseq.graph-parser.db :as gp-db]
[rum.core :as rum]
[clojure.string :as string]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[logseq.common.util :as common-util]
[logseq.common.util.page-ref :as page-ref]
[promesa.core :as p]
[frontend.config :as config]
[logseq.db :as ldb]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.property.type :as db-property-type]
[logseq.db.sqlite.util :as sqlite-util]
[frontend.db-mixins :as db-mixins]
[logseq.db :as ldb]))
[logseq.graph-parser.db :as gp-db]
[logseq.shui.ui :as shui]
[promesa.core :as p]
[rum.core :as rum]))
(rum/defc page-block-selector
[*find]
@@ -203,7 +203,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? (get-in (db/entity repo @*property) [:block/schema :type]))
property-type (when db-graph? (: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)]
(rum/use-effect!

View File

@@ -6,28 +6,28 @@
[clojure.set :as set]
[clojure.string :as string]
[datascript.impl.entity :as de]
[dommy.core :as dom]
[frontend.components.dnd :as dnd]
[frontend.components.property.value :as pv]
[frontend.components.select :as select]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.date :as date]
[frontend.db :as db]
[frontend.db-mixins :as db-mixins]
[frontend.handler.property :as property-handler]
[frontend.handler.ui :as ui-handler]
[frontend.mixins :as mixins]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[goog.dom :as gdom]
[dommy.core :as dom]
[logseq.db :as ldb]
[logseq.db.frontend.property :as db-property]
[logseq.db.frontend.property.type :as db-property-type]
[logseq.shui.ui :as shui]
[rum.core :as rum]
[frontend.mixins :as mixins]
[logseq.shui.table.core :as table-core]
[logseq.db :as ldb]
[frontend.config :as config]
[frontend.db-mixins :as db-mixins]))
[logseq.shui.ui :as shui]
[rum.core :as rum]))
(defn- get-latest-entity
[e]
@@ -117,7 +117,7 @@
(defn- get-property-value-for-search
[block property]
(let [type (get-in property [:block/schema :type])
(let [type (:property/type property)
many? (= :db.cardinality/many (get property :db/cardinality))
number-type? (= :number type)
v (get block (:db/ident property))
@@ -192,7 +192,7 @@
:logseq.property/created-from-property}
ident)
(and with-object-name? (= :block/title ident))
(contains? #{:map :entity} (get-in property [:block/schema :type])))
(contains? #{:map :entity} (:property/type property)))
(let [property (if (de/entity? property)
property
(or (merge (db/entity ident) property) property)) ; otherwise, :cell/:header/etc. will be removed
@@ -535,13 +535,6 @@
:on-click #(set-show-input! true)}
(ui/icon "search")))))
(comment
(defn- property-ref-type?
[property]
(let [schema (:block/schema property)
type (:type schema)]
(db-property-type/all-ref-property-types type))))
(defn- get-property-values
[rows property]
(let [property-ident (:db/ident property)
@@ -560,7 +553,7 @@
(defn datetime-property?
[property]
(or
(= :datetime (get-in property [:block/schema :type]))
(= :datetime (:property/type property))
(contains? #{:block/created-at :block/updated-at} (:db/ident property))))
(def timestamp-options
@@ -613,7 +606,7 @@
property (db/entity id)
internal-property {:db/ident (:id column)
:block/title (:name column)
:block/schema {:type (:type column)}}]
:property/type (:type column)}]
(if (or property
(= :db.cardinality/many (:db/cardinality (get schema id)))
(not= (:type column) :string))
@@ -636,7 +629,7 @@
(let [filters' (conj filters [(:db/ident property) :after value])]
(set-filters! filters')))})
property
(if (= :checkbox (get-in property [:block/schema :type]))
(if (= :checkbox (:property/type property))
(let [items [{:value true :label "true"}
{:value false :label "false"}]]
(merge option
@@ -699,7 +692,7 @@
[:before :after]
(concat
[:is :is-not]
(case (get-in property [:block/schema :type])
(case (:property/type property)
(:default :url :node)
[:text-contains :text-not-contains]
(:date)
@@ -792,7 +785,7 @@
(rum/defc filter-value-select < rum/static
[{:keys [data-fns] :as table} property value operator idx]
(let [type (get-in property [:block/schema :type])
(let [type (:property/type property)
items (cond
(contains? #{:before :after} operator)
timestamp-options

View File

@@ -6,20 +6,20 @@
[clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as walk]
[frontend.config :as config]
[frontend.date :as date]
[frontend.db.utils :as db-utils]
[frontend.db.model :as model]
[frontend.db.query-react :as query-react]
[logseq.db.frontend.rules :as rules]
[frontend.db.utils :as db-utils]
[frontend.state :as state]
[frontend.template :as template]
[logseq.graph-parser.text :as text]
[frontend.util :as util]
[frontend.util.text :as text-util]
[logseq.common.util :as common-util]
[logseq.common.util.date-time :as date-time-util]
[logseq.common.util.page-ref :as page-ref]
[logseq.common.util :as common-util]
[frontend.util.text :as text-util]
[frontend.util :as util]
[frontend.config :as config]
[frontend.state :as state]))
[logseq.db.frontend.rules :as rules]
[logseq.graph-parser.text :as text]))
;; Query fields:
@@ -303,7 +303,7 @@
(subs v' 1)
(or (page-ref/get-page-name v') v'))
;; Convert number pages to string
(and (double? v) (= :node (get-in (db-utils/entity k) [:block/schema :type])))
(and (double? v) (= :node (:property/type (db-utils/entity k))))
(str v)
:else
v')))

View File

@@ -1,20 +1,20 @@
(ns frontend.extensions.slide
(:require [rum.core :as rum]
[cljs-bean.core :as bean]
[frontend.loader :as loader]
[frontend.ui :as ui]
[frontend.context.i18n :refer [t]]
[frontend.config :as config]
[frontend.components.block :as block]
(:require [cljs-bean.core :as bean]
[clojure.string :as string]
[frontend.db-mixins :as db-mixins]
[frontend.components.block :as block]
[frontend.config :as config]
[frontend.context.i18n :refer [t]]
[frontend.db :as db]
[frontend.db-mixins :as db-mixins]
[frontend.db.conn :as conn]
[frontend.handler.db-based.property.util :as db-pu]
[frontend.loader :as loader]
[frontend.modules.outliner.tree :as outliner-tree]
[frontend.state :as state]
[frontend.handler.db-based.property.util :as db-pu]
[frontend.ui :as ui]
[logseq.db :as ldb]
[logseq.db.frontend.property :as db-property]
[frontend.db.conn :as conn]))
[rum.core :as rum]))
(defn loaded? []
js/window.Reveal)
@@ -28,7 +28,7 @@
(->> properties
(keep (fn [[k v]]
;; Don't inject hidden props like created-from-property
(when-not (:hide? (:block/schema (db/entity repo k)))
(when-not (:property/hide? (db/entity repo k))
[k
(if (:db/id v)
;; Can't use db-property-util/lookup b/c vals aren't entities

View File

@@ -26,4 +26,4 @@
(remove ldb/hidden?)
(remove (fn [e]
(and (ldb/property? e)
(true? (get-in e [:block/schema :hide?])))))))
(true? (:property/hide? e)))))))

View File

@@ -2735,7 +2735,7 @@
(cursor/move-cursor-to-start input)
(and property? right? (cursor/end? input)
(or (not= (get-in block [:block/schema :type]) :default)
(or (not= (: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"))]
@@ -3469,7 +3469,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] (:hide? (:block/schema e))))
(remove (fn [e] (:property/hide? e)))
(remove nil?))]
(or (seq properties)
(ldb/class-instance? (entity-plus/entity-memoized db :logseq.class/Query) block))))

View File

@@ -43,7 +43,7 @@
(or
(let [p (:logseq.task/recur-status-property entity)
choices (:property/closed-values p)
checkbox? (= :checkbox (get-in p [:block/schema :type]))]
checkbox? (= :checkbox (: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 (get-in p [:block/schema :type]))]
checkbox? (= :checkbox (: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 (:type (:block/schema property-entity)))
(let [ref? (contains? db-property-type/all-ref-property-types (:property/type property-entity))
db-value (cond
;; entity-conditions
(nil? datom-value)

View File

@@ -22,7 +22,7 @@
(def ^:private watched-attrs
#{:block/title :block/created-at :block/updated-at :block/alias
:block/tags :block/schema :block/link :block/journal-day
:block/tags :block/link :block/journal-day
:property/schema.classes :property.value/content
:db/index :db/valueType :db/cardinality})

View File

@@ -365,7 +365,6 @@
:block/updated-at
:block/created-at
:block/alias
:block/schema
:block/tags
:block/link
:block/journal-day

View File

@@ -1,16 +1,16 @@
(ns frontend.worker.search
"Full-text and fuzzy search"
(:require [clojure.string :as string]
(:require ["fuse.js" :as fuse]
[cljs-bean.core :as bean]
["fuse.js" :as fuse]
[goog.object :as gobj]
[clojure.set :as set]
[clojure.string :as string]
[datascript.core :as d]
[frontend.common.search-fuzzy :as fuzzy]
[logseq.db.sqlite.util :as sqlite-util]
[goog.object :as gobj]
[logseq.common.util :as common-util]
[logseq.db :as ldb]
[clojure.set :as set]
[logseq.common.util.namespace :as ns-util]
[logseq.db :as ldb]
[logseq.db.sqlite.util :as sqlite-util]
[logseq.graph-parser.text :as text]))
;; TODO: use sqlite for fuzzy search
@@ -332,37 +332,6 @@ DROP TRIGGER IF EXISTS blocks_au;
(drop-tables-and-triggers! db)
(create-tables-and-triggers! db))
(comment
(defn- get-db-properties-str
"Similar to db-pu/readable-properties but with a focus on making property values searchable"
[db properties]
(->> properties
(keep
(fn [[k v]]
(let [property (d/entity db k)
values
(->> (if (set? v) v #{v})
(map (fn [val]
(if (= :db.type/ref (:db/valueType property))
(let [e (d/entity db (:db/id val))
value (or
;; closed value
(property-value-when-closed e)
;; :page or :date properties
(:block/title e)
;; first child
(let [parent-id (:db/id e)]
(:block/title (ldb/get-first-child db parent-id))))]
value)
val)))
(remove string/blank?))
hide? (get-in property [:block/schema :hide?])]
(when (and (not hide?) (seq values))
(str (:block/title property)
": "
(string/join "; " values))))))
(string/join ", "))))
(defn get-all-block-contents
[db]
(when db
@@ -406,7 +375,7 @@ DROP TRIGGER IF EXISTS blocks_au;
datoms (filter
(fn [datom]
;; Capture any direct change on page display title, page ref or block content
(contains? #{:block/uuid :block/name :block/title :block/properties :block/schema} (:a datom)))
(contains? #{:block/uuid :block/name :block/title :block/properties} (:a datom)))
data)]
(when (seq datoms)
(get-blocks-from-datoms-impl repo tx-report datoms))))