Skip to content

Commit

Permalink
fix tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuebert committed Jan 11, 2024
1 parent 353aae7 commit 72078db
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 235 deletions.
21 changes: 11 additions & 10 deletions src/sb/app/account/data.cljc
Expand Up @@ -45,16 +45,17 @@
{:endpoint {:query true}
:prepare az/with-account-id!}
[{:keys [account-id]}]
(->> (q/pull '[{:member/_account [:member/roles
:member/last-visited
{:member/entity [:entity/id
:entity/kind
:entity/title
{:image/avatar [:entity/id]}
{:image/background [:entity/id]}]}]}]
account-id)
:member/_account
(map #(u/lift-key % :member/entity))))
(u/timed `all
(->> (q/pull '[{:member/_account [:member/roles
:member/last-visited
{:member/entity [:entity/id
:entity/kind
:entity/title
{:image/avatar [:entity/id]}
{:image/background [:entity/id]}]}]}]
account-id)
:member/_account
(map #(u/lift-key % :member/entity)))))

(q/defquery recent-ids
{:endpoint {:query true}
Expand Down
2 changes: 1 addition & 1 deletion src/sb/app/account/ui.cljc
Expand Up @@ -115,7 +115,7 @@
[title (t :tr/orgs)]
(limit (map entity.ui/row org))])])])
[:div.p-body
(when (empty? (:board entities))
(when (and (empty? @?filter) (empty? (:board entities)))
[ui/hero
(ui/show-markdown
(t :tr/start-board-new))
Expand Down
22 changes: 14 additions & 8 deletions src/sb/app/board/admin_ui.cljc
Expand Up @@ -18,15 +18,19 @@
{:route "/b/:board-id/settings"}
[{:as params :keys [board-id]}]
(when-let [board (data/settings params)]
(let [use-persisted (fn [attr & [props]]
(use-persisted-attr board attr (merge {:field/can-edit? true} props)))]
(let [colors (->> [(->> board :entity/member-tags (keep :tag/color))
(->> board :entity/member-fields (mapcat :field/options) (keep :field-option/color))
(->> board :entity/project-fields (mapcat :field/options) (keep :field-option/color))]
(apply concat)
(into #{}))
use-persisted (fn [attr & [props]]
(use-persisted-attr board attr (merge {:field/can-edit? true
:field/color-list colors} props)))]

[:<>
(header/entity board nil)

#_[:div {:class "max-w-[600px] mx-auto my-6 flex-v gap-6"}
(use-persisted :entity/member-tags)]

#_(for [color colors]
[:div.w-8.h-8.m-1.rounded {:key color :style {:background-color color}}])
[radix/accordion {:class "max-w-[600px] mx-auto my-6 flex-v gap-6"
:multiple true}

Expand All @@ -36,12 +40,14 @@
(use-persisted :entity/title)
(use-persisted :entity/description)
(use-persisted :entity/domain-name)
(use-persisted :image/avatar {:field/label (t :tr/logo)})]
(use-persisted :image/avatar {:field/label (t :tr/logo)})
(use-persisted :entity/member-tags)
]


[:div.field-label (t :tr/projects-and-members)]
[:div.flex-v.gap-4
(use-persisted :entity/member-tags)

(use-persisted :entity/member-fields)
(use-persisted :entity/project-fields)]

Expand Down
48 changes: 26 additions & 22 deletions src/sb/app/board/data.cljc
Expand Up @@ -105,15 +105,16 @@
{:prepare [(member.data/member:log-visit! :board-id)
(az/with-roles :board-id)]}
[{:keys [board-id member/roles]}]
(if-let [board (db/pull `[~@entity.data/entity-keys
:entity/member-tags
:entity/member-fields
:entity/project-fields
:board/registration-open?
{:entity/parent [~@entity.data/entity-keys :org/show-org-tab?]}]
board-id)]
(merge board {:member/roles roles})
(throw (ex-info "Board not found!" {:status 400}))))
(u/timed `show
(if-let [board (db/pull `[~@entity.data/entity-keys
:entity/member-tags
:entity/member-fields
:entity/project-fields
:board/registration-open?
{:entity/parent [~@entity.data/entity-keys :org/show-org-tab?]}]
board-id)]
(merge board {:member/roles roles})
(throw (ex-info "Board not found!" {:status 400})))))

(def project-fields `[~@entity.data/entity-keys])
(def member-fields [{:member/account [:entity/id
Expand All @@ -131,17 +132,19 @@
(q/defquery members
{:prepare [(az/with-roles :board-id)]}
[{:keys [board-id member/roles]}]
(->> (db/where [[:member/entity board-id]])
(remove :entity/archived?)
(mapv (db/pull `[~@entity.data/entity-keys
~@member-fields]))))
(u/timed `members
(->> (db/where [[:member/entity board-id]])
(remove :entity/archived?)
(mapv (db/pull `[~@entity.data/entity-keys
~@member-fields])))))

(q/defquery projects
{:prepare [(az/with-roles :board-id)]}
[{:keys [board-id member/roles]}]
(->> (db/where [[:entity/parent board-id]])
(remove (some-fn :entity/draft? :entity/archived?))
(mapv (db/pull project-fields))))
(u/timed `projects
(->> (db/where [[:entity/parent board-id]])
(remove (some-fn :entity/draft? :entity/archived?))
(mapv (db/pull project-fields)))))

(q/defquery drafts
{:prepare az/with-account-id}
Expand Down Expand Up @@ -180,12 +183,13 @@
(validate/assert-can-edit! account-id (dl/entity board-id))
params)]}
[{:keys [board-id member/roles]}]
(some->
(q/pull `[~@entity.data/entity-keys
:entity/member-tags
{:entity/member-fields ~field.data/field-keys}
{:entity/project-fields ~field.data/field-keys}] board-id)
(merge {:member/roles roles})))
(u/timed `settings
(some->
(q/pull `[~@entity.data/entity-keys
:entity/member-tags
{:entity/member-fields ~field.data/field-keys}
{:entity/project-fields ~field.data/field-keys}] board-id)
(merge {:member/roles roles}))))
(comment
[:ul ;; i18n stuff
[:li "suggested locales:" (str (:entity/locale-suggestions board))]
Expand Down
4 changes: 3 additions & 1 deletion src/sb/app/board/ui.cljc
Expand Up @@ -143,7 +143,9 @@

[radix/tab-content {:value (t :tr/members)}
(into [:div.grid.gap-4.grid-cols-1.md:grid-cols-2.lg:grid-cols-3]
(map (partial member.ui/card {:entity/member-fields (filter :field/show-on-card? (:entity/member-fields board))}))
(comp (ui/filtered @?filter)
(map (partial member.ui/row {:entity/member-tags (:entity/member-tags board)
:entity/member-fields (filter :field/show-on-card? (:entity/member-fields board))})))
(data/members {:board-id board-id}))
]]]]))

Expand Down

0 comments on commit 72078db

Please sign in to comment.