diff --git a/api/app_questionnaires.php b/api/app_questionnaires.php index aa1d3d3..0eb139b 100644 --- a/api/app_questionnaires.php +++ b/api/app_questionnaires.php @@ -76,6 +76,7 @@ if ($qnID) { if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms']; if (isset($config['range'])) $q['range'] = $config['range']; if (isset($config['constraints'])) $q['constraints'] = $config['constraints']; + if (isset($config['precision'])) $q['precision'] = $config['precision']; if (isset($config['minSelection'])) $q['minSelection'] = $config['minSelection']; if (isset($config['maxLength'])) $q['maxLength'] = (int)$config['maxLength']; if (!empty($config['multiline'])) $q['multiline'] = true; diff --git a/handlers/app_questionnaires.php b/handlers/app_questionnaires.php index 9915f46..e17e15b 100644 --- a/handlers/app_questionnaires.php +++ b/handlers/app_questionnaires.php @@ -267,6 +267,7 @@ if ($qnID) { if (isset($config['symptoms'])) $q['symptoms'] = $config['symptoms']; if (isset($config['range'])) $q['range'] = $config['range']; if (isset($config['constraints'])) $q['constraints'] = $config['constraints']; + if (isset($config['precision'])) $q['precision'] = $config['precision']; if (isset($config['minSelection'])) $q['minSelection'] = $config['minSelection']; if (isset($config['maxLength'])) $q['maxLength'] = (int)$config['maxLength']; if (!empty($config['multiline'])) $q['multiline'] = true; diff --git a/import_questionnaires.php b/import_questionnaires.php index 3050999..a4b4a86 100644 --- a/import_questionnaires.php +++ b/import_questionnaires.php @@ -85,13 +85,14 @@ try { if (isset($q['symptoms'])) $config['symptoms'] = $q['symptoms']; if (isset($q['range'])) $config['range'] = $q['range']; if (isset($q['constraints'])) $config['constraints'] = $q['constraints']; + if (isset($q['precision'])) $config['precision'] = $q['precision']; if (isset($q['minSelection'])) $config['minSelection'] = $q['minSelection']; if (isset($q['maxLength'])) $config['maxLength'] = (int)$q['maxLength']; if (!empty($q['multiline'])) $config['multiline'] = true; if (isset($q['otherNextQuestionId'])) $config['otherNextQuestionId'] = $q['otherNextQuestionId']; if (isset($q['otherOptionKey'])) $config['otherOptionKey'] = $q['otherOptionKey']; if (isset($q['config']) && is_array($q['config'])) { - foreach (['otherNextQuestionId', 'otherOptionKey', 'hint', 'maxLength', 'multiline', 'textKey'] as $ck) { + foreach (['otherNextQuestionId', 'otherOptionKey', 'hint', 'maxLength', 'multiline', 'textKey', 'precision'] as $ck) { if (isset($q['config'][$ck])) { $config[$ck] = $q['config'][$ck]; } diff --git a/website/js/pages/editor.js b/website/js/pages/editor.js index ba9b3a1..a6ba455 100644 --- a/website/js/pages/editor.js +++ b/website/js/pages/editor.js @@ -146,7 +146,16 @@ function configFormHTML(layout, config, prefix) { case 'date_spinner': { const notBefore = config.constraints?.notBefore || ''; const notAfter = config.constraints?.notAfter || ''; + const precision = config.precision || 'full'; html = ` +
+ + +
@@ -257,6 +266,8 @@ function readConfigFromForm(layout, prefix) { }; break; case 'date_spinner': { + const prec = val('precision') || 'full'; + if (prec && prec !== 'full') config.precision = prec; const nb = val('notBefore'); const na = val('notAfter'); if (nb || na) { diff --git a/website/temp-assets/questionnaire_0_readme.json b/website/temp-assets/questionnaire_0_readme.json index 2278137..c75af54 100644 --- a/website/temp-assets/questionnaire_0_readme.json +++ b/website/temp-assets/questionnaire_0_readme.json @@ -56,17 +56,19 @@ { "id": "q4", - "_comment": "Frage mit Spinner zur Auswahl des Datums", + "_comment": "Datumsfrage. precision: full (YYYY-MM-DD), year_month (YYYY-MM), year (YYYY).", "layout": "date_spinner", - "question": "departure_country" + "question": "departure_country", + "precision": "year_month" }, { "id": "q5", - "_comment": "Frage mit Spinner zur Auswahl des Datums. Über constraints und notBefore und notAfter, ist es möglich das Datum nicht in der Zukunft oder Vergangenheit zu wählen.", + "_comment": "Datumsfrage mit constraints. precision steuert Tag/Monat/Jahr-Spinner.", "layout": "date_spinner", "question": "since_in_germany", + "precision": "year_month", "constraints": { "notBefore": "departure_country", "notAfter": "departure_country" diff --git a/website/temp-assets/questionnaire_1_demographic_information.json b/website/temp-assets/questionnaire_1_demographic_information.json index f255d40..4eaf298 100644 --- a/website/temp-assets/questionnaire_1_demographic_information.json +++ b/website/temp-assets/questionnaire_1_demographic_information.json @@ -121,12 +121,14 @@ { "id": "q13", "layout": "date_spinner", - "question": "departure_country" + "question": "departure_country", + "precision": "year_month" }, { "id": "q14", "layout": "date_spinner", "question": "since_in_germany", + "precision": "year_month", "constraints": { "notBefore": "departure_country" } @@ -280,6 +282,7 @@ "id": "q24", "layout": "date_spinner", "question": "provisional_accommodation_since", + "precision": "year_month", "constraints": { "notBefore": "since_in_germany" } @@ -288,6 +291,7 @@ "id": "q25", "layout": "date_spinner", "question": "asylum_procedure_since", + "precision": "year_month", "constraints": { "notBefore": "since_in_germany" }