From a6d47cca10b654942825a20a139701a09f7f66ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 15 Oct 2020 11:15:35 +0200 Subject: [PATCH] :sparkles: Make some small fixes --- common/app/common/pages_helpers.cljc | 2 +- .../app/main/data/workspace/libraries.cljs | 42 ++++++++++++------- .../data/workspace/libraries_helpers.cljs | 9 ++-- frontend/src/app/main/store.cljs | 3 +- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/common/app/common/pages_helpers.cljc b/common/app/common/pages_helpers.cljc index 5edbfd70c..1432923bd 100644 --- a/common/app/common/pages_helpers.cljc +++ b/common/app/common/pages_helpers.cljc @@ -58,7 +58,7 @@ (defn get-object-with-children "Retrieve a list with an object and all of its children" [id objects] - (map #(get objects %) (d/concat [id] (get-children id objects)))) + (map #(get objects %) (cons id (get-children id objects)))) (defn is-shape-grouped "Checks if a shape is inside a group" diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 15a0e254d..00226a92e 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -364,7 +364,8 @@ (ptk/reify ::reset-component ptk/WatchEvent (watch [_ state stream] - (js/console.info "##### RESET-COMPONENT of shape" (str id)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.info "##### RESET-COMPONENT of shape" (str id)) (let [page-id (:current-page-id state) page (get-in state [:workspace-data :pages-index page-id]) objects (dwc/lookup-page-objects state page-id) @@ -377,10 +378,11 @@ state true) - _ (js/console.info "shape" (:name shape) "<- component" (:name component)) - _ (js/console.debug "all-shapes" (clj->js all-shapes)) - _ (js/console.debug "component" (clj->js component)) - _ (js/console.debug "root-component" (clj->js root-component)) + ;; ===== Uncomment this to debug ===== + ;; _ (js/console.info "shape" (:name shape) "<- component" (:name component)) + ;; _ (js/console.debug "all-shapes" (clj->js all-shapes)) + ;; _ (js/console.debug "component" (clj->js component)) + ;; _ (js/console.debug "root-component" (clj->js root-component)) [rchanges uchanges] (dwlh/generate-sync-shape-and-children-components shape @@ -391,7 +393,8 @@ nil true)] - (js/console.debug "rchanges" (clj->js rchanges)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.debug "rchanges" (clj->js rchanges)) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})))))) @@ -401,7 +404,8 @@ (ptk/reify ::update-component ptk/WatchEvent (watch [_ state stream] - (js/console.info "##### UPDATE-COMPONENT of shape" (str id)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.info "##### UPDATE-COMPONENT of shape" (str id)) (let [page-id (:current-page-id state) objects (dwc/lookup-page-objects state page-id) shape (get objects id) @@ -413,10 +417,11 @@ state true) - _ (js/console.info "shape" (:name shape) "-> component" (:name component)) - _ (js/console.debug "all-shapes" (clj->js all-shapes)) - _ (js/console.debug "component" (clj->js component)) - _ (js/console.debug "root-component" (clj->js root-component)) + ;; ===== Uncomment this to debug ===== + ;; _ (js/console.info "shape" (:name shape) "-> component" (:name component)) + ;; _ (js/console.debug "all-shapes" (clj->js all-shapes)) + ;; _ (js/console.debug "component" (clj->js component)) + ;; _ (js/console.debug "root-component" (clj->js root-component)) [rchanges uchanges] (dwlh/generate-sync-shape-inverse shape @@ -425,7 +430,8 @@ root-component page-id)] - (js/console.debug "rchanges" (clj->js rchanges)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.debug "rchanges" (clj->js rchanges)) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true})))))) @@ -443,7 +449,8 @@ ptk/WatchEvent (watch [_ state stream] - (js/console.info "##### SYNC-FILE" (str (or file-id "local"))) + ;; ===== Uncomment this to debug ===== + ;; (js/console.info "##### SYNC-FILE" (str (or file-id "local"))) (let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components file-id state) [rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state) [rchanges3 uchanges3] (dwlh/generate-sync-file :colors file-id state) @@ -452,7 +459,8 @@ [rchanges6 uchanges6] (dwlh/generate-sync-library :typographies file-id state) rchanges (d/concat rchanges1 rchanges2 rchanges3 rchanges4 rchanges5 rchanges6) uchanges (d/concat uchanges1 uchanges2 uchanges3 uchanges4 uchanges5 uchanges6)] - (js/console.debug "rchanges" (clj->js rchanges)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.debug "rchanges" (clj->js rchanges)) (rx/concat (rx/of (dm/hide-tag :sync-dialog)) (when rchanges @@ -478,13 +486,15 @@ (ptk/reify ::sync-file-2nd-stage ptk/WatchEvent (watch [_ state stream] - (js/console.info "##### SYNC-FILE" (str (or file-id "local")) "(2nd stage)") + ;; ===== Uncomment this to debug ===== + ;; (js/console.info "##### SYNC-FILE" (str (or file-id "local")) "(2nd stage)") (let [[rchanges1 uchanges1] (dwlh/generate-sync-file :components nil state) [rchanges2 uchanges2] (dwlh/generate-sync-library :components file-id state) rchanges (d/concat rchanges1 rchanges2) uchanges (d/concat uchanges1 uchanges2)] (when rchanges - (js/console.debug "rchanges" (clj->js rchanges)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.debug "rchanges" (clj->js rchanges)) (rx/of (dwc/commit-changes rchanges uchanges {:commit-local? true}))))))) (def ignore-sync diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index e9a89be2b..8585f0d10 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -422,14 +422,17 @@ "Generate changes to synchronize one shape inside a component, with other shape that is linked to it." [shape root-shape root-component component page-id] - (js/console.log "component" (clj->js component)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.log "component" (clj->js component)) (if (nil? component) empty-changes (let [component-shape (get (:objects component) (:shape-ref shape))] - (js/console.log "component-shape" (clj->js component-shape)) + ;; ===== Uncomment this to debug ===== + ;; (js/console.log "component-shape" (clj->js component-shape)) (if (nil? component-shape) empty-changes - (let [_(js/console.info "update" (:name shape) "->" (:name component-shape)) + (let [;; ===== Uncomment this to debug ===== + ;; _(js/console.info "update" (:name shape) "->" (:name component-shape)) [rchanges1 uchanges1] (update-attrs component-shape shape diff --git a/frontend/src/app/main/store.cljs b/frontend/src/app/main/store.cljs index 9e34aa323..be3fc28d5 100644 --- a/frontend/src/app/main/store.cljs +++ b/frontend/src/app/main/store.cljs @@ -90,8 +90,7 @@ (let [shape (get objects shape-id)] (println (str/pad (str (str/repeat " " level) (:name shape) - (when (seq (filter #(not= :position-group %) - (:touched shape))) "*")) + (when (seq (:touched shape)) "*") {:length 20 :type :right}) (show-component shape objects))