mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 10:21:38 +02:00
🐛 Fix projects and files ordering on dashboard grid.
This commit is contained in:
parent
8aaffeeb17
commit
65678ac674
2 changed files with 14 additions and 31 deletions
|
@ -75,7 +75,7 @@
|
||||||
(fetch-projects (:team-id local)))))))
|
(fetch-projects (:team-id local)))))))
|
||||||
|
|
||||||
|
|
||||||
(defn initialize-team
|
(defn initialize-recent
|
||||||
[team-id]
|
[team-id]
|
||||||
(us/verify ::us/uuid team-id)
|
(us/verify ::us/uuid team-id)
|
||||||
(ptk/reify ::initialize-team
|
(ptk/reify ::initialize-team
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
(ptk/reify ::projects-fetched
|
(ptk/reify ::projects-fetched
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [assoc-project #(update-in %1 [:projects (:id %2)] merge %2)]
|
(let [assoc-project #(assoc-in %1 [:projects (:id %2)] %2)]
|
||||||
(reduce assoc-project state projects)))))
|
(reduce assoc-project state projects)))))
|
||||||
|
|
||||||
;; --- Fetch Files
|
;; --- Fetch Files
|
||||||
|
@ -252,9 +252,13 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [params {:id id :name name}]
|
(let [local (:dashboard-local state)
|
||||||
|
params {:id id :name name}]
|
||||||
|
;; NOTE: this is a temporal (quick & dirty) solution for
|
||||||
|
;; refreshing the results; we need to think in a better way to
|
||||||
|
;; do it instead of a simple and complete data refresh.
|
||||||
(->> (rp/mutation :rename-file params)
|
(->> (rp/mutation :rename-file params)
|
||||||
(rx/ignore))))))
|
(rx/map (fn [_] (initialize-recent (:team-id local)))))))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Create File
|
;; --- Create File
|
||||||
|
|
|
@ -13,29 +13,9 @@
|
||||||
[uxbox.main.ui.confirm :refer [confirm-dialog]]
|
[uxbox.main.ui.confirm :refer [confirm-dialog]]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.i18n :as i18n :refer [t tr]]
|
[uxbox.util.i18n :as i18n :refer [t tr]]
|
||||||
|
[uxbox.util.router :as rt]
|
||||||
[uxbox.util.time :as dt]))
|
[uxbox.util.time :as dt]))
|
||||||
|
|
||||||
;; --- Helpers
|
|
||||||
|
|
||||||
(defn sort-by
|
|
||||||
[ordering files]
|
|
||||||
(case ordering
|
|
||||||
:name (cljs.core/sort-by :name files)
|
|
||||||
:created (reverse (cljs.core/sort-by :created-at files))
|
|
||||||
:modified (reverse (cljs.core/sort-by :modified-at files))
|
|
||||||
files))
|
|
||||||
|
|
||||||
(defn contains-term?
|
|
||||||
[phrase term]
|
|
||||||
(let [term (name term)]
|
|
||||||
(str/includes? (str/lower phrase) (str/trim (str/lower term)))))
|
|
||||||
|
|
||||||
(defn filter-by
|
|
||||||
[term files]
|
|
||||||
(if (str/blank? term)
|
|
||||||
files
|
|
||||||
(filter #(contains-term? (:name %) term) files)))
|
|
||||||
|
|
||||||
;; --- Grid Item Thumbnail
|
;; --- Grid Item Thumbnail
|
||||||
|
|
||||||
(mf/defc grid-item-thumbnail
|
(mf/defc grid-item-thumbnail
|
||||||
|
@ -57,14 +37,16 @@
|
||||||
{:wrap [mf/wrap-memo]}
|
{:wrap [mf/wrap-memo]}
|
||||||
[{:keys [file] :as props}]
|
[{:keys [file] :as props}]
|
||||||
(let [local (mf/use-state {})
|
(let [local (mf/use-state {})
|
||||||
on-navigate #(st/emit! (udp/go-to (:id file)))
|
on-navigate #(st/emit! (rt/nav :workspace
|
||||||
delete-fn #(st/emit! nil (udp/delete-file (:id file)))
|
{:file-id (:id file)}
|
||||||
|
{:page-id (first (:pages file))}))
|
||||||
|
delete-fn #(st/emit! nil (dsh/delete-file (:id file)))
|
||||||
on-delete #(do
|
on-delete #(do
|
||||||
(dom/stop-propagation %)
|
(dom/stop-propagation %)
|
||||||
(modal/show! confirm-dialog {:on-accept delete-fn}))
|
(modal/show! confirm-dialog {:on-accept delete-fn}))
|
||||||
|
|
||||||
on-blur #(let [name (-> % dom/get-target dom/get-value)]
|
on-blur #(let [name (-> % dom/get-target dom/get-value)]
|
||||||
(st/emit! (udp/rename-file (:id file) name))
|
(st/emit! (dsh/rename-file (:id file) name))
|
||||||
(swap! local assoc :edition false))
|
(swap! local assoc :edition false))
|
||||||
|
|
||||||
on-key-down #(when (kbd/enter? %) (on-blur %))
|
on-key-down #(when (kbd/enter? %) (on-blur %))
|
||||||
|
@ -106,9 +88,6 @@
|
||||||
(let [locale (i18n/use-locale)
|
(let [locale (i18n/use-locale)
|
||||||
order (:order opts :modified)
|
order (:order opts :modified)
|
||||||
filter (:filter opts "")
|
filter (:filter opts "")
|
||||||
files (->> files
|
|
||||||
(filter-by filter)
|
|
||||||
(sort-by order))
|
|
||||||
on-click #(do
|
on-click #(do
|
||||||
(dom/prevent-default %)
|
(dom/prevent-default %)
|
||||||
(st/emit! (dsh/create-file id)))]
|
(st/emit! (dsh/create-file id)))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue