mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 12:59:12 -05: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)))))))
|
||||
|
||||
|
||||
(defn initialize-team
|
||||
(defn initialize-recent
|
||||
[team-id]
|
||||
(us/verify ::us/uuid team-id)
|
||||
(ptk/reify ::initialize-team
|
||||
|
@ -132,7 +132,7 @@
|
|||
(ptk/reify ::projects-fetched
|
||||
ptk/UpdateEvent
|
||||
(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)))))
|
||||
|
||||
;; --- Fetch Files
|
||||
|
@ -252,9 +252,13 @@
|
|||
|
||||
ptk/WatchEvent
|
||||
(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)
|
||||
(rx/ignore))))))
|
||||
(rx/map (fn [_] (initialize-recent (:team-id local)))))))))
|
||||
|
||||
|
||||
;; --- Create File
|
||||
|
|
|
@ -13,29 +13,9 @@
|
|||
[uxbox.main.ui.confirm :refer [confirm-dialog]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.i18n :as i18n :refer [t tr]]
|
||||
[uxbox.util.router :as rt]
|
||||
[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
|
||||
|
||||
(mf/defc grid-item-thumbnail
|
||||
|
@ -57,14 +37,16 @@
|
|||
{:wrap [mf/wrap-memo]}
|
||||
[{:keys [file] :as props}]
|
||||
(let [local (mf/use-state {})
|
||||
on-navigate #(st/emit! (udp/go-to (:id file)))
|
||||
delete-fn #(st/emit! nil (udp/delete-file (:id file)))
|
||||
on-navigate #(st/emit! (rt/nav :workspace
|
||||
{:file-id (:id file)}
|
||||
{:page-id (first (:pages file))}))
|
||||
delete-fn #(st/emit! nil (dsh/delete-file (:id file)))
|
||||
on-delete #(do
|
||||
(dom/stop-propagation %)
|
||||
(modal/show! confirm-dialog {:on-accept delete-fn}))
|
||||
|
||||
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))
|
||||
|
||||
on-key-down #(when (kbd/enter? %) (on-blur %))
|
||||
|
@ -106,9 +88,6 @@
|
|||
(let [locale (i18n/use-locale)
|
||||
order (:order opts :modified)
|
||||
filter (:filter opts "")
|
||||
files (->> files
|
||||
(filter-by filter)
|
||||
(sort-by order))
|
||||
on-click #(do
|
||||
(dom/prevent-default %)
|
||||
(st/emit! (dsh/create-file id)))]
|
||||
|
|
Loading…
Add table
Reference in a new issue