Skip to content

Commit

Permalink
Number 6: Pilgrimage checkbox for certain activities (depends on type…
Browse files Browse the repository at this point in the history
… also)
  • Loading branch information
Deraen committed Oct 17, 2024
1 parent b8f671e commit 8ce2bfd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
51 changes: 42 additions & 9 deletions webapp/src/cljc/lipas/data/activities.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,33 @@
(assoc-in [:description-short :field :description :en]
"Presentation of 1-3 sentences about the route and its specific properties.")))


(def common-props-schema
(collect-schema common-props))

(comment
(m/schema common-props-schema))

;; :show callback is added into the two activities to control which type-codes
;; should display this field.
;; Currently only the routes component in the UI side uses this :show option.
;;
;; outdoor-recreation-routes paitsi 4402 (hiihtolatu)
;; cycling (kaikki)
;; paddling paitsi 4452 (vesiretkeilyreitti) ja 5150 (ei routes dataa)
(def pilgrimage-field
{:schema [:boolean {:optional true}]
:field
{:type "checkbox"
:description {:fi "Jos kohde on pyhiinvaellusreitti, aktivoi liukukytkin. HUOM! Pyhiinvaellusreitti on ulkoilureitti, joka tarjoaa mahdollisuuden liikkumiseen, hiljentymiseen ja hengellisyyteen/henkisyyteen.  Reitin varrelle on rakennettu mobiilisti tai maastoon opasteita ja sisältöjä, jotka ohjaavat vaeltajaa."
:se ""
:en ""}
:label {:fi "Pyhinvaelluskohde"
:se ""
:en "Pilgrimage destination"}}})

(def pilgrimage-key-schema
[:pilgrimage {:optional true} :boolean])

(def outdoor-recreation-areas
{:label {:fi "Retkeily ja ulkoilualueet"
:se "Utomhusrekreation och naturområden"
Expand Down Expand Up @@ -573,6 +593,7 @@
:accessibility-classification
:accessibility
:accessibility-categorized
:pilgrimage
:contacts
:additional-info-link
:images
Expand Down Expand Up @@ -605,7 +626,8 @@
[:surface-material {:optional true} surface-material-schema]
[:accessibility-classification
(into [:enum] (keys accessibility-classification))]
[:independent-entity {:optional true} [:boolean]]])]
[:independent-entity {:optional true} [:boolean]]
pilgrimage-key-schema])]
:field
{:type "routes"
:description {:fi "Reittikokonaisuus, päiväetappi, vaativuusosuus"
Expand Down Expand Up @@ -793,7 +815,10 @@
:en "Activate the slider if the route is not a part of any region or a broader entity (e.g. recreational area or national park). The activated slider turns red."}
:label {:fi "Itsenäinen kohde"
:se "Fristående plats"
:en "Standalone place"}}}})}}}})
:en "Standalone place"}}}

:pilgrimage (assoc pilgrimage-field :show (fn [{:keys [type-code]}]
(not (#{4402} type-code))))})}}}})

(def outdoor-recreation-routes-schema
(collect-schema (:props outdoor-recreation-routes)))
Expand Down Expand Up @@ -895,13 +920,13 @@
:food-and-water
:good-to-know
:accessibility
:pilgrimage
:contacts
:additional-info-link
:images
:videos]
:props
{
;; Päiväetapit pitää pystyä esittelemään erikseen kartalla ja
{;; Päiväetapit pitää pystyä esittelemään erikseen kartalla ja
;; kuvailemaan omana kohteenaan. Reittikokonaisuus olisi päätason
;; liikuntapaikka (alatasona päiväetapit, jotka ovat ehdotusmaisia
;; etappeja).
Expand All @@ -927,7 +952,8 @@
[:surface-material {:optional true} surface-material-schema]
[:unpaved-percentage {:optional true} percentage-schema]
[:trail-percentage {:optional true} percentage-schema]
[:cyclable-percentage {:optional true} percentage-schema]])]
[:cyclable-percentage {:optional true} percentage-schema]
pilgrimage-key-schema])]
:field
{:type "routes"
:description {:fi "Reittikokonaisuus, päiväetappi, vaativuusosuus"
Expand Down Expand Up @@ -1087,7 +1113,9 @@
:en "Surface material"}
:description {:fi "Valitse kaikki pintamateriaalit, joita reitillä kuljetaan"
:se "Välj alla underlag som finns på rutten."
:en "Select all the surface materials on the route"}}}})}}}})
:en "Select all the surface materials on the route"}}}

:pilgrimage pilgrimage-field})}}}})

(def cycling-schema
(collect-schema (:props cycling)))
Expand Down Expand Up @@ -1180,6 +1208,7 @@
:rules
:safety
:accessibility
:pilgrimage
:contacts
:additional-info-link
:images
Expand Down Expand Up @@ -1252,7 +1281,8 @@
[:travel-direction {:optional true} [:enum "clockwise" "counter-clockwise"]]
[:safety {:optional true} localized-string-schema]
[:good-to-know {:optional true} localized-string-schema]
[:duration {:optional true} duration-schema]])]
[:duration {:optional true} duration-schema]
pilgrimage-key-schema])]
:field
{:type "routes"
:description {:fi "Reittikokonaisuus, päiväetappi, vaativuusosuus"
Expand Down Expand Up @@ -1373,7 +1403,10 @@
:en "If the route has a recommended travelling direction (clockwise, counterclockwise), choose it here."}
:label {:fi "Kulkusuunta"
:se "Färdriktning"
:en "Travel direction"}}}})}}})})
:en "Travel direction"}}}

:pilgrimage (assoc pilgrimage-field :show (fn [{:keys [type-code]}]
(= 4451 type-code)))})}}})})

(def paddling-schema
(collect-schema (:props paddling)))
Expand Down
19 changes: 12 additions & 7 deletions webapp/src/cljs/lipas/ui/sports_sites/activities/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@
(defn image-dialog
[{:keys [tr locale helper-text dialog-state on-save on-close lipas-id image-props]}]
(let [description-length-error (> (-> @dialog-state :data :description (get locale) count) 255)]
(js/console.log (> (-> @dialog-state :data :description (get locale) count) 255))
[lui/dialog
{:title (if (-> @dialog-state :data :url)
(tr :utp/photo)
Expand Down Expand Up @@ -854,10 +853,12 @@
#{:arrival :rules :rules-structured :permits-rules-guidelines :highlights})

(defn route-form
[{:keys [locale geom-type lipas-id route-props state read-only? field-sorter]}]
[{:keys [locale geom-type lipas-id type-code route-props state read-only? field-sorter]}]
[nice-form {:read-only? read-only?}
(doall
(for [[prop-k {:keys [field]}] (sort-by field-sorter utils/reverse-cmp route-props)]
(for [[prop-k {:keys [field show]}] (sort-by field-sorter utils/reverse-cmp route-props)
:when (or (nil? show)
(show {:type-code type-code}))]
(when-not (and
(contains? route-props :independent-entity)
(not (:independent-entity @state))
Expand All @@ -877,7 +878,7 @@
:lipas-id lipas-id}])))])

(defn single-route
[{:keys [read-only? route-props lipas-id _display-data _edit-data
[{:keys [read-only? route-props lipas-id type-code _display-data _edit-data
locale geom-type label description set-field activity-k
route]
:as props}]
Expand All @@ -896,6 +897,7 @@
:tr tr
:field-sorter field-sorter
:lipas-id lipas-id
:type-code type-code
:read-only? read-only?
:geom-type geom-type
:route-props route-props
Expand All @@ -905,7 +907,7 @@
(remove-watch route-form-state :lol))))

(defn multiple-routes
[{:keys [read-only? route-props lipas-id _display-data _edit-data
[{:keys [read-only? route-props lipas-id type-code _display-data _edit-data
locale geom-type label description set-field activity-k]
:as props}]
(r/with-let [route-form-state (r/atom {})]
Expand Down Expand Up @@ -977,6 +979,7 @@
:tr tr
:field-sorter field-sorter
:lipas-id lipas-id
:type-code type-code
:read-only? read-only?
:geom-type geom-type
:route-props route-props
Expand Down Expand Up @@ -1025,7 +1028,7 @@

(defn routes
[{:keys [read-only? route-props lipas-id _display-data _edit-data
locale geom-type label description set-field activity-k]
locale geom-type label description set-field activity-k type-code]
:as props}]
(let [route-view (<== [::subs/route-view])
routes (<== [::subs/routes lipas-id activity-k])
Expand Down Expand Up @@ -1069,7 +1072,7 @@
[mui/form-helper-text description])]))

(defn make-field
[{:keys [field edit-data locale prop-k read-only? lipas-id set-field activity-k]}]
[{:keys [field edit-data locale prop-k read-only? lipas-id set-field activity-k type-code]}]
(case (:type field)

"select" [lui/select
Expand Down Expand Up @@ -1186,6 +1189,7 @@
:route-props (:props field)
:set-field (partial set-field prop-k)
:activity-k activity-k
:type-code type-code
:value (get-in edit-data [prop-k])}]

"duration" [duration
Expand Down Expand Up @@ -1297,6 +1301,7 @@
:display-data (get-in display-data [:activities activity-k])
:locale locale
:activity-k activity-k
:type-code type-code
:set-field set-field
:geom-type geom-type
:lipas-id lipas-id}])]]
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/cljs/lipas/ui/sports_sites/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
[lipas.ui.sports-sites.football.db :as football]
[lipas.ui.utils :as utils]))

;; FIXME: What is the benefit of moving static data to re-frame app-db?
;; This breaks editing the data ns and getting the result visible right away.

(def default-db
{:statuses sports-sites/statuses
:document-statuses sports-sites/document-statuses ;; unused?
Expand Down

0 comments on commit 8ce2bfd

Please sign in to comment.