From 2b1f4aed56c5bfbf014f3f871e9dcc336b5a31b7 Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Wed, 24 May 2023 18:38:04 +0300 Subject: new application form is ready --- public/app/controllers/Auth.php | 15 +++------------ public/app/controllers/JsonToForm.php | 4 ++-- public/app/controllers/Office.php | 24 +++++++++++++++++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'public/app/controllers') diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php index e191c53..d52b6c9 100644 --- a/public/app/controllers/Auth.php +++ b/public/app/controllers/Auth.php @@ -163,18 +163,9 @@ class Auth { // prepare gendered options to position field $positions = ($user->prefix != 'η') - ? [ - 'Διευθυντής', - 'Υποδιευθυντής', - 'Μόνιμος Καθηγητής', - 'Αναπληρωτής Καθηγητής' - ] - : [ - 'Διευθύντρια', - 'Υποδιευθύντρια', - 'Μόνιμη Καθηγήτρια', - 'Αναπληρώτρια Καθηγήτρια' - ]; + ? GENDERED_POSITIONS['he'] + : GENDERED_POSITIONS['she']; + $gendered_position = json_decode( json_encode( $positions, JSON_UNESCAPED_UNICODE )); // attach gendered options diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php index 1e0b99b..5e16472 100644 --- a/public/app/controllers/JsonToForm.php +++ b/public/app/controllers/JsonToForm.php @@ -119,12 +119,12 @@ class JsonToForm * construct a form (html, javasctipt) * from a json designer * - * @param stdClass $formJson : form descriptor + * @param stdClass $formJson : form descriptor * * @param array $require_identity : array of properties and values; * they identify the record; injected into form as hidden fields * - * @return array [ html=>(string), init_js=>(string), values_js=>String ] + * @return array [ html=>(string), init_js=>(string), values_js=>String ] * ------------------------------------------------------------------------- */ public static function json_form($formJson, $require_identity = []) diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index 9eb2a4c..5038200 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -160,6 +160,9 @@ class Office { } + /** render application form + * + */ private static function render_application_form($opts) { // #1: user-id --------------------------------------------------------- @@ -170,15 +173,30 @@ class Office { // #3: inject default values ------------------------------------------- + $userData = Auth::user_data(); + // #3.1: inject user data $form_setup->defaults = json_decode( json_encode( - Auth::user_data(), JSON_UNESCAPED_UNICODE + $userData, JSON_UNESCAPED_UNICODE )); + // #3.2 inject `sector` and `position`