Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
alonso.torres 2025-03-06 16:05:12 +01:00
commit e01dfd76e8
3 changed files with 96 additions and 78 deletions

View file

@ -154,7 +154,7 @@
(let [data (::file-data (meta changes))] (let [data (::file-data (meta changes))]
(dm/get-in data [:pages-index uuid/zero :objects]))) (dm/get-in data [:pages-index uuid/zero :objects])))
(defn- apply-changes-local (defn apply-changes-local
[changes & {:keys [apply-to-library?]}] [changes & {:keys [apply-to-library?]}]
(dm/assert! (dm/assert!
"expected valid changes" "expected valid changes"

View file

@ -794,7 +794,8 @@
(let [omit-touched? (not reset?) (let [omit-touched? (not reset?)
clear-remote-synced? (and initial-root? reset?) clear-remote-synced? (and initial-root? reset?)
set-remote-synced? (and (not initial-root?) reset?) set-remote-synced? (and (not initial-root?) reset?)
changes (cond-> changes changes
(cond-> changes
:always :always
(update-attrs shape-inst (update-attrs shape-inst
shape-main shape-main
@ -811,14 +812,6 @@
container container
omit-touched?) omit-touched?)
(ctl/grid-layout? shape-main)
(update-grid-copy-attrs shape-main
shape-inst
library
component
container
omit-touched?)
reset? reset?
(change-touched shape-inst (change-touched shape-inst
shape-main shape-main
@ -911,8 +904,9 @@
(d/index-of children-inst child-inst) (d/index-of children-inst child-inst)
(d/index-of children-main child-main) (d/index-of children-main child-main)
container container
omit-touched?))] omit-touched?))
changes
(compare-children changes (compare-children changes
shape-inst shape-inst
children-inst children-inst
@ -928,7 +922,19 @@
moved moved
false false
reset? reset?
components-v2)))) components-v2)
changes
(cond-> changes
(ctl/grid-layout? shape-inst)
(update-grid-copy-attrs
(:id shape-inst)
shape-main
library
component
omit-touched?))]
changes)))
(defn generate-rename-component (defn generate-rename-component
"Generate the changes for rename the component with the given id, in the current file library." "Generate the changes for rename the component with the given id, in the current file library."
@ -1774,30 +1780,36 @@
(defn- update-grid-copy-attrs (defn- update-grid-copy-attrs
"Synchronizes the `layout-grid-cells` property from the main shape to the copies" "Synchronizes the `layout-grid-cells` property from the main shape to the copies"
[changes shape-main shape-copy main-container main-component copy-container omit-touched?] [changes shape-copy-id shape-main main-container main-component omit-touched?]
(-> changes
(pcb/apply-changes-local)
(pcb/update-shapes
[shape-copy-id]
(fn [shape-copy objects]
(let [ids-map (let [ids-map
(into {} (into {}
(comp (comp
(map #(dm/get-in copy-container [:objects %])) (map #(get objects %))
(keep (keep
(fn [copy-shape] (fn [copy-shape]
(let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)] (let [main-shape (ctf/get-ref-shape main-container main-component copy-shape)]
[(:id main-shape) (:id copy-shape)])))) [(:id main-shape) (:id copy-shape)]))))
(:shapes shape-copy)) (:shapes shape-copy))
new-changes remove-orphan-cells
(-> (pcb/empty-changes) (fn [cells {:keys [shapes]}]
(pcb/with-container copy-container) (let [child? (set shapes)]
(pcb/with-objects (:objects copy-container)) (-> cells
(pcb/update-shapes (update-vals
[(:id shape-copy)] (fn [cell]
(fn [shape-copy] (update cell :shapes #(filterv child? %)))))))
;; Take cells from main and remap the shapes to assign it to the copy ;; Take cells from main and remap the shapes to assign it to the copy
(let [copy-cells (:layout-grid-cells shape-copy) copy-cells (-> shape-copy :layout-grid-cells (remove-orphan-cells shape-copy))
main-cells (-> (ctl/remap-grid-cells shape-main ids-map) :layout-grid-cells)] main-cells (-> shape-main (ctl/remap-grid-cells ids-map) :layout-grid-cells)]
(assoc shape-copy :layout-grid-cells (ctl/merge-cells copy-cells main-cells omit-touched?)))) (-> shape-copy
{:ignore-touched true}))] (assoc :layout-grid-cells
(pcb/concat-changes changes new-changes))) (ctl/merge-cells copy-cells main-cells omit-touched?)))))
{:ignore-touched true :with-objects? true})))
(defn- update-grid-main-attrs (defn- update-grid-main-attrs
"Synchronizes the `layout-grid-cells` property from the copy to the main shape" "Synchronizes the `layout-grid-cells` property from the copy to the main shape"

View file

@ -1642,11 +1642,16 @@
"Given target cells update with source cells while trying to keep target as "Given target cells update with source cells while trying to keep target as
untouched as possible" untouched as possible"
[target-cells source-cells omit-touched?] [target-cells source-cells omit-touched?]
(if (not omit-touched?) (if omit-touched?
source-cells
(letfn [(get-data [cells id] (letfn [(get-data [cells id]
(dissoc (get cells id) :shapes :row :column :row-span :column-span))] (dissoc (get cells id) :row :column :row-span :column-span))
(merge-cells [source-cell target-cell]
(-> source-cell
(d/patch-object
(dissoc target-cell :shapes :row :column :row-span :column-span))
(cond-> (d/not-empty? (:shapes target-cell))
(assoc :shapes (:shapes target-cell)))))]
(let [deleted-cells (let [deleted-cells
(into #{} (into #{}
(filter #(not (contains? source-cells %))) (filter #(not (contains? source-cells %)))
@ -1664,8 +1669,9 @@
(reduce (reduce
(fn [cells id] (fn [cells id]
(-> cells (-> cells
(d/update-when id d/patch-object (get-data target-cells id)))) (d/update-when id merge-cells (get target-cells id))))
source-cells)))))) source-cells))))
source-cells))
(defn toggle-fix-if-auto (defn toggle-fix-if-auto
"Changes the sizing to fix if it's fill" "Changes the sizing to fix if it's fill"