From 931a93cd7bae092e2752064568cebe407d2bf46e Mon Sep 17 00:00:00 2001 From: Geo Xalkis Date: Tue, 2 May 2023 01:02:48 +0300 Subject: (almost) final structrure of forms --- public/app/config/app_constants.php | 49 ++++++++++++----- public/app/controllers/JsonToForm.php | 18 ++++--- public/app/models/_info.md | 25 ++++++++- public/assets/css/overides.css | 99 ++++++++++++++++++----------------- 4 files changed, 123 insertions(+), 68 deletions(-) diff --git a/public/app/config/app_constants.php b/public/app/config/app_constants.php index fedba90..9dff566 100644 --- a/public/app/config/app_constants.php +++ b/public/app/config/app_constants.php @@ -245,7 +245,7 @@ define('COMMON_REQUEST_FORM', [ 'outer_class' => 'col-12', 'inner_class' => 'form-control', 'type' => 'text', - 'source' => 'user' + 'source' => '\app\controllers\User::current' ], 'form' => [ [ @@ -331,20 +331,36 @@ define('PENALTY_FORM', [ 'type' => 'label' ], [ - 'name' => 'of_student', - 'label' => 'τ.. μαθητ...', + 'name' => 'of_article', + 'label' => 'του/της...', + 'type' => 'select', + 'options' => [ + 'του μαθητή', + 'της μαθήτριας', + 'των μαθητών', + 'των μαθητριών' + ], + 'class' => 'col-4', + 'attributes' => ['required'] + ], + [ + 'name' => 'student_names', + 'label' => '(ονοματεπώνυ-μο/μα, πτώση γενική)', + 'type' => 'textarea', + 'class' => 'col-8', 'attributes' => ['required'] ], [ 'name' => 'of_department', 'label' => 'του τμήματος...', + 'class' => 'col-4', 'attributes' => ['required'] ], [ 'name' => 'date', 'label' => 'Ημερομηνία', 'type' => 'date', - 'class' => 'col-5', + 'class' => 'col-4', 'attributes' => ['required'] ], [ @@ -356,21 +372,28 @@ define('PENALTY_FORM', [ [ 'name' => 'place', 'label' => 'Τόπος', + 'type' => 'select', + 'options' => [ + 'Γραφείο Διευθηντή', + 'Γραφείο Καθηγητών' + ], 'attributes' => ['required'] ], [ 'name' => 'rapporteur', 'label' => 'εισηγητής', + 'source' => '\app\extends\Cache_service::all_users', 'attributes' => ['required'] ], [ 'name' => 'charge', - 'label' => 'κατηγορία', + 'label' => 'Περιγραφή συμβάντος:', + 'type' => 'textarea', 'attributes' => ['required'] ], [ 'name' => 'apology', - 'label' => 'Απολογία', // + of_student + 'label' => 'Απολογία: (μαθητή/-των)', // + of_student 'type' => 'textarea', 'attributes' => [] ], @@ -378,17 +401,18 @@ define('PENALTY_FORM', [ 'name' => 'decision_reasoning', 'label' => 'Αιτιολογία απόφασης (πχ. Επειδή...)', 'type' => 'textarea', - 'attributes' => ['required'] + 'attributes' => [] ], [ - 'label' => 'Το Πειθαρχικό Συμβούλιο' + 'label' => 'Το Πειθαρχικό Συμβούλιο', + 'type' => 'label' ], [ 'name' => 'decision', 'label' => 'Αποφασίζει', 'type' => 'select', 'options' => [ - 'προφορική επίπληψη', + 'προφορική επίπληξη', 'ωριαία αποβολή', 'ημερήσια αποβολή' ], @@ -396,13 +420,14 @@ define('PENALTY_FORM', [ ], [ 'name' => 'decision_more', - 'label' => '(μη τυποποιημένo κείμενο απόφασης)', + 'label' => '(μη τυποποιημένο κείμενο απόφασης)', 'attributes' => [] ], [ 'name' => 'president', - 'label' => 'Ημερομηνία αίτησης', + 'label' => 'Πρόεδρος συνεδρίασης', 'type' => 'text', + 'source' => '\app\extends\Cache_service::all_users', 'attributes' => ['required'] ], [ @@ -410,7 +435,7 @@ define('PENALTY_FORM', [ 'label' => 'Μέλη', 'type' => 'select', 'attributes' => ['required', 'multiple'], - 'source' => 'teachers', + 'source' => '\app\extends\Cache_service::all_users', 'options' => [ 'Μαρία Χαλκιαδάκη', 'Σπαγκοβαγγελοδημήτρης Νικόλαος', diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php index 5a60891..1b05af7 100644 --- a/public/app/controllers/JsonToForm.php +++ b/public/app/controllers/JsonToForm.php @@ -181,7 +181,9 @@ class JsonToForm - $html = ''; + $html = " +
+ "; foreach ($formJson->form as $key => $field) { @@ -227,13 +229,13 @@ class JsonToForm } else { // select is single; draw select + add empty option $html .=" - "; - // // prepare initialization of select2 (single) - // $initSelectsJS .= " - // var {$name} = $('#{$name}'); - // {$name}.select2({ allowClear: true });"; + // prepare initialization of select2 (single) + $initSelectsJS .= " + var {$name} = $('#{$name}'); + {$name}.select2({ }); + {$name}.val(null).trigger('change')"; // prepare check if empty field $checkFilledJS .= " @@ -338,7 +340,7 @@ class JsonToForm } return [ - 'html' => $html, + 'html' => $html .'
', 'init_js' => $initSelectsJS, 'values_js' => $checkFilledJS ]; diff --git a/public/app/models/_info.md b/public/app/models/_info.md index 401c13c..82143bf 100644 --- a/public/app/models/_info.md +++ b/public/app/models/_info.md @@ -45,7 +45,6 @@ active) VALUES (:id, :active ) - UPDATE user SET prefix = :prefix, first_name = :first_name, @@ -127,3 +126,27 @@ admin/iinvite + + +# callable/dynamic select options + + + diff --git a/public/assets/css/overides.css b/public/assets/css/overides.css index 6e577fc..3fd143f 100644 --- a/public/assets/css/overides.css +++ b/public/assets/css/overides.css @@ -2,7 +2,7 @@ --bs-heading-color: #679; } -html, body { font-family: "Roboto Slab", serif; font-weight: 400; } +html, body, select, select option, .select2-selection__choice { font-family: "Roboto Slab", serif; font-weight: 400; } .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { font-weight: 400; }; @@ -12,13 +12,8 @@ html, body { font-family: "Roboto Slab", serif; font-weight: 400; } .form-control, .form-select { border: 1px solid #7777; font-size: .857em; } .form-label { font-size: .72em; color: var(--bs-heading-color); } -.footer__listLink { - color: #bbb; -} -.footer__listLink:hover { - color: #eee; -} - +.footer__listLink { color: #bbb; } +.footer__listLink:hover { color: #eee; } .footer__title { color: #bbb7; } /* .user .dropdown button { min-width: 256px; } */ @@ -69,11 +64,6 @@ ul.select2-results__options li { font-size: 14px; padding: 4px 8px; } .admin-container .form-control { border-radius: 4px; } -.admin-container select[data-chosen='one'] { - font-weight: 700; - color: #0d6efd; - border: 1px solid #0d6efd; -} /* hack select2 caret styling * (like bootstrap5 select caret) @@ -87,53 +77,68 @@ ul.select2-results__options li { font-size: 14px; padding: 4px 8px; } height: 16 !important; width: 12px !important; margin: auto !important; - top: 9px !important; + top: 12px !important; left: auto !important; height: 14px; } .select2-container--default .select2-selection--single .select2-selection__arrow { width: 24px; } -.select2-container--default .select2-selection--single { height: 31px; } +.select2-container--default .select2-selection--single { height: 37px; } /* ------------------------------------------------------------------------- end */ -.admin-container .edit-post textarea[name=body] { - height: calc(100vh - 420px); /* almost all avialable height */ -} +/* + .admin-container .edit-post textarea[name=intro] { height: 94px ;} -.admin-container .edit-page textarea[name=body] { - height: calc(100vh - 380px); /* almost all avialable height */ -} -.admin-container .edit-post textarea[name=intro] { height: 94px ;} /* almost 3 (half-)lines */ + .admin-container .post-media button.over-bar { margin: -26px 0 0 0; float: right; } + .admin-container .post-media ul { + border: 1px solid #ccc; + border-radius: 4px; + padding: 6px; + } -.admin-container .edit-post textarea[name=body] { - height: calc(100vh - 420px); /* almost all avialable height */ -} + .admin-container .post-media ul li { + border-bottom: 1px solid #ddd; + list-style-type: none; + padding: 3px 6px; -.admin-container .post-media button.over-bar { margin: -26px 0 0 0; float: right; } -.admin-container .post-media ul { - border: 1px solid #ccc; - border-radius: 4px; - padding: 6px; -} + display: flex; + justify-content: space-between; + align-items: center; + } + .admin-container .post-media ul li:last-child { border-bottom: none ;} + .admin-container .post-media ul li:hover { background: #eee; } + + .admin-container .post-media li .btn-xs { font-size: 14px; width: 24px; height: 24px; padding:0; } + + .classroom .edit-post textarea[name=body], + .classroom .edit-page textarea[name=body] { + min-height:320px; + font-family: Consolas, 'Ubuntu Mono','Courier New', Courier, monospace; + color: #333; + } + +*/ -.admin-container .post-media ul li { - border-bottom: 1px solid #ddd; - list-style-type: none; - padding: 3px 6px; - display: flex; - justify-content: space-between; - align-items: center; +/** select2|multiple overides + * --- -- -- - - - + */ +input.select2-search__field { font-size: 15px; } +ul.select2-selection__rendered { margin-bottom: 0; } /* select2: ul */ +.select2-container--default .select2-selection--multiple .select2-selection__choice { padding: 2px; } /* select2: li */ +.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { /* select2: button */ + border-right: none; + padding: 1px 4px; } -.admin-container .post-media ul li:last-child { border-bottom: none ;} -.admin-container .post-media ul li:hover { background: #eee; } +.select2-container--default .select2-selection--multiple { font-size: 15px; } + + + -.admin-container .post-media li .btn-xs { font-size: 14px; width: 24px; height: 24px; padding:0; } +/* select2.min.css | https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css */ -.classroom .edit-post textarea[name=body], -.classroom .edit-page textarea[name=body] { - min-height:320px; - font-family: Consolas, 'Ubuntu Mono','Courier New', Courier, monospace; - color: #333; - } \ No newline at end of file +.select2-container--default .select2-selection--single .select2-selection__clear { margin-right: 32px; } + +.select2-container .select2-selection--single .select2-selection__rendered { font-size: 15px; padding: 2px 20px 2px 8px; } + \ No newline at end of file -- cgit v1.2.3