mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 15:16:10 +02:00
🐛 Replace :use-for-thumbnail?
with :use-for-thumbnail
This commit is contained in:
parent
0f133ca431
commit
36506ec360
9 changed files with 31 additions and 16 deletions
|
@ -144,8 +144,8 @@
|
||||||
(run! pmap/load!))
|
(run! pmap/load!))
|
||||||
|
|
||||||
;; Then proceed to find the frame set for thumbnail
|
;; Then proceed to find the frame set for thumbnail
|
||||||
|
(d/seek #(or (:use-for-thumbnail %)
|
||||||
(d/seek :use-for-thumbnail?
|
(:use-for-thumbnail? %)) ; NOTE: backward comp (remove on v1.21)
|
||||||
(for [page (-> data :pages-index vals)
|
(for [page (-> data :pages-index vals)
|
||||||
frame (-> page :objects ctt/get-frames)]
|
frame (-> page :objects ctt/get-frames)]
|
||||||
(assoc frame :page-id (:id page)))))
|
(assoc frame :page-id (:id page)))))
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
(ns app.common.files.defaults)
|
(ns app.common.files.defaults)
|
||||||
|
|
||||||
(def version 30)
|
(def version 31)
|
||||||
|
|
|
@ -576,3 +576,18 @@
|
||||||
(-> data
|
(-> data
|
||||||
(update :pages-index update-vals update-container)
|
(update :pages-index update-vals update-container)
|
||||||
(update :components update-vals update-container))))
|
(update :components update-vals update-container))))
|
||||||
|
|
||||||
|
(defmethod migrate 31
|
||||||
|
[data]
|
||||||
|
(letfn [(update-object [object]
|
||||||
|
(cond-> object
|
||||||
|
(contains? object :use-for-thumbnail?)
|
||||||
|
(-> (assoc :use-for-thumbnail (:use-for-thumbnail? object))
|
||||||
|
(dissoc :use-for-thumbnail?))))
|
||||||
|
|
||||||
|
(update-container [container]
|
||||||
|
(d/update-when container :objects update-vals update-object))]
|
||||||
|
|
||||||
|
(-> data
|
||||||
|
(update :pages-index update-vals update-container)
|
||||||
|
(update :components update-vals update-container))))
|
||||||
|
|
|
@ -974,7 +974,7 @@
|
||||||
(report-error :missing-component-root
|
(report-error :missing-component-root
|
||||||
(str/format "Referenced shape %s not found in near component" (:shape-ref shape))
|
(str/format "Referenced shape %s not found in near component" (:shape-ref shape))
|
||||||
shape file page))))
|
shape file page))))
|
||||||
|
|
||||||
(defn validate-component-not-ref
|
(defn validate-component-not-ref
|
||||||
"Validate that this shape does not reference other one."
|
"Validate that this shape does not reference other one."
|
||||||
[shape file page report-error]
|
[shape file page report-error]
|
||||||
|
@ -1065,7 +1065,7 @@
|
||||||
|
|
||||||
(defn validate-shape
|
(defn validate-shape
|
||||||
"Validate referential integrity and semantic coherence of a shape and all its children.
|
"Validate referential integrity and semantic coherence of a shape and all its children.
|
||||||
|
|
||||||
The context is the situation of the parent in respect to components:
|
The context is the situation of the parent in respect to components:
|
||||||
:not-component
|
:not-component
|
||||||
:main-top
|
:main-top
|
||||||
|
|
|
@ -462,7 +462,7 @@
|
||||||
fdata (:workspace-data state)
|
fdata (:workspace-data state)
|
||||||
components-v2 (dm/get-in fdata [:options :components-v2])
|
components-v2 (dm/get-in fdata [:options :components-v2])
|
||||||
objects (->> (:objects page)
|
objects (->> (:objects page)
|
||||||
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail?))))
|
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail))))
|
||||||
main-instances-ids (set (keep #(when (ctk/main-instance? (val %)) (key %)) objects))
|
main-instances-ids (set (keep #(when (ctk/main-instance? (val %)) (key %)) objects))
|
||||||
ids-to-remove (set (apply concat (map #(cph/get-children-ids objects %) main-instances-ids)))
|
ids-to-remove (set (apply concat (map #(cph/get-children-ids objects %) main-instances-ids)))
|
||||||
|
|
||||||
|
|
|
@ -449,8 +449,8 @@
|
||||||
:frame-id frame-id)
|
:frame-id frame-id)
|
||||||
|
|
||||||
(dissoc :shapes
|
(dissoc :shapes
|
||||||
:main-instance?
|
:main-instance
|
||||||
:use-for-thumbnail?)
|
:use-for-thumbnail)
|
||||||
|
|
||||||
(cond->
|
(cond->
|
||||||
(or frame? group? bool?)
|
(or frame? group? bool?)
|
||||||
|
|
|
@ -504,7 +504,7 @@
|
||||||
pages (-> state :workspace-data :pages-index vals)]
|
pages (-> state :workspace-data :pages-index vals)]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
;; First: clear the `:use-for-thumbnail?` flag from all not
|
;; First: clear the `:use-for-thumbnail` flag from all not
|
||||||
;; selected frames.
|
;; selected frames.
|
||||||
(rx/from
|
(rx/from
|
||||||
(->> pages
|
(->> pages
|
||||||
|
@ -512,13 +512,13 @@
|
||||||
(fn [{:keys [objects id] :as page}]
|
(fn [{:keys [objects id] :as page}]
|
||||||
(->> (ctst/get-frames objects)
|
(->> (ctst/get-frames objects)
|
||||||
(sequence
|
(sequence
|
||||||
(comp (filter :use-for-thumbnail?)
|
(comp (filter :use-for-thumbnail)
|
||||||
(map :id)
|
(map :id)
|
||||||
(remove selected)
|
(remove selected)
|
||||||
(map (partial vector id)))))))
|
(map (partial vector id)))))))
|
||||||
(d/group-by first second)
|
(d/group-by first second)
|
||||||
(map (fn [[page-id frame-ids]]
|
(map (fn [[page-id frame-ids]]
|
||||||
(dch/update-shapes frame-ids #(dissoc % :use-for-thumbnail?) {:page-id page-id})))))
|
(dch/update-shapes frame-ids #(dissoc % :use-for-thumbnail) {:page-id page-id})))))
|
||||||
|
|
||||||
;; And finally: toggle the flag value on all the selected shapes
|
;; And finally: toggle the flag value on all the selected shapes
|
||||||
(rx/of (dch/update-shapes selected #(update % :use-for-thumbnail? not))))))))
|
(rx/of (dch/update-shapes selected #(update % :use-for-thumbnail not))))))))
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
do-toggle-thumbnail #(st/emit! (dw/toggle-file-thumbnail-selected))]
|
do-toggle-thumbnail #(st/emit! (dw/toggle-file-thumbnail-selected))]
|
||||||
(when (and single? has-frame?)
|
(when (and single? has-frame?)
|
||||||
[:*
|
[:*
|
||||||
(if (every? :use-for-thumbnail? shapes)
|
(if (every? :use-for-thumbnail shapes)
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-remove")
|
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-remove")
|
||||||
:on-click do-toggle-thumbnail}]
|
:on-click do-toggle-thumbnail}]
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-set")
|
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-set")
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
(on-frame-leave (:id frame))))
|
(on-frame-leave (:id frame))))
|
||||||
|
|
||||||
main-instance? (ctk/main-instance? frame)
|
main-instance? (ctk/main-instance? frame)
|
||||||
text-pos-x (if (or (:use-for-thumbnail? frame) grid-edition? main-instance?) 15 0)]
|
text-pos-x (if (or (:use-for-thumbnail frame) grid-edition? main-instance?) 15 0)]
|
||||||
|
|
||||||
(when (not (:hidden frame))
|
(when (not (:hidden frame))
|
||||||
[:g.frame-title {:id (dm/str "frame-title-" (:id frame))
|
[:g.frame-title {:id (dm/str "frame-title-" (:id frame))
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
:transform (vwu/title-transform frame zoom grid-edition?)
|
:transform (vwu/title-transform frame zoom grid-edition?)
|
||||||
:pointer-events (when (:blocked frame) "none")}
|
:pointer-events (when (:blocked frame) "none")}
|
||||||
(cond
|
(cond
|
||||||
(or (:use-for-thumbnail? frame) grid-edition? main-instance?)
|
(or (:use-for-thumbnail frame) grid-edition? main-instance?)
|
||||||
[:svg {:x 0
|
[:svg {:x 0
|
||||||
:y -9
|
:y -9
|
||||||
:width 12
|
:width 12
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
:style {:fill color}
|
:style {:fill color}
|
||||||
:visibility (if show-artboard-names? "visible" "hidden")}
|
:visibility (if show-artboard-names? "visible" "hidden")}
|
||||||
(cond
|
(cond
|
||||||
(:use-for-thumbnail? frame)
|
(:use-for-thumbnail frame)
|
||||||
[:use {:href "#icon-set-thumbnail"}]
|
[:use {:href "#icon-set-thumbnail"}]
|
||||||
|
|
||||||
grid-edition?
|
grid-edition?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue