added support for date specifictiy
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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];
|
||||
}
|
||||
|
||||
@ -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 = `
|
||||
<div class="form-group">
|
||||
<label>Date precision</label>
|
||||
<select id="${prefix}_precision">
|
||||
<option value="full" ${precision === 'full' ? 'selected' : ''}>Year, month, and day</option>
|
||||
<option value="year_month" ${precision === 'year_month' ? 'selected' : ''}>Year and month</option>
|
||||
<option value="year" ${precision === 'year' ? 'selected' : ''}>Year only</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>Not before (question key)</label>
|
||||
@ -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) {
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user