mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 15:46:38 +02:00
♻️ Move app.common.pages to app.common.files
This commit is contained in:
parent
8345548a7a
commit
52fbc678f3
139 changed files with 1459 additions and 1510 deletions
|
@ -10,6 +10,9 @@
|
|||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.files.changes :as cp]
|
||||
[app.common.files.changes-builder :as fcb]
|
||||
[app.common.files.helpers :as cph]
|
||||
[app.common.files.libraries-helpers :as cflh]
|
||||
[app.common.files.migrations :as pmg]
|
||||
[app.common.files.shapes-helpers :as cfsh]
|
||||
|
@ -18,9 +21,6 @@
|
|||
[app.common.geom.rect :as grc]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.logging :as l]
|
||||
[app.common.pages.changes :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.svg :as csvg]
|
||||
[app.common.svg.shapes-builder :as sbuilder]
|
||||
[app.common.types.component :as ctk]
|
||||
|
@ -540,13 +540,13 @@
|
|||
(create-shapes-for-bitmap mobj position))
|
||||
|
||||
changes
|
||||
(-> (pcb/empty-changes nil)
|
||||
(pcb/set-save-undo? false)
|
||||
(pcb/with-page page)
|
||||
(pcb/with-objects (:objects page))
|
||||
(pcb/with-library-data fdata)
|
||||
(pcb/delete-media (:id mobj))
|
||||
(pcb/add-objects (cons shape children)))
|
||||
(-> (fcb/empty-changes nil)
|
||||
(fcb/set-save-undo? false)
|
||||
(fcb/with-page page)
|
||||
(fcb/with-objects (:objects page))
|
||||
(fcb/with-library-data fdata)
|
||||
(fcb/delete-media (:id mobj))
|
||||
(fcb/add-objects (cons shape children)))
|
||||
|
||||
;; NOTE: this is a workaround for `generate-add-component`, it
|
||||
;; is needed because that function always starts from empty
|
||||
|
@ -574,7 +574,7 @@
|
|||
true
|
||||
nil
|
||||
cfsh/prepare-create-artboard-from-selection)
|
||||
changes (pcb/concat-changes changes changes2)]
|
||||
changes (fcb/concat-changes changes changes2)]
|
||||
|
||||
(:redo-changes changes)))
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.files.migrations :as pmg]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.schema.desc-js-like :as-alias smdj]
|
||||
[app.common.spec :as us]
|
||||
|
@ -453,7 +453,7 @@
|
|||
[page id-or-ids]
|
||||
(update page :objects (fn [objects]
|
||||
(reduce (fn [result object-id]
|
||||
(->> (cph/get-children-with-self objects object-id)
|
||||
(->> (cfh/get-children-with-self objects object-id)
|
||||
(filter some?)
|
||||
(d/index-by :id)
|
||||
(merge result)))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(:require
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.files.changes :as fch]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
|
@ -113,7 +113,7 @@
|
|||
(let [data
|
||||
(->> revs
|
||||
(mapcat #(->> % :changes blob/decode))
|
||||
(cp/process-changes (blob/decode (:data file))))]
|
||||
(fch/process-changes (blob/decode (:data file))))]
|
||||
(db/update! conn :file
|
||||
{:deleted-at nil
|
||||
:revn revn
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.thumbnails :as thc]
|
||||
[app.common.types.shape-tree :as ctt]
|
||||
|
@ -127,14 +127,14 @@
|
|||
;; all unneeded shapes if a concrete frame is provided. If no
|
||||
;; frame, the objects is returned untouched.
|
||||
(filter-objects [objects frame-id]
|
||||
(d/index-by :id (cph/get-children-with-self objects frame-id)))
|
||||
(d/index-by :id (cfh/get-children-with-self objects frame-id)))
|
||||
|
||||
;; function responsible of assoc available thumbnails
|
||||
;; to frames and remove all children shapes from objects if
|
||||
;; thumbnails is available
|
||||
(assoc-thumbnails [objects page-id thumbnails]
|
||||
(loop [objects objects
|
||||
frames (filter cph/frame-shape? (vals objects))]
|
||||
frames (filter cfh/frame-shape? (vals objects))]
|
||||
|
||||
(if-let [frame (-> frames first)]
|
||||
(let [frame-id (:id frame)
|
||||
|
@ -144,7 +144,7 @@
|
|||
(dissoc frame :thumbnail))
|
||||
|
||||
children-ids
|
||||
(cph/get-children-ids objects frame-id)
|
||||
(cfh/get-children-ids objects frame-id)
|
||||
|
||||
bounds
|
||||
(when (:show-content frame)
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.files.changes :as cpc]
|
||||
[app.common.files.migrations :as pmg]
|
||||
[app.common.files.validate :as val]
|
||||
[app.common.logging :as l]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes :as cpc]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
|
@ -291,7 +290,7 @@
|
|||
|
||||
(-> file
|
||||
(update :revn inc)
|
||||
(update :data cp/process-changes changes)
|
||||
(update :data cpc/process-changes changes)
|
||||
|
||||
;; If `libs` is defined, then full validation is performed
|
||||
(val/validate-file! libs)
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
"A collection of adhoc fixes scripts."
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.files.validate :as cfv]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.logging :as l]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.pprint :refer [pprint]]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.container :as ctn]
|
||||
|
@ -139,7 +139,7 @@
|
|||
(let [component (ctf/find-component libs (:component-id copy) {:include-deleted? true})
|
||||
component-file (get libs (:component-file copy))
|
||||
component-shapes (ctf/get-component-shapes (:data component-file) component)
|
||||
copy-shapes (cph/get-children-with-self objects (:id copy))
|
||||
copy-shapes (cfh/get-children-with-self objects (:id copy))
|
||||
|
||||
copy-updates (fix-copy-item true copy-shapes component-shapes (:id copy) (:main-instance-id component))]
|
||||
(concat updates copy-updates)))
|
||||
|
@ -301,8 +301,8 @@
|
|||
(if-not (ctk/instance-head? shape)
|
||||
shape
|
||||
(let [component (ctf/get-component libs (:component-file shape) (:component-id shape) {:include-deleted? true})
|
||||
[_path name] (cph/parse-path-name (:name shape))
|
||||
full-name (cph/clean-path (str (:path component) "/" (:name component)))]
|
||||
[_path name] (cfh/parse-path-name (:name shape))
|
||||
full-name (cfh/clean-path (str (:path component) "/" (:name component)))]
|
||||
(if (= name (:name component))
|
||||
(assoc shape :name full-name)
|
||||
shape))))
|
||||
|
@ -355,12 +355,12 @@
|
|||
(gsh/close-attrs? attr (get shape attr) (get ref-shape attr) 1)
|
||||
true)
|
||||
(gsh/close-attrs? attr (get shape attr) (get ref-shape attr)))]
|
||||
(when (and (not equal?) (not (cph/touched-group? shape group)))
|
||||
(when (and (not equal?) (not (cfh/touched-group? shape group)))
|
||||
(println " -> set touched " (:name shape) (:id shape) attr group))
|
||||
(cond-> shape
|
||||
(and (not equal?) (not (cph/touched-group? shape group)))
|
||||
(update :touched cph/set-touched-group group)))))
|
||||
|
||||
(and (not equal?) (not (cfh/touched-group? shape group)))
|
||||
(update :touched cfh/set-touched-group group)))))
|
||||
|
||||
fix-touched-children
|
||||
(fn [shape]
|
||||
(let [matches? (fn [[child-id ref-child-id]]
|
||||
|
@ -369,11 +369,11 @@
|
|||
(= (:shape-ref child) ref-child-id))
|
||||
false))
|
||||
equal? (every? matches? (d/zip-all (:shapes shape) (:shapes ref-shape)))]
|
||||
(when (and (not equal?) (not (cph/touched-group? shape :shapes-group)))
|
||||
(when (and (not equal?) (not (cfh/touched-group? shape :shapes-group)))
|
||||
(println " -> set touched " (:name shape) (:id shape) :shapes :shapes-group))
|
||||
(cond-> shape
|
||||
(and (not equal?) (not (cph/touched-group? shape :shapes-group)))
|
||||
(update :touched cph/set-touched-group :shapes-group))))]
|
||||
(and (not equal?) (not (cfh/touched-group? shape :shapes-group)))
|
||||
(update :touched cfh/set-touched-group :shapes-group))))]
|
||||
|
||||
(as-> shape $
|
||||
(reduce fix-touched-attr $ ctk/sync-attrs)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
[app.common.features :as cfeat]
|
||||
[app.common.files.migrations :as pmg]
|
||||
[app.common.logging :as l]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pprint :refer [pprint]]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue