mirror of https://github.com/logseq/logseq
Add built-in property to list
Hide it on edit so query table doesn't look weird. Also removed needless arity wrappings in block fnspull/7713/head^2
parent
199be34244
commit
39e1b8dc8a
|
@ -47,6 +47,7 @@
|
|||
"Properties used by logseq that user can edit"
|
||||
[]
|
||||
(into #{:title :icon :template :template-including-parent :public :filters :exclude-from-graph-view
|
||||
:logseq.query/nlp-date
|
||||
;; org-mode only
|
||||
:macro :filetags}
|
||||
editable-linkable-built-in-properties))
|
||||
|
@ -70,6 +71,7 @@
|
|||
{:template-including-parent :boolean
|
||||
:public :boolean
|
||||
:exclude-from-graph-view :boolean
|
||||
:logseq.query/nlp-date :boolean
|
||||
:heading :boolean
|
||||
:collapsed :boolean
|
||||
:created-at :integer
|
||||
|
|
|
@ -2024,6 +2024,13 @@
|
|||
(assert (set/subset? hidden-editable-page-properties (gp-property/editable-built-in-properties))
|
||||
"Hidden editable page properties must be valid editable properties")
|
||||
|
||||
(def hidden-editable-block-properties
|
||||
"Properties that are hidden in a block (block property)"
|
||||
#{:logseq.query/nlp-date})
|
||||
|
||||
(assert (set/subset? hidden-editable-block-properties (gp-property/editable-built-in-properties))
|
||||
"Hidden editable page properties must be valid editable properties")
|
||||
|
||||
(defn- add-aliases-to-properties
|
||||
[properties block]
|
||||
(let [repo (state/get-current-repo)
|
||||
|
@ -2044,6 +2051,8 @@
|
|||
(dissoc-keys (property/hidden-properties))
|
||||
pre-block?
|
||||
(dissoc-keys hidden-editable-page-properties)
|
||||
(not pre-block?)
|
||||
(dissoc-keys hidden-editable-block-properties)
|
||||
pre-block?
|
||||
(add-aliases-to-properties block))]
|
||||
(cond
|
||||
|
|
|
@ -41,31 +41,31 @@ and handles unexpected failure."
|
|||
(gp-block/page-name->map original-page-name with-id? (db/get-db (state/get-current-repo)) with-timestamp? (state/get-date-formatter))))
|
||||
|
||||
(defn- normalize-as-percentage
|
||||
([block]
|
||||
(some->> block
|
||||
str
|
||||
(re-matches #"(-?\d+\.?\d*)%")
|
||||
second
|
||||
(#(/ % 100)))))
|
||||
[block]
|
||||
(some->> block
|
||||
str
|
||||
(re-matches #"(-?\d+\.?\d*)%")
|
||||
second
|
||||
(#(/ % 100))))
|
||||
|
||||
(defn- normalize-as-date
|
||||
([block]
|
||||
(some->> block
|
||||
str
|
||||
date/normalize-date
|
||||
(tf/unparse date/custom-formatter))))
|
||||
[block]
|
||||
(some->> block
|
||||
str
|
||||
date/normalize-date
|
||||
(tf/unparse date/custom-formatter)))
|
||||
|
||||
(defn normalize-block
|
||||
"Normalizes supported formats such as dates and percentages.
|
||||
Be careful, this function may harm query sort performance!
|
||||
- nlp-date? - Enable NLP parsing on date items.
|
||||
Requires heavy computation (see `normalize-as-date` for details)"
|
||||
([block nlp-date?]
|
||||
(->> [normalize-as-percentage (when nlp-date? normalize-as-date) identity]
|
||||
(remove nil?)
|
||||
(map #(% (if (set? block) (first block) block)))
|
||||
(remove nil?)
|
||||
(first))))
|
||||
[block nlp-date?]
|
||||
(->> [normalize-as-percentage (when nlp-date? normalize-as-date) identity]
|
||||
(remove nil?)
|
||||
(map #(% (if (set? block) (first block) block)))
|
||||
(remove nil?)
|
||||
(first)))
|
||||
|
||||
(defn parse-block
|
||||
([block]
|
||||
|
|
Loading…
Reference in New Issue