mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 17:41:40 +02:00
🐛 Fix weird numeration creating elements in dashboard
This commit is contained in:
parent
6be83fc6d6
commit
dd2321a37b
19 changed files with 256 additions and 239 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.data.dashboard
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
|
@ -664,10 +665,12 @@
|
|||
(ptk/reify ::create-project
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [name (name (gensym (str (tr "dashboard.new-project-prefix") " ")))
|
||||
team-id (:current-team-id state)
|
||||
params {:name name
|
||||
:team-id team-id}
|
||||
(let [projects (get state :dashboard-projects)
|
||||
unames (cp/retrieve-used-names projects)
|
||||
name (cp/generate-unique-name unames (str (tr "dashboard.new-project-prefix") " 1"))
|
||||
team-id (:current-team-id state)
|
||||
params {:name name
|
||||
:team-id team-id}
|
||||
{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error rx/throw}} (meta params)]
|
||||
|
@ -875,7 +878,9 @@
|
|||
:or {on-success identity
|
||||
on-error rx/throw}} (meta params)
|
||||
|
||||
name (name (gensym (str (tr "dashboard.new-file-prefix") " ")))
|
||||
files (get state :dashboard-files)
|
||||
unames (cp/retrieve-used-names files)
|
||||
name (cp/generate-unique-name unames (str (tr "dashboard.new-file-prefix") " 1"))
|
||||
features (cond-> #{}
|
||||
(features/active-feature? state :components-v2)
|
||||
(conj "components/v2"))
|
||||
|
@ -1067,8 +1072,12 @@
|
|||
pparams (:path-params route)
|
||||
in-project? (contains? pparams :project-id)
|
||||
name (if in-project?
|
||||
(name (gensym (str (tr "dashboard.new-file-prefix") " ")))
|
||||
(name (gensym (str (tr "dashboard.new-project-prefix") " "))))
|
||||
(let [files (get state :dashboard-files)
|
||||
unames (cp/retrieve-used-names files)]
|
||||
(cp/generate-unique-name unames (str (tr "dashboard.new-file-prefix") " 1")))
|
||||
(let [projects (get state :dashboard-projects)
|
||||
unames (cp/retrieve-used-names projects)]
|
||||
(cp/generate-unique-name unames (str (tr "dashboard.new-project-prefix") " 1"))))
|
||||
params (if in-project?
|
||||
{:project-id (:project-id pparams)
|
||||
:name name}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
[app.common.geom.proportions :as gpp]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.logging :as log]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
|
@ -408,8 +409,8 @@
|
|||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [pages (get-in state [:workspace-data :pages-index])
|
||||
unames (ctst/retrieve-used-names pages)
|
||||
name (ctst/generate-unique-name unames "Page-1")
|
||||
unames (cp/retrieve-used-names pages)
|
||||
name (cp/generate-unique-name unames "Page 1")
|
||||
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/add-empty-page id name))]
|
||||
|
@ -423,9 +424,9 @@
|
|||
(watch [it state _]
|
||||
(let [id (uuid/next)
|
||||
pages (get-in state [:workspace-data :pages-index])
|
||||
unames (ctst/retrieve-used-names pages)
|
||||
unames (cp/retrieve-used-names pages)
|
||||
page (get-in state [:workspace-data :pages-index page-id])
|
||||
name (ctst/generate-unique-name unames (:name page))
|
||||
name (cp/generate-unique-name unames (:name page))
|
||||
|
||||
no_thumbnails_objects (->> (:objects page)
|
||||
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail?))))
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
|
@ -33,7 +34,7 @@
|
|||
|
||||
flows (get-in page [:options :flows] [])
|
||||
unames (into #{} (map :name flows))
|
||||
name (ctst/generate-unique-name unames "Flow-1")
|
||||
name (cp/generate-unique-name unames "Flow 1")
|
||||
|
||||
new-flow {:id (uuid/next)
|
||||
:name name
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
(pcb/with-objects objects))]
|
||||
(let [group-name (if (= 1 (count shapes))
|
||||
(:name (first shapes))
|
||||
"Component-1")]
|
||||
"Component 1")]
|
||||
(dwg/prepare-create-group it
|
||||
objects
|
||||
page-id
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
[app.common.types.page :as ctp]
|
||||
[app.common.types.shape-tree :as ctt]
|
||||
[app.common.types.shape.interactions :as ctsi]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.modal :as md]
|
||||
|
@ -290,7 +289,7 @@
|
|||
move to the desired position, and recalculate parents and frames as needed."
|
||||
[all-objects page ids delta it]
|
||||
(let [shapes (map (d/getf all-objects) ids)
|
||||
unames (volatile! (ctt/retrieve-used-names (:objects page)))
|
||||
unames (volatile! (cp/retrieve-used-names (:objects page)))
|
||||
update-unames! (fn [new-name] (vswap! unames conj new-name))
|
||||
all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) (d/ordered-set) ids)
|
||||
ids-map (into {} (map #(vector % (uuid/next))) all-ids)
|
||||
|
@ -367,7 +366,7 @@
|
|||
(let [update-flows (fn [flows]
|
||||
(reduce
|
||||
(fn [flows frame]
|
||||
(let [name (ctt/generate-unique-name @unames "Flow-1")
|
||||
(let [name (cp/generate-unique-name @unames "Flow 1")
|
||||
_ (vswap! unames conj name)
|
||||
new-flow {:id (uuid/next)
|
||||
:name name
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us :refer [max-safe-int min-safe-int]]
|
||||
|
@ -493,7 +494,7 @@
|
|||
(- y vb-y (/ vb-height 2))
|
||||
y))
|
||||
|
||||
unames (ctst/retrieve-used-names objects)
|
||||
unames (cp/retrieve-used-names objects)
|
||||
|
||||
svg-name (str/replace (:name svg-data) ".svg" "")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue