From 3d07aa3bd0ae57942dbdfa74b794f72f3c3bfa6a Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Tue, 13 Aug 2024 11:29:24 +0200 Subject: [PATCH] UDFs Prestudent aktivieren --- .../api/frontend/v1/stv/Prestudent.php | 18 ++++++++++++++++++ .../api/frontend/v1/stv/Student.php | 4 ++-- .../Studentenverwaltung/Details/Prestudent.js | 9 ++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php index 5917ae8f1..df8b14710 100644 --- a/application/controllers/api/frontend/v1/stv/Prestudent.php +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -57,9 +57,19 @@ class Prestudent extends FHCAPI_Controller public function updatePrestudent($prestudent_id) { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + // UDF + $this->load->library('UDFLib'); + + $result = $this->udflib->getCiValidations($this->PrestudentModel, $this->input->post()); + $udf_field_validations = $this->getDataOrTerminateWithError($result); + //Form validation $this->load->library('form_validation'); + $this->form_validation->set_rules($udf_field_validations); + $this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [ 'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Priorisierung']) ]); @@ -105,6 +115,14 @@ class Prestudent extends FHCAPI_Controller 'standort_code' ]; + // add UDFs + $result = $this->udflib->getDefinitionForModel($this->PrestudentModel); + + $definitions = $this->getDataOrTerminateWithError($result); + + foreach ($definitions as $def) + $array_allowed_props_prestudent[] = $def['name']; + $update_prestudent = array(); foreach ($array_allowed_props_prestudent as $prop) { diff --git a/application/controllers/api/frontend/v1/stv/Student.php b/application/controllers/api/frontend/v1/stv/Student.php index 2f7b02972..89c317ae4 100644 --- a/application/controllers/api/frontend/v1/stv/Student.php +++ b/application/controllers/api/frontend/v1/stv/Student.php @@ -143,9 +143,9 @@ class Student extends FHCAPI_Controller $result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post()); //TODO(Manu) check with Chris: input number not allowed - $field_validations = $this->getDataOrTerminateWithError($result); + $udf_field_validations = $this->getDataOrTerminateWithError($result); - $this->form_validation->set_rules($field_validations); + $this->form_validation->set_rules($udf_field_validations); if (!$this->form_validation->run()) $this->terminateWithValidationErrors($this->form_validation->error_array()); diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js index 6857bef0b..e6db926cc 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js @@ -2,11 +2,14 @@ import FormForm from '../../../Form/Form.js'; import FormInput from '../../../Form/Input.js'; import TblHistory from "./Prestudent/History.js"; +import CoreUdf from '../../../Udf/Udf.js'; + export default { components: { FormForm, FormInput, - TblHistory + TblHistory, + CoreUdf }, inject: { lists: { @@ -98,6 +101,9 @@ export default { }) .catch(this.$fhcAlert.handleSystemError); }, + udfsLoaded(udfs) { + this.initialFormData = {...(this.initialFormData || {}), ...udfs}; + }, updatePrestudent(){ this.$refs.form .post('api/frontend/v1/stv/prestudent/updatePrestudent/' + this.modelValue.prestudent_id, this.deltaArray) @@ -505,6 +511,7 @@ export default { > +