mirror of https://github.com/logseq/logseq
Hide icon property when page property
Requested by https://discuss.logseq.com/t/hide-icon-property-like-title/8738pull/6482/head
parent
8dfa8dfb49
commit
ef910e3ab5
|
@ -71,6 +71,7 @@
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[reitit.frontend.easy :as rfe]
|
[reitit.frontend.easy :as rfe]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
|
[clojure.set :as set]
|
||||||
[shadow.loader :as loader]))
|
[shadow.loader :as loader]))
|
||||||
|
|
||||||
(defn safe-read-string
|
(defn safe-read-string
|
||||||
|
@ -1843,16 +1844,16 @@
|
||||||
:else
|
:else
|
||||||
(inline-text config (:block/format block) (str v)))]))
|
(inline-text config (:block/format block) (str v)))]))
|
||||||
|
|
||||||
(rum/defc properties-cp
|
(def hidden-editable-page-properties
|
||||||
[config block]
|
"Properties that are hidden in the pre-block (page property)"
|
||||||
(let [properties (walk/keywordize-keys (:block/properties block))
|
#{:title :filters :icon})
|
||||||
properties-order (:block/properties-order block)
|
|
||||||
properties (apply dissoc properties (property/hidden-properties))
|
(assert (set/subset? hidden-editable-page-properties (gp-property/editable-built-in-properties))
|
||||||
properties-order (remove (property/hidden-properties) properties-order)
|
"Hidden editable page properties must be valid editable properties")
|
||||||
pre-block? (:block/pre-block? block)
|
|
||||||
properties (if pre-block?
|
(defn- add-aliases-to-properties
|
||||||
|
[properties block]
|
||||||
(let [repo (state/get-current-repo)
|
(let [repo (state/get-current-repo)
|
||||||
properties (dissoc properties :title :filters)
|
|
||||||
aliases (db/get-page-alias-names repo
|
aliases (db/get-page-alias-names repo
|
||||||
(:block/name (db/pull (:db/id (:block/page block)))))]
|
(:block/name (db/pull (:db/id (:block/page block)))))]
|
||||||
(if (seq aliases)
|
(if (seq aliases)
|
||||||
|
@ -1860,24 +1861,36 @@
|
||||||
(update properties :alias (fn [c]
|
(update properties :alias (fn [c]
|
||||||
(util/distinct-by string/lower-case (concat c aliases))))
|
(util/distinct-by string/lower-case (concat c aliases))))
|
||||||
(assoc properties :alias aliases))
|
(assoc properties :alias aliases))
|
||||||
properties))
|
properties)))
|
||||||
properties)
|
|
||||||
properties-order (if pre-block?
|
(rum/defc properties-cp
|
||||||
(remove #{:title :filters} properties-order)
|
[config {:block/keys [pre-block?] :as block}]
|
||||||
properties-order)
|
(let [dissoc-keys (fn [m keys] (apply dissoc m keys))
|
||||||
properties (if (seq properties-order)
|
properties (cond-> (update-keys (:block/properties block) keyword)
|
||||||
(map (fn [k] [k (get properties k)]) properties-order)
|
true
|
||||||
properties)]
|
(dissoc-keys (property/hidden-properties))
|
||||||
|
pre-block?
|
||||||
|
(dissoc-keys hidden-editable-page-properties)
|
||||||
|
pre-block?
|
||||||
|
(add-aliases-to-properties block))]
|
||||||
(cond
|
(cond
|
||||||
(seq properties)
|
(seq properties)
|
||||||
|
(let [properties-order (cond->> (:block/properties-order block)
|
||||||
|
true
|
||||||
|
(remove (property/hidden-properties))
|
||||||
|
pre-block?
|
||||||
|
(remove hidden-editable-page-properties))
|
||||||
|
ordered-properties (if (seq properties-order)
|
||||||
|
(map (fn [k] [k (get properties k)]) properties-order)
|
||||||
|
properties)]
|
||||||
[:div.block-properties
|
[:div.block-properties
|
||||||
{:class (when pre-block? "page-properties")
|
{:class (when pre-block? "page-properties")
|
||||||
:title (if pre-block?
|
:title (if pre-block?
|
||||||
"Click to edit this page's properties"
|
"Click to edit this page's properties"
|
||||||
"Click to edit this block's properties")}
|
"Click to edit this block's properties")}
|
||||||
(for [[k v] properties]
|
(for [[k v] ordered-properties]
|
||||||
(rum/with-key (property-cp config block k v)
|
(rum/with-key (property-cp config block k v)
|
||||||
(str (:block/uuid block) "-" k)))]
|
(str (:block/uuid block) "-" k)))])
|
||||||
|
|
||||||
(and pre-block? properties)
|
(and pre-block? properties)
|
||||||
[:span.opacity-50 "Properties"]
|
[:span.opacity-50 "Properties"]
|
||||||
|
|
Loading…
Reference in New Issue