Skip to content

Commit

Permalink
insurance qol fixes
Browse files Browse the repository at this point in the history
creation form:

* don't default instrument category, leads to mistakes
* don't default owner when adder is a team member
* show full names in member select
  • Loading branch information
Ramblurr committed May 14, 2024
1 parent b74023d commit 6bd4f94
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion resources/lang/en.edn
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
:create-title "New Instrument"
:create-subtitle "Enter details for the Instrument"
:photo-upload "Photo Upload"
:photo-upload-title "Upload Instrument PHotos"
:photo-upload-title "Upload Instrument Photos"
:photo-upload-subtitle "Upload a couple photos showing the instrument/item from several angles."
:images-share-url "Photos Public Link"
:images-share-url-hint "Use this link when sharing outside the band"}
Expand Down
4 changes: 0 additions & 4 deletions src/clj/app/insurance/controller.clj
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@
:db/id "covered_instrument"}
[:db/add [:insurance.policy/policy-id policy-id] :insurance.policy/covered-instruments "covered_instrument"]])))



(defn update-instrument-tx [{:keys [description build-year serial-number make instrument-name owner-member-id model category-id] :as decoded} instrument-id]
{:instrument/instrument-id instrument-id
:instrument/description description
Expand All @@ -439,8 +437,6 @@
:instrument/owner [:member/member-id owner-member-id]
:instrument/category [:instrument.category/category-id category-id]})



(defn upsert-instrument! [req]
(let [decoded (util/remove-nils (s/decode UpdateInstrument (util.http/unwrap-params req)))]
(if (s/valid? UpdateInstrument decoded)
Expand Down
23 changes: 19 additions & 4 deletions src/clj/app/insurance/views.clj
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,29 @@ Mit freundlichen Grüßen,
(instrument-form req error instrument {}))
([{:keys [tr db] :as req} error {:instrument/keys [name owner make model build-year serial-number description category] :as instrument} {:keys [hide-owner?] :as opts}]

(let [owner-id (if (:member/member-id owner)
(let [current-member (auth/get-current-member req)
;; the logic here is that when creating a new instrument, if the creator is an insurance
;; team member, we don't want to default the owner to themselves (because it happens that
;; they add the instrument to themselves when they probably want to add it to someone else)
;; but if its a normal-member then we do (to make it easier for them)
insurance-team-member? (q/insurance-team-member? db current-member)
owner-id (if (:member/member-id owner)
(:member/member-id owner)
(:member/member-id (auth/get-current-member req)))]
(if insurance-team-member?
nil
(:member/member-id current-member)))]

(list
(ui/text-left :label (tr [:instrument/name]) :id "instrument-name" :value name :error error)
(when-not hide-owner?
(ui/member-select :variant :left :label (tr [:instrument/owner]) :id "owner-member-id" :value owner-id :members (q/members-for-select db) :error error))
(ui/member-select :with-empty-opt? insurance-team-member?
:full-names? true
:variant :left
:label (tr [:instrument/owner])
:id "owner-member-id"
:value owner-id
:members (q/members-for-select db)
:error error))
(ui/instrument-category-select :variant :left :label (tr [:instrument/category]) :id "category-id" :value (:instrument.category/category-id category) :categories (controller/instrument-categories db) :error error)
(ui/text-left :label (tr [:instrument/make]) :id "make" :value make :error error)
(ui/text-left :label (tr [:instrument/model]) :hint (tr [:instrument/if-available]) :id "model" :value model :required? false :error error)
Expand Down Expand Up @@ -608,7 +623,7 @@ Mit freundlichen Grüßen,
(tr [:insurance/confirm-mark-as] [%])
(tr [:insurance/confirm-mark-as-button])
(tr [:action/cancel]))
common-attrs {:hx-post endpoint-mark-as :hx-target hx-target :hx-include "input.mark-coverage-as-data" }]
common-attrs {:hx-post endpoint-mark-as :hx-target hx-target :hx-include "input.mark-coverage-as-data"}]
(ui/action-menu
:label (tr [:action/mark-as])
:sections [{:label "Workflow Status"
Expand Down
22 changes: 15 additions & 7 deletions src/clj/app/ui.clj
Original file line number Diff line number Diff line change
Expand Up @@ -528,16 +528,20 @@
(:section/name section)
"No Section"))

(defn member-select [& {:keys [id value label members variant with-empty-opt? error]
(defn member-select [& {:keys [id value label members variant with-empty-opt? error full-names?]
:or {label "Member"
full-names? false
variant :inline
with-empty-opt? false}}]
(let [options
(concat
(if with-empty-opt?
[{:value "" :label " - "}] [])
(->> members
(map (fn [m] {:value (:member/member-id m) :label (member-nick m)}))
(map (fn [m] {:value (:member/member-id m)
:label (if full-names?
(:member/name m)
(member-nick m))}))
(util/isort-by :label)))]
(condp = variant
:inline (select :id id
Expand Down Expand Up @@ -600,14 +604,18 @@
:value value
:options options))))

(defn instrument-category-select [& {:keys [id value label categories :variant]
(defn instrument-category-select [& {:keys [id value label categories variant with-empty-opt?]
:or {label "Instrument Category"
with-empty-opt? true
variant :inline}}]
(let [options
(map (fn [c]
{:value (:instrument.category/category-id c)
:label (:instrument.category/name c)})
categories)]
(concat
(if with-empty-opt?
[{:value "" :label " - "}] [])
(map (fn [c]
{:value (:instrument.category/category-id c)
:label (:instrument.category/name c)})
categories))]
(condp = variant
:inline
(select :id id
Expand Down

0 comments on commit 6bd4f94

Please sign in to comment.