Skip to content

Commit

Permalink
subfields (:many) can be specified per attr
Browse files Browse the repository at this point in the history
TODO: figure out how to determine 'persisted-value' for nested data
  • Loading branch information
mhuebert committed Dec 24, 2023
1 parent 71e932c commit b8494b6
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 215 deletions.
4 changes: 2 additions & 2 deletions deps.edn
Expand Up @@ -5,9 +5,9 @@

;; v2
datalevin/datalevin {:mvn/version "0.8.21"}
io.github.mhuebert/re-db {:git/sha "a01298e075889ab0ac5b9f2afe751ae5e8d20613"}
io.github.mhuebert/re-db {:git/sha "479a57401635f3a11ab128226976c6388b5f7f2c"}
io.github.mhuebert/yawn {:git/sha "68285f6c132f26a2ff3cc2f7dffc3fe68c9856d9"}
io.github.mhuebert/inside-out {:git/sha "003ad6fbb282d5e49ccefa5a44cecae467e54183"}
io.github.mhuebert/inside-out {:git/sha "6f8a4f4413f344d59da2ed55ddb1a0e9090c30b7"}

;; Google Cloud
com.google.firebase/firebase-admin {:mvn/version "6.13.0"}
Expand Down
64 changes: 41 additions & 23 deletions src/sb/app.cljc
@@ -1,8 +1,10 @@
(ns sb.app
(:require [sb.app.account.ui]
(:require [inside-out.forms :as io]
[org.sparkboard.slack.schema]
[sb.app.account.ui]
[sb.app.asset.ui]
[sb.app.board.ui]
[sb.app.board.admin-ui]
[sb.app.board.ui]
[sb.app.chat.ui]
[sb.app.collection.ui]
[sb.app.content.ui]
Expand All @@ -14,34 +16,50 @@
[sb.app.form.ui :as form.ui]
[sb.app.member.ui]
[sb.app.notification.ui]
[sb.app.org.admin-ui]
[sb.app.org.ui]
sb.app.org.admin-ui
[sb.app.project.ui]
[sb.app.social-feed.ui]
[sb.app.vote.ui]
[org.sparkboard.slack.schema]
[sb.i18n :refer [t]]
[sb.transit :as t]
[inside-out.forms :as io]
[sb.i18n :refer [t]]))
[sb.util :as u]))

#?(:cljs
(def client-endpoints (t/read (shadow.resource/inline "public/js/sparkboard.views.transit.json"))))

(defn fields-editor-field []
(io/field :many (u/prune {:field/id ?id
:field/type ?type
:field/label ?label
:field/hint ?hint
:field/options (?options :many {:field-option/label ?label
:field-option/value ?value
:field-option/color ?color})
:field/required? ?required?
:field/show-as-filter? ?show-as-filter?
:field/show-at-registration? ?show-at-registration?
:field/show-on-card? ?show-on-card?})))

(def global-field-meta
{:account/email {:view field.ui/text-field
:props {:type "email"
:placeholder (t :tr/email)}
:validators [form.ui/email-validator]}
:account/password {:view field.ui/text-field
:props {:type "password"
:placeholder (t :tr/password)}
:validators [(io/min-length 8)]}
:entity/title {:validators [(io/min-length 3)]}
:board/project-fields {:view field.admin-ui/fields-editor}
:board/member-fields {:view field.admin-ui/fields-editor}
:field/label {:view field.ui/text-field}
:field/hint {:view field.ui/text-field}
:field/options {:view field.admin-ui/options-editor}
:entity/domain-name {:view domain.ui/domain-field
:validators (domain.ui/validators)}
:image/avatar {:view field.ui/image-field}})
{:account/email {:view field.ui/text-field
:props {:type "email"
:placeholder (t :tr/email)}
:validators [form.ui/email-validator]}
:account/password {:view field.ui/text-field
:props {:type "password"
:placeholder (t :tr/password)}
:validators [(io/min-length 8)]}
:entity/title {:validators [(io/min-length 3)]}
:board/project-fields {:view field.admin-ui/fields-editor
:make-field fields-editor-field
:props {:wrap u/prune}}
:board/member-fields {:view field.admin-ui/fields-editor
:make-field fields-editor-field
:props {:wrap u/prune}}
:field/label {:view field.ui/text-field}
:field/hint {:view field.ui/text-field}
:field/options {:view field.admin-ui/options-editor}
:entity/domain-name {:view domain.ui/domain-field
:validators (domain.ui/validators)}
:image/avatar {:view field.ui/image-field}})
1 change: 1 addition & 0 deletions src/sb/app/asset/data.cljc
Expand Up @@ -53,6 +53,7 @@
:asset.variant/provider]}



:image/avatar (sch/ref :one :asset/as-map)
:image/logo-large (sch/ref :one :asset/as-map)
:image/footer (sch/ref :one :asset/as-map)
Expand Down
158 changes: 59 additions & 99 deletions src/sb/app/board/admin_ui.cljc
@@ -1,11 +1,12 @@
(ns sb.app.board.admin-ui
(:require [inside-out.forms :as io]
[sb.app.board.data :as data]
[sb.app.entity.ui :as entity.ui :refer [use-persisted-attr view-field]]
[sb.app.entity.ui :as entity.ui :refer [use-persisted-field view-field]]
[sb.app.views.header :as header]
[sb.app.views.radix :as radix]
[sb.app.views.ui :as ui]
[sb.i18n :refer [t]]
[sb.util :as u]
[yawn.hooks :as h]))

;; issue
Expand All @@ -17,101 +18,60 @@
{:route "/b/:board-id/settings"}
[{:as params :keys [board-id]}]
(when-let [board (data/settings params)]
(prn (:board/member-fields board))
(ui/with-form [?board
{:entity/title ?title
:entity/description ?description
:entity/domain-name ?domain-name
:image/avatar ?avatar
:board/member-fields (?member-fields :many
{:field/id ?id
:field/type ?type
:field/label ?label
:field/hint ?hint
:field/options
(?options :many
{:field-option/label ?label
:field-option/value ?value
:field-option/color ?color})

:field/required? ?required?
:field/show-as-filter? ?show-as-filter?
:field/show-at-registration? ?show-at-registration?
:field/show-on-card? ?show-on-card?})
:board/project-fields (?project-fields :many
{:field/id ?id
:field/type ?type
:field/label ?label
:field/hint ?hint
:field/options
(?options :many
{:field-option/label ?label
:field-option/value ?value
:field-option/color ?color})

:field/required? ?required?
:field/show-as-filter? ?show-as-filter?
:field/show-at-registration? ?show-at-registration?
:field/show-on-card? ?show-on-card?})
:board/registration-open? ?registration-open?
:board/registration-url-override ?registration-url-override
:board/registration-page-message ?registration-page-message
:board/invite-email-text ?invite-email-text}
:init board
:form/entity.id (:entity/id board)]
[:<>
(header/entity board (list (entity.ui/settings-button board)))
[radix/accordion {:class "max-w-[600px] mx-auto my-6 flex-v gap-6"
:multiple true}

[:div.field-label (t :tr/basic-settings)]
[:div.flex-v.gap-4

(view-field ?title)
(view-field ?description)
(view-field ?domain-name)
(view-field ?avatar {:label (t :tr/image.logo)})]


[:div.field-label (t :tr/projects-and-members)]
[:div.flex-v.gap-4
(view-field ?member-fields)
(view-field ?project-fields)]


[:div.field-label (t :tr/registration)]
[:div.flex-v.gap-4
(view-field ?registration-open?)
(view-field ?registration-url-override)
(view-field ?registration-page-message)
(view-field ?invite-email-text)]]



;; TODO
;; - :board/project-sharing-buttons
;; - :board/member-tags

;; Registration
;; - :board/registration-invitation-email-text
;; - :board/registration-newsletter-field?
;; - :board/registration-open?
;; - :board/registration-message
;; - :board/registration-url-override
;; - :board/registration-codes

;; Theming
;; - border radius
;; - headline font
;; - accent color

;; Sponsors
;; - logo area with tiered sizes/visibility

;; Sticky Notes
;; - schema: a new entity type (not a special kind of project)
;; - modify migration based on ^new schema
;; - color is picked per sticky note
;; - sticky notes can include images/videos

])))

[:<>
(header/entity board (list (entity.ui/settings-button board)))
[radix/accordion {:class "max-w-[600px] mx-auto my-6 flex-v gap-6"
:multiple true}

[:div.field-label (t :tr/basic-settings)]
[:div.flex-v.gap-4

(use-persisted-field board :entity/title)
(use-persisted-field board :entity/description)
(use-persisted-field board :entity/domain-name)
(use-persisted-field board :image/avatar {:label (t :tr/image.logo)})]


[:div.field-label (t :tr/projects-and-members)]
[:div.flex-v.gap-4
(use-persisted-field board :board/member-fields #_{:wrap u/prune})
(use-persisted-field board :board/project-fields #_{:wrap u/prune})]


[:div.field-label (t :tr/registration)]
[:div.flex-v.gap-4
(use-persisted-field board :board/registration-open?)
(use-persisted-field board :board/registration-url-override)
(use-persisted-field board :board/registration-page-message)
(use-persisted-field board :board/invite-email-text)]]



;; TODO
;; - :board/project-sharing-buttons
;; - :board/member-tags

;; Registration
;; - :board/registration-invitation-email-text
;; - :board/registration-newsletter-field?
;; - :board/registration-open?
;; - :board/registration-message
;; - :board/registration-url-override
;; - :board/registration-codes

;; Theming
;; - border radius
;; - headline font
;; - accent color

;; Sponsors
;; - logo area with tiered sizes/visibility

;; Sticky Notes
;; - schema: a new entity type (not a special kind of project)
;; - modify migration based on ^new schema
;; - color is picked per sticky note
;; - sticky notes can include images/videos

]))

0 comments on commit b8494b6

Please sign in to comment.