From e20bebad87851b252146bc2768db7afa3a2ee969 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Tue, 21 May 2024 16:09:21 +0200 Subject: [PATCH 1/7] Bugfixes: Typos --- application/controllers/api/frontend/v1/stv/Student.php | 2 +- public/js/components/Stv/Studentenverwaltung/List/New.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 62a6b3e95..9649f4162 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -259,7 +259,7 @@ class Student extends FHCAPI_Controller { $this->load->library('form_validation'); - $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'callback_isValidDate', [ + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'isValidDate', [ 'isValidDate' => $this->p->t('ui', 'error_invalid_date') ]); diff --git a/public/js/components/Stv/Studentenverwaltung/List/New.js b/public/js/components/Stv/Studentenverwaltung/List/New.js index 351737e23..c02d9ba29 100644 --- a/public/js/components/Stv/Studentenverwaltung/List/New.js +++ b/public/js/components/Stv/Studentenverwaltung/List/New.js @@ -107,7 +107,7 @@ export default { this.abortController.suggestions = new AbortController(); // TODO(chris): move to fhcapi.factory - this.$fhcapi + this.$fhcApi .post('api/frontend/v1/stv/student/check', { vorname: this.formData.vorname, nachname: this.formData.nachname, From b52ea080134131ce4607323a5188344f97ce4934 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 22 May 2024 08:54:00 +0200 Subject: [PATCH 2/7] Correct Casting for stg_kz --- application/controllers/api/frontend/v1/stv/Verband.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Verband.php b/application/controllers/api/frontend/v1/stv/Verband.php index 5a7960fd5..d74b24a0e 100644 --- a/application/controllers/api/frontend/v1/stv/Verband.php +++ b/application/controllers/api/frontend/v1/stv/Verband.php @@ -145,7 +145,7 @@ class Verband extends FHCAPI_Controller $this->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester ORDER BY verband, gruppe LIMIT 1)) AS name", false); $this->StudiengangModel->addSelect('semester'); - $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . ' AS stg_kz', false); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); $this->StudiengangModel->addOrder('semester'); @@ -223,7 +223,7 @@ class Verband extends FHCAPI_Controller $this->GruppeModel->addSelect('sort'); $this->GruppeModel->addSelect('gruppe_kurzbz'); - $this->GruppeModel->addSelect($this->GruppeModel->escape($studiengang_kz) . ' AS stg_kz', false); + $this->GruppeModel->addSelect($this->GruppeModel->escape($studiengang_kz) . '::integer AS stg_kz', false); $this->GruppeModel->addOrder('sort'); $this->GruppeModel->addOrder('gruppe_kurzbz'); @@ -299,7 +299,7 @@ class Verband extends FHCAPI_Controller $this->StudiengangModel->addSelect("TRUE AS leaf", false); $this->StudiengangModel->addSelect('gruppe'); - $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . ' AS stg_kz', false); + $this->StudiengangModel->addSelect($this->StudiengangModel->escape($studiengang_kz) . '::integer AS stg_kz', false); $this->StudiengangModel->addOrder('gruppe'); From 5eafa6b5f495ed53044306e976d4d7da7cc1826f Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 22 May 2024 08:54:23 +0200 Subject: [PATCH 3/7] Bugfix: filter not null --- public/js/components/Stv/Studentenverwaltung/Verband.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/components/Stv/Studentenverwaltung/Verband.js b/public/js/components/Stv/Studentenverwaltung/Verband.js index 4ea1184ad..eb467b6bb 100644 --- a/public/js/components/Stv/Studentenverwaltung/Verband.js +++ b/public/js/components/Stv/Studentenverwaltung/Verband.js @@ -37,7 +37,7 @@ export default { let res = arr.filter(n => n.key == key); if (res.length) return res.pop(); - res = arr.map(n => n.children ? this.findNodeByKey(key, n.children) : null).filter(); + res = arr.map(n => n.children ? this.findNodeByKey(key, n.children) : null).filter(a => a); if (res.length) return res.pop(); return null; From 84013e42e76cd6b35ff14e2bfd4a348e97dc9deb Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 22 May 2024 12:46:05 +0200 Subject: [PATCH 4/7] Bugfixes: correct validation function, cast stg_kz to int, query order --- .../api/frontend/v1/stv/Student.php | 4 +- .../api/frontend/v1/stv/Verband.php | 2 + .../controllers/components/stv/Students.php | 98 +++++++++---------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 9649f4162..fbff10b58 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -259,9 +259,7 @@ class Student extends FHCAPI_Controller { $this->load->library('form_validation'); - $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'isValidDate', [ - 'isValidDate' => $this->p->t('ui', 'error_invalid_date') - ]); + $this->form_validation->set_rules('gebdatum', 'Geburtsdatum', 'is_valid_date'); if (!$this->form_validation->run()) $this->terminateWithValidationErrors($this->form_validation->error_array()); diff --git a/application/controllers/api/frontend/v1/stv/Verband.php b/application/controllers/api/frontend/v1/stv/Verband.php index d74b24a0e..8600a1bf0 100644 --- a/application/controllers/api/frontend/v1/stv/Verband.php +++ b/application/controllers/api/frontend/v1/stv/Verband.php @@ -343,6 +343,8 @@ class Verband extends FHCAPI_Controller $studiensemester = $this->getDataOrTerminateWithError($result); $result = []; + $studiengang_kz = (int)$studiengang_kz; + foreach ($studiensemester as $sem) { $semlink = $link . $sem->studiensemester_kurzbz; $intlink = $semlink . '/interessenten'; diff --git a/application/controllers/components/stv/Students.php b/application/controllers/components/stv/Students.php index 475497141..e4ba9befd 100644 --- a/application/controllers/components/stv/Students.php +++ b/application/controllers/components/stv/Students.php @@ -168,55 +168,6 @@ class Students extends FHC_Controller $stdsemEsc = $this->PrestudentModel->escape($studiensemester_kurzbz); - $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); - #$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', 'ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $this->PrestudentModel->escape($studiensemester_kurzbz) . ') AND ps.prestudent_id=tbl_prestudent.prestudent_id'); - $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', 'ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.prestudent_id=tbl_prestudent.prestudent_id AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT'); - // TODO(chris): check what functions are returning when no entry exists - - $this->PrestudentModel->addSelect('p.person_id'); - $this->PrestudentModel->addSelect('tbl_prestudent.prestudent_id'); - $this->PrestudentModel->addSelect("'' AS uid"); - $this->PrestudentModel->addSelect('titelpre'); - $this->PrestudentModel->addSelect('titelpost'); - $this->PrestudentModel->addSelect('vorname'); - $this->PrestudentModel->addSelect('wahlname'); - $this->PrestudentModel->addSelect('vornamen'); - $this->PrestudentModel->addSelect('geschlecht'); - $this->PrestudentModel->addSelect('nachname'); - $this->PrestudentModel->addSelect('gebdatum'); - $this->PrestudentModel->addSelect('tbl_prestudent.anmerkung'); - $this->PrestudentModel->addSelect('ersatzkennzeichen'); - $this->PrestudentModel->addSelect('svnr'); - $this->PrestudentModel->addSelect("'' AS matrikelnr"); - $this->PrestudentModel->addSelect('p.anmerkung AS anmerkungen'); - $this->PrestudentModel->addSelect("'' AS semester"); - $this->PrestudentModel->addSelect("'' AS verband"); - $this->PrestudentModel->addSelect("'' AS gruppe"); - $this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz'); - $this->PrestudentModel->addSelect('aufmerksamdurch_kurzbz'); - $this->PrestudentModel->addSelect('mentor'); - $this->PrestudentModel->addSelect('FALSE AS bnaktiv'); - $this->PrestudentModel->addSelect( - "(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS email_privat", - false - ); - $this->PrestudentModel->addSelect( - "(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=s.prestudent_id) AS punkte", - false - ); - $this->PrestudentModel->addSelect('tbl_prestudent.dual'); - $this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id'); - $this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest'); - $this->PrestudentModel->addSelect('p.matr_nr'); - $this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz'); - $this->PrestudentModel->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz'); - $this->PrestudentModel->addSelect('tbl_prestudent.priorisierung'); - $this->PrestudentModel->addSelect('p.zugangscode'); - $this->PrestudentModel->addSelect('p.bpk'); - - $this->PrestudentModel->addOrder('nachname'); - $this->PrestudentModel->addOrder('vorname'); - $where = []; if ($orgform_kurzbz) { $where['ps.orgform_kurzbz'] = $orgform_kurzbz; @@ -322,6 +273,55 @@ class Students extends FHC_Controller break; } + $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id'); + #$this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', 'ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $this->PrestudentModel->escape($studiensemester_kurzbz) . ') AND ps.prestudent_id=tbl_prestudent.prestudent_id'); + $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', 'ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.prestudent_id=tbl_prestudent.prestudent_id AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ') AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')', 'LEFT'); + // TODO(chris): check what functions are returning when no entry exists + + $this->PrestudentModel->addSelect('p.person_id'); + $this->PrestudentModel->addSelect('tbl_prestudent.prestudent_id'); + $this->PrestudentModel->addSelect("'' AS uid"); + $this->PrestudentModel->addSelect('titelpre'); + $this->PrestudentModel->addSelect('titelpost'); + $this->PrestudentModel->addSelect('vorname'); + $this->PrestudentModel->addSelect('wahlname'); + $this->PrestudentModel->addSelect('vornamen'); + $this->PrestudentModel->addSelect('geschlecht'); + $this->PrestudentModel->addSelect('nachname'); + $this->PrestudentModel->addSelect('gebdatum'); + $this->PrestudentModel->addSelect('tbl_prestudent.anmerkung'); + $this->PrestudentModel->addSelect('ersatzkennzeichen'); + $this->PrestudentModel->addSelect('svnr'); + $this->PrestudentModel->addSelect("'' AS matrikelnr"); + $this->PrestudentModel->addSelect('p.anmerkung AS anmerkungen'); + $this->PrestudentModel->addSelect("'' AS semester"); + $this->PrestudentModel->addSelect("'' AS verband"); + $this->PrestudentModel->addSelect("'' AS gruppe"); + $this->PrestudentModel->addSelect('tbl_prestudent.studiengang_kz'); + $this->PrestudentModel->addSelect('aufmerksamdurch_kurzbz'); + $this->PrestudentModel->addSelect('mentor'); + $this->PrestudentModel->addSelect('FALSE AS bnaktiv'); + $this->PrestudentModel->addSelect( + "(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS email_privat", + false + ); + $this->PrestudentModel->addSelect( + "(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=s.prestudent_id) AS punkte", + false + ); + $this->PrestudentModel->addSelect('tbl_prestudent.dual'); + $this->PrestudentModel->addSelect('tbl_prestudent.reihungstest_id'); + $this->PrestudentModel->addSelect('tbl_prestudent.anmeldungreihungstest'); + $this->PrestudentModel->addSelect('p.matr_nr'); + $this->PrestudentModel->addSelect('tbl_prestudent.gsstudientyp_kurzbz'); + $this->PrestudentModel->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz'); + $this->PrestudentModel->addSelect('tbl_prestudent.priorisierung'); + $this->PrestudentModel->addSelect('p.zugangscode'); + $this->PrestudentModel->addSelect('p.bpk'); + + $this->PrestudentModel->addOrder('nachname'); + $this->PrestudentModel->addOrder('vorname'); + $this->addFilter($studiensemester_kurzbz); $this->outputJson([]); From ae4c06f481672b7c8428c54a84971ede3c8a76dd Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 22 May 2024 13:09:18 +0200 Subject: [PATCH 5/7] Bugfix: Typo validations --- application/controllers/api/frontend/v1/stv/Student.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index fbff10b58..6b018ec8b 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -134,9 +134,9 @@ class Student extends FHCAPI_Controller $result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post()); //TODO(Manu) check with Chris: input number not allowed - $fieldValidations = $this->getDataOrTerminateWithError($result); + $field_validations = $this->getDataOrTerminateWithError($result); - $this->form_validation->set_rules($fieldvalidations); + $this->form_validation->set_rules($field_validations); if (!$this->form_validation->run()) $this->terminateWithValidationErrors($this->form_validation->error_array()); From 7541770fbbef21cc9477ba245ad3487fad4456e6 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 22 May 2024 13:42:39 +0200 Subject: [PATCH 6/7] Code Quality & Comments --- application/controllers/api/frontend/v1/stv/Favorites.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Favorites.php b/application/controllers/api/frontend/v1/stv/Favorites.php index 5b4b4fa73..e651bf85e 100644 --- a/application/controllers/api/frontend/v1/stv/Favorites.php +++ b/application/controllers/api/frontend/v1/stv/Favorites.php @@ -28,7 +28,6 @@ class Favorites extends FHCAPI_Controller { public function __construct() { - // TODO(chris): access! parent::__construct([ 'index' => self::PERM_LOGGED, 'set' => self::PERM_LOGGED @@ -58,10 +57,8 @@ class Favorites extends FHCAPI_Controller $this->form_validation->set_rules('favorites', 'Favorites', 'required'); - if ($this->form_validation->run() == false) { - $this->output->set_status_header(REST_Controller::HTTP_BAD_REQUEST); - return $this->outputJson($this->form_validation->error_array()); - } + if (!$this->form_validation->run()) + $this->terminateWithValidationErrors($this->form_validation->error_array()); $favorites = $this->input->post('favorites'); From 3d1f81a7213636c3e855cf9afccdd5f26aee1125 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Mon, 27 May 2024 08:53:18 +0200 Subject: [PATCH 7/7] address: code quality --- .../Details/Kontakt/Address.js | 260 +++++++++--------- 1 file changed, 129 insertions(+), 131 deletions(-) diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js index 1e7423fd9..8f6cd9888 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontakt/Address.js @@ -291,128 +291,129 @@ export default{ }) .catch(this.$fhcAlert.handleSystemError) }, + // TODO(chris): use Form Component template: ` -
+
- + -
-
- -
- -
+ +
+ +
+
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
+
+
+ +
+
+
-
- -
- - -
+
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+
+ +
+
+
-
- -
- - -
-
- -
- -
-
- -
+
+ +
+
+
- -
- -
-
- -
+
+ +
+ +
+ +
+
+ +
+ +
+
+
- -
- -
- -
+
+ +
+ +
+
- -
- -
-
- -
-
+
+ +
+ +
+
- -
- -
- -
-
- -
- -
- -
-
-
- -
- -
+
+
+ +
+
+
- + - +
@@ -448,28 +449,28 @@ export default{
-
- -
-
- -
+
+ +
+
+ +
- -
- -
-
- -
+ +
+ +
+
+ +
@@ -508,12 +509,12 @@ export default{
-
- -
-
- -
+
+ +
+
+ +
@@ -539,10 +540,10 @@ export default{ - + - + - + - -
` +
` };