Parcourir la source

fix: don't show closed value editing in publishing

Also allow class and page properties to be styled differently
Gabriel Horner il y a 2 ans
Parent
commit
34d2b3c234

+ 2 - 2
src/main/frontend/components/property.cljs

@@ -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?))

+ 28 - 20
src/main/frontend/components/property/closed_value.cljs

@@ -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]])])
-   (fn [{:keys [toggle-fn]}]
-     [:div.p-4
-      (icon-component/icon-search
-       {:on-chosen (fn [e icon]
-                     (on-chosen e icon)
-                     (toggle-fn))})])
+   (if config/publishing?
+     (constantly [])
+     (fn [{:keys [toggle-fn]}]
+       [:div.p-4
+        (icon-component/icon-search
+         {:on-chosen (fn [e icon]
+                       (on-chosen e icon)
+                       (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,16 +141,18 @@
                :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)))))
-     (fn [opts]
-       (item-config
-        property
-        block
-        (assoc opts :on-save
-               (fn [value icon description]
-                 (upsert-closed-value! property {:id uuid
-                                                 :value value
-                                                 :description description
-                                                 :icon icon})))))
+     (if config/publishing?
+       (constantly [])
+       (fn [opts]
+         (item-config
+          property
+          block
+          (assoc opts :on-save
+                 (fn [value icon description]
+                   (upsert-closed-value! property {:id uuid
+                                                   :value value
+                                                   :description description
+                                                   :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
-      (fn [{:keys [toggle-fn]}]
-        [:a.fade-link.flex.flex-row.items-center.gap-1.leading-8 {:on-click toggle-fn}
-         (ui/icon "plus" {:size 16})
-         "Add choice"])
+      (if config/publishing?
+        (constantly [])
+        (fn [{:keys [toggle-fn]}]
+          [:a.fade-link.flex.flex-row.items-center.gap-1.leading-8 {:on-click toggle-fn}
+           (ui/icon "plus" {:size 16})
+           "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