Skip to content

Commit

Permalink
OK-781: Koskesta haettujen tutkintojen visualisointi katselmointi-näk…
Browse files Browse the repository at this point in the history
…ymässä
  • Loading branch information
pitkamak committed Jan 7, 2025
1 parent d09d1db commit f1b4362
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 43 deletions.
26 changes: 19 additions & 7 deletions resources/less/virkailija-application.less
Original file line number Diff line number Diff line change
Expand Up @@ -3607,15 +3607,27 @@ th.application__readonly-adjacent--header {

}
}

.application__tutkinto-wrapper-readonly {
border-bottom: solid 1px @review-separator-color;
margin-bottom: 30px;
min-height: 65px;
display: flex;
flex-direction: column;
flex-direction: row;

&:last-child {
margin-bottom: 10px;
.tutkinto-contents {
border-bottom: solid 1px @review-separator-color;
margin-bottom: 30px;
min-height: 65px;
display: flex;
flex-direction: column;

&:last-child {
margin-bottom: 10px;
}
}

.koski-originated-tutkinto-tag {
background-color: @neutral-grey-200;
display: inline-flex;
flex-direction: column;
padding: 10px;
height: fit-content;
}
}
2 changes: 1 addition & 1 deletion spec/ataru/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

(defrecord MockKoskiTutkintoService [koski-cas-client]
KoskiTutkintoService
(get-tutkinnot-for-oppija [_ _] {}))
(get-tutkinnot-for-oppija [_ _ _] {}))

(defn- default-get-parametri [_ _] {:jarjestetytHakutoiveet true})

Expand Down
4 changes: 2 additions & 2 deletions src/clj/ataru/applications/application_service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@
:person-oid
(person-service/get-person person-service)
:oppijanumero))
koski-tutkinnot (future (some->> (when requested-tutkinto-levels (:person-oid application))
(koski/get-tutkinnot-for-oppija koski-service)
koski-tutkinnot (future (some->> (when (tutkinto-util/koski-tutkinnot-in-application? application) (:person-oid application))
(koski/get-tutkinnot-for-oppija koski-service false)
:opiskeluoikeudet
(parse-koski-tutkinnot requested-tutkinto-levels)))]
(util/remove-nil-values {:application (-> application
Expand Down
2 changes: 1 addition & 1 deletion src/clj/ataru/applications/excel_export.clj
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@
ehdollinen? (delay (get-ehdollinen? get-hakukohde hakukohteiden-ehdolliset application selected-hakukohde-oids))
tutkinnot (some->> (when
(tutkinto-util/koski-tutkinnot-in-application? application) (:person-oid application))
(koski/get-tutkinnot-for-oppija koski-service)
(koski/get-tutkinnot-for-oppija koski-service false)
:opiskeluoikeudet
(parse-koski-tutkinnot tutkinto-levels)
(tutkinto-util/sort-koski-tutkinnot))]
Expand Down
5 changes: 3 additions & 2 deletions src/clj/ataru/hakija/hakija_application_service.clj
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,9 @@
application-in-processing?
field-deadlines))
requested-tutkinto-levels (tutkinto-util/koski-tutkinto-levels-in-form form)
koski-tutkinnot (future (some->> (when requested-tutkinto-levels (:person-oid application))
(koski-service/get-tutkinnot-for-oppija koski-service)
koski-tutkinnot (future (some->> (when (tutkinto-util/koski-tutkinnot-in-application? application)
(:person-oid application))
(koski-service/get-tutkinnot-for-oppija koski-service true)
:opiskeluoikeudet
(parse-koski-tutkinnot requested-tutkinto-levels)))
new-person (application-service/get-person-for-securelink application-service application)
Expand Down
2 changes: 1 addition & 1 deletion src/clj/ataru/hakija/hakija_routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
session (oss/read-session oppija-session)
tutkinto-level-list (str/split tutkinto-levels #",")]
(if-let [henkilo-oid (get-in session [:data :person-oid])]
(if-let [oppija-response (koski/get-tutkinnot-for-oppija koski-service henkilo-oid)]
(if-let [oppija-response (koski/get-tutkinnot-for-oppija koski-service true henkilo-oid)]
(response/ok (parse-koski-tutkinnot tutkinto-level-list (:opiskeluoikeudet oppija-response)))
(response/not-found {}))
(response/unauthorized {}))))
Expand Down
12 changes: 7 additions & 5 deletions src/clj/ataru/koski/koski_service.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
(ns ataru.koski.koski-service
(:require [ataru.koski.koski-client :as koski-client]))
(:require [taoensso.timbre :as log]
[ataru.koski.koski-client :as koski-client]))

(defprotocol KoskiTutkintoService
(get-tutkinnot-for-oppija [this oppija-oid]
(get-tutkinnot-for-oppija [this throw-errors oppija-oid]
"Gets all available tutkinnot for oppija"))

;TODO korjaa tai poista logitus
(defrecord IntegratedKoskiTutkintoService [koski-cas-client]
KoskiTutkintoService
(get-tutkinnot-for-oppija [_ oppija-oid]
(get-tutkinnot-for-oppija [_ throw-errors oppija-oid]
(try
(koski-client/get-tutkinnot-for-oppija-oid oppija-oid koski-cas-client)
(catch Exception exp
(println (str "!!!!!!!!!!!!!!!!!!!! error " exp))))))
(log/error exp "Failed to fetch tutkinnot from koski")
(when throw-errors
(throw exp))))))
12 changes: 11 additions & 1 deletion src/cljc/ataru/translations/texts.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,17 @@
:en "EN: Hakija ei ole maksuvelvollinen"}
:tutkinnot {:fi "Tutkintotiedot Koski-Palvelusta"
:sv "SV: Tutkintotiedot Koski-Palvelusta"
:en "EN: Tutkintotiedot Koski-Palvelusta"}})
:en "EN: Tutkintotiedot Koski-Palvelusta"}
:koski-originated-tutkinto-tag-first-row {:fi "Tutkinnon tiedot haettu"
:sv "SV: Tutkinnon tiedot haettu"
:en "EN: Tutkinnon tiedot haettu"}
:koski-originated-tutkinto-tag-second-row {:fi "KOSKI-järjestelmästä"
:sv "SV: KOSKI-järjestelmästä"
:en "EN: KOSKI-järjestelmästä"}
:koski-tutkinto-fetch-failed {:fi "Tutkintotietojen haku KOSKI-järjestelmästä epäonnistui"
:sv "SV: Tutkintotietojen haku KOSKI-järjestelmästä epäonnistui"
:en "EN: Tutkintotietojen haku KOSKI-järjestelmästä epäonnistui"}})

(def state-translations
{:active {:fi "Aktiivinen"
:sv "Aktiv"
Expand Down
2 changes: 1 addition & 1 deletion src/cljc/ataru/tutkinto/tutkinto_util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
(flatten (map :followups selected-levels))))

(defn is-koski-tutkinto-id-field? [field-id]
(boolean (when (str/ends-with? field-id ktm/tutkinto-id-field-postfix)
(boolean (when (and field-id (str/ends-with? field-id ktm/tutkinto-id-field-postfix))
(let [tutkinto-level (str/replace field-id (str "-" ktm/tutkinto-id-field-postfix) "")]
(some #{tutkinto-level} ktm/koski-tutkinto-tasot)))))

Expand Down
10 changes: 1 addition & 9 deletions src/cljs/ataru/hakija/application_tutkinto_handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
[ataru.hakija.application :refer [create-initial-answers]]
[ataru.hakija.application-handlers :refer [check-schema-interceptor set-empty-value-dispatch]]))

(reg-event-fx
:application/handle-tutkinnot-error
[check-schema-interceptor]
(fn [{:keys [db]} [_ response]]
(js/console.error (str "Handle tutkinto fetch error, response " response))
{:db (assoc-in db [:oppija-session :tutkinto-fetch-handled] true)}))

(reg-event-db
:application/handle-fetch-tutkinnot
[check-schema-interceptor]
Expand All @@ -26,8 +19,7 @@
(fn [_ [_ requested-koski-levels]]
{:http {:method :get
:url (str "/hakemus/api/omat-tutkinnot?tutkinto-levels=" requested-koski-levels)
:handler [:application/handle-fetch-tutkinnot]
:error-handler [:application/handle-tutkinnot-error]}}))
:handler [:application/handle-fetch-tutkinnot]}}))

(reg-event-fx
:application/add-tutkinto-row
Expand Down
9 changes: 9 additions & 0 deletions src/cljs/ataru/virkailija/application/application_subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[ataru.component-data.person-info-module :as person-info-module]
[ataru.tarjonta.haku :as haku]
[ataru.util :as u]
[ataru.tutkinto.tutkinto-util :as tutkinto-util]
[ataru.virkailija.application.application-selectors :refer [hakukohde-oids-from-selected-hakukohde-or-hakukohderyhma
selected-application-answers
selected-hakukohde-oid-set
Expand Down Expand Up @@ -1038,6 +1039,14 @@
(and (not (person-info-module/muu-person-info-module? form))
(nil? (get-in application [:person :oid])))))

(re-frame/reg-sub
:application/show-tutkinto-fetch-failed?
(fn [_ _]
[(re-frame/subscribe [:application/selected-application])])
(fn show-tutkinto-fetch-failed? [[application] _]
(and (tutkinto-util/koski-tutkinnot-in-application? application)
(not (seq (:koski-tutkinnot application))))))

(re-frame/reg-sub
:application/filter-questions
(fn [db _]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
selected-review-hakukohde @(subscribe [:state-query [:application :selected-review-hakukohde-oids]])
show-not-latest-form? (some? @(subscribe [:state-query [:application :latest-form]]))
show-creating-henkilo-failed? @(subscribe [:application/show-creating-henkilo-failed?])
show-tutkinto-fetch-failed? @(subscribe [:application/show-tutkinto-fetch-failed?])
show-henkilo-info-incomplete? (and (some? person-oid)
(not (-> application :person :language)))
show-not-yksiloity? (and (some? person-oid)
Expand All @@ -56,6 +57,8 @@
(select-application (:key application) selected-review-hakukohde true))}])
(when show-creating-henkilo-failed? ; henkilo details are missing entirely
[notification {:text :creating-henkilo-failed}])
(when show-tutkinto-fetch-failed?
[notification {:text :koski-tutkinto-fetch-failed}])
(when show-henkilo-info-incomplete? ; henkilo is missing some essential information, such as language
[notification {:text :henkilo-info-incomplete
:link-text :review-in-henkilopalvelu
Expand Down
33 changes: 20 additions & 13 deletions src/cljs/ataru/virkailija/views/virkailija_readonly.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,26 @@
(defn- tutkinto [children application hakukohteet-and-ryhmat lang idx tutkinto]
(let [non-koski-content (filter #(not (get-in % [:params :transparent])) children)]
[:div.application__tutkinto-wrapper-readonly
(for [field (tutkinto-util/get-tutkinto-field-mappings lang)]
(let [field-id (:id field)
label-id (str "koski-answer-label-" field-id "-" idx)
field-path (if (:multi-lang? field) [(:koski-tutkinto-field field) lang] [(:koski-tutkinto-field field)])]
^{:key (str "koski-answer-" field-id "-" idx)}
[:div.application__form-field
[:div.application__form-field-label
{:id label-id}
[:span (:text field)]]
[text-form-field-values (:id field) (get-in tutkinto field-path)]]))
(for [child non-koski-content]
^{:key (str "tutkinto-" (:id child) "-" idx)}
[field child application hakukohteet-and-ryhmat lang idx false])]))
[:div.application__tutkinto-wrapper-readonly.tutkinto-contents
(when tutkinto
(for [field (tutkinto-util/get-tutkinto-field-mappings lang)]
(let [field-id (:id field)
label-id (str "koski-answer-label-" field-id "-" idx)
field-path (if (:multi-lang? field) [(:koski-tutkinto-field field) lang] [(:koski-tutkinto-field field)])]
^{:key (str "koski-answer-" field-id "-" idx)}
[:div.application__form-field
[:div.application__form-field-label
{:id label-id}
[:span (:text field)]]
[text-form-field-values (:id field) (get-in tutkinto field-path)]]))
)
(for [child non-koski-content]
^{:key (str "tutkinto-" (:id child) "-" idx)}
[field child application hakukohteet-and-ryhmat lang idx false])]
(when tutkinto
[:div.application__tutkinto-wrapper-readonly.koski-originated-tutkinto-tag
[:span @(subscribe [:editor/virkailija-translation :koski-originated-tutkinto-tag-first-row])]
[:span @(subscribe [:editor/virkailija-translation :koski-originated-tutkinto-tag-second-row])]])]))

(defn tutkinto-wrapper [_ _ _ _]
(fn [content application hakukohteet-and-ryhmat lang children]
Expand Down

0 comments on commit f1b4362

Please sign in to comment.