fix: don't show closed value editing in publishing

Also allow class and page properties to be styled differently
feat/datascript-storage-test
Gabriel Horner 2023-12-05 11:16:37 -05:00
parent 1b2a3cc1c1
commit 34d2b3c234
2 changed files with 30 additions and 22 deletions

View File

@ -695,9 +695,9 @@
(empty? class->properties) (empty? class->properties)
(not new-property?) (not new-property?)
(not (:page-configure? opts))) (not (:page-configure? opts)))
[:div.ls-properties-area (cond-> {} [:div.ls-properties-area (cond-> {:class [(if class-schema? "class-properties" "page-properties")]}
(:selected? opts) (:selected? opts)
(assoc :class "select-none")) (update :class conj "select-none"))
(properties-section block (if class-schema? properties own-properties) opts) (properties-section block (if class-schema? properties own-properties) opts)
(when (and (seq full-hidden-properties) (not class-schema?) (not config/publishing?)) (when (and (seq full-hidden-properties) (not class-schema?) (not config/publishing?))

View File

@ -10,6 +10,7 @@
[frontend.components.property.util :as pu-component] [frontend.components.property.util :as pu-component]
[frontend.handler.property :as property-handler] [frontend.handler.property :as property-handler]
[frontend.handler.db-based.property :as db-property-handler] [frontend.handler.db-based.property :as db-property-handler]
[frontend.config :as config]
[frontend.components.property.value :as property-value] [frontend.components.property.value :as property-value]
[frontend.db :as db] [frontend.db :as db]
[frontend.state :as state] [frontend.state :as state]
@ -31,12 +32,14 @@
(if icon (if icon
(icon-component/icon icon) (icon-component/icon icon)
[:span.bullet-container.cursor [:span.bullet]])]) [:span.bullet-container.cursor [:span.bullet]])])
(if config/publishing?
(constantly [])
(fn [{:keys [toggle-fn]}] (fn [{:keys [toggle-fn]}]
[:div.p-4 [:div.p-4
(icon-component/icon-search (icon-component/icon-search
{:on-chosen (fn [e icon] {:on-chosen (fn [e icon]
(on-chosen e icon) (on-chosen e icon)
(toggle-fn))})]) (toggle-fn))})]))
{:modal-class (util/hiccup->class {:modal-class (util/hiccup->class
"origin-top-right.absolute.left-0.rounded-md.shadow-lg")})) "origin-top-right.absolute.left-0.rounded-md.shadow-lg")}))
@ -138,6 +141,8 @@
:update-icon :update-icon
(fn [icon] (fn [icon]
(property-handler/set-block-property! (state/get-current-repo) (:block/uuid block) :icon icon))))) (property-handler/set-block-property! (state/get-current-repo) (:block/uuid block) :icon icon)))))
(if config/publishing?
(constantly [])
(fn [opts] (fn [opts]
(item-config (item-config
property property
@ -147,7 +152,7 @@
(upsert-closed-value! property {:id uuid (upsert-closed-value! property {:id uuid
:value value :value value
:description description :description description
:icon icon}))))) :icon icon}))))))
dropdown-opts))) dropdown-opts)))
(rum/defc add-existing-values (rum/defc add-existing-values
@ -186,10 +191,12 @@
(swap! *property-schema assoc :values new-values) (swap! *property-schema assoc :values new-values)
(pu-component/update-property! property @*property-name @*property-schema)))})) (pu-component/update-property! property @*property-name @*property-schema)))}))
(ui/dropdown (ui/dropdown
(if config/publishing?
(constantly [])
(fn [{:keys [toggle-fn]}] (fn [{:keys [toggle-fn]}]
[:a.fade-link.flex.flex-row.items-center.gap-1.leading-8 {:on-click toggle-fn} [:a.fade-link.flex.flex-row.items-center.gap-1.leading-8 {:on-click toggle-fn}
(ui/icon "plus" {:size 16}) (ui/icon "plus" {:size 16})
"Add choice"]) "Add choice"]))
(fn [opts] (fn [opts]
(if (= :page property-type) (if (= :page property-type)
(property-value/select-page property (property-value/select-page property
@ -204,6 +211,7 @@
(remove uuid?) (remove uuid?)
(remove string/blank?) (remove string/blank?)
distinct)] distinct)]
(if (seq values) (if (seq values)
(add-existing-values property *property-schema values opts) (add-existing-values property *property-schema values opts)
(item-config (item-config