Skip to content

Commit

Permalink
Merge branch 'OK-786-tutkintojen-tallennus' of github.com:Opetushalli…
Browse files Browse the repository at this point in the history
…tus/ataru into MERGE__koski-tutkinnot-dev-new__OK-696__OK-799__OK-786__OK-712

# Conflicts:
#	spec/ataru/test_utils.clj
#	src/cljc/ataru/tutkinto/tutkinto_util.cljc
  • Loading branch information
pitkamak committed Jan 22, 2025
2 parents 79bdb4d + 58623d4 commit 5ec80b3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 21 deletions.
6 changes: 6 additions & 0 deletions resources/less/hakija.less
Original file line number Diff line number Diff line change
Expand Up @@ -2491,6 +2491,12 @@ th.application__readonly-adjacent--header {
}
}

.application__validation-error-item {
display: flex;
flex-flow: row nowrap;
color: @primary-green-700;
}

@media print {
.application__banner-container {
display: none;
Expand Down
3 changes: 1 addition & 2 deletions src/cljc/ataru/schema/form_properties_schema.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
(s/optional-key :order-id-prefix) (s/maybe s/Str)})

(s/defschema FormCategoryProperties
{(s/optional-key :selected-option-ids) [s/Str]
(s/optional-key :mandatory) s/Bool})
{(s/optional-key :selected-option-ids) [s/Str]})

(s/defschema TutkintoProperties
(merge FormCategoryProperties
Expand Down
3 changes: 3 additions & 0 deletions src/cljc/ataru/translations/texts.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,9 @@
:tutkintotaso-validation-info {:fi "Pakollinen tieto, hakijan on valittava vähintään yksi Koskesta tuotu tutkinto, tai syötettävä itse vähintään yksi."
:sv "SV: Pakollinen tieto, hakijan on valittava vähintään yksi Koskesta tuotu tutkinto, tai syötettävä itse vähintään yksi."
:en ""}
:tutkinto-validation-error-msg {:fi "Vähintään yksi tutkinto"
:sv "SV: Vähintään yksi tutkinto"
:en ""}
:perusopetus-label {:fi "Perusopetus"
:sv "SV: Perusopetus"
:en ""}
Expand Down
9 changes: 9 additions & 0 deletions src/cljc/ataru/tutkinto/tutkinto_util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,12 @@
(defn find-itse-syotetty-tutkinto-content [form]
(let [itse-syotetty-option (find-option-by-id (:content form) ktm/itse-syotetty-option-id)]
(:followups itse-syotetty-option)))

(defn tutkinnot-required-and-missing [flat-form-content answers]
(let [tutkinto-conf-component (some #(when (ktm/is-tutkinto-configuration-component? %) %) flat-form-content)
required? (:mandatory tutkinto-conf-component)]
(if required?
(not (util/any-answered? answers
(util/find-descendant-ids-by-parent-id flat-form-content (:id tutkinto-conf-component))))
false
)))
2 changes: 1 addition & 1 deletion src/cljc/ataru/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
(not-blank? answer)))))))

(defn any-answered? [answers fields]
(let [field-ids (map #(keyword (:id %)) (flatten-form-fields fields))]
(let [field-ids (map #(keyword %) fields)]
(some #(non-blank-answer? (get answers %)) field-ids)))

(defn remove-nil-values [m]
Expand Down
20 changes: 12 additions & 8 deletions src/cljs/ataru/hakija/application.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(:require [ataru.constants :as constants]
[ataru.util :as util]
[ataru.tutkinto.tutkinto-util :as tutkinto-util]
[ataru.translations.texts :refer [koski-tutkinnot-texts]]
[ataru.application-common.application-field-common :refer [required-validators pad sanitize-value]]
[clojure.core.match :refer [match]]))

Expand Down Expand Up @@ -229,14 +230,17 @@
first))))

(defn answers->valid-status [all-answers ui flat-form-content]
{:invalid-fields (for [field flat-form-content
:let [key (keyword (:id field))
answer (get all-answers key)]
:when (and (some? answer)
(not (:valid answer))
(get-in ui [key :visible?] true))]
{:key key
:label (:label answer)})})
(let [tutkinnot-required-and-missing? (tutkinto-util/tutkinnot-required-and-missing flat-form-content all-answers)]
{:invalid-fields (cond-> (for [field flat-form-content
:let [key (keyword (:id field))
answer (get all-answers key)]
:when (and (some? answer)
(not (:valid answer))
(get-in ui [key :visible?] true))]
{:key key
:label (:label answer)})
tutkinnot-required-and-missing?
(conj {:key nil :label (:tutkinto-validation-error-msg koski-tutkinnot-texts)}))}))

(defn- sanitize-attachment-value-by-state [value values]
(when (not= :deleting (:status values))
Expand Down
2 changes: 0 additions & 2 deletions src/cljs/ataru/hakija/application/field_visibility.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@
(or (empty? children)
(some #(get-in db [:application :ui (keyword (:id %)) :visible?])
children))))))

]
(js/console.log (str "!!!!!!!!!!!!!!!!!!! set visibility " (:id field-descriptor) ", " visible?))
(cond-> (-> db
child-visibility
option-visibility
Expand Down
3 changes: 2 additions & 1 deletion src/cljs/ataru/hakija/application_tutkinto_handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
[check-schema-interceptor]
(fn set-itse-syotetyt-visibility [db [_ show?]]
(let [itse-syotetty-content (tutkinto-util/find-itse-syotetty-tutkinto-content (:form db))
itse-syotetyt-fields (map :id (util/flatten-form-fields itse-syotetty-content))
do-show? (boolean
(or show? (util/any-answered? (get-in db [:application :answers]) itse-syotetty-content)))]
(or show? (util/any-answered? (get-in db [:application :answers]) itse-syotetyt-fields)))]
(reduce (fn [db field] (field-visibility/set-field-visibility db field do-show?))
(assoc-in db [:application :ui :show-itse-syotetyt-tutkinnot?] do-show?)
itse-syotetty-content))))
Expand Down
11 changes: 7 additions & 4 deletions src/cljs/ataru/hakija/banner.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
{:on-click toggle-show-details}
"x"]]
(map (fn [field]
(let [label (util/non-blank-val (:label field) @languages)]
[:a {:href (str "#scroll-to-" (name (:key field)))} [:div (if (empty? label)
(translations/get-hakija-translation :missing-input @lang)
label)]]))
(let [label (util/non-blank-val (:label field) @languages)
label-text (if (empty? label)
(translations/get-hakija-translation :missing-input @lang)
label)]
(if (:key field)
[:a {:href (str "#scroll-to-" (name (:key field)))} [:div label-text]]
[:div.application__validation-error-item label-text])))
(:invalid-fields @valid-status)))])]))))

(defn sent-indicator []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns ataru.virkailija.editor.components.form-properties.multiple-checkbox-component
(:require [ataru.cljs-util :as util]
[re-frame.core :refer [subscribe dispatch]]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[reagent.ratom :refer-macros [reaction]]
[reagent.core :as r]
[ataru.virkailija.editor.components.text-header-component :as text-header-component]
Expand Down Expand Up @@ -33,7 +33,7 @@
(not (nil? (some #(= (:id option) %)
currently-checked)))})
options))))
is-mandatory? (reaction @(subscribe [:editor/get-property-value :tutkinto-properties :mandatory]))]
is-mandatory? (reaction @(subscribe [:editor/get-component-value path :mandatory]))]
(fn [content followups path]
(let [option-count (count options)
list-of-selected (mapv :id (filter #((keyword (:id %)) @option-check-statuses) options))
Expand Down Expand Up @@ -67,7 +67,7 @@
:disabled @component-locked
:on-change (fn [event]
(let [checked (boolean (-> event .-target .-checked))]
(dispatch [:editor/set-property-value :tutkinto-properties :mandatory checked])))}]
(dispatch-sync [:editor/set-component-value checked path :mandatory])))}]
[:label.editor-form__checkbox-label
{:for validator-setting-id}
(get-in content [:validate-info @virkailija-lang])]]]
Expand Down

0 comments on commit 5ec80b3

Please sign in to comment.