Commit ec50905b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #9617: two modes now implemented 'requiredOff' and 'requiredOffButMark'.

parent a4aacbce
Pipeline #2778 passed with stages
in 2 minutes and 58 seconds
......@@ -1912,7 +1912,7 @@ Store: *VARS* - V
| slaveId | see `slaveId`_ |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| allRequiredGiven | Form save - Set during check of all required FE. If every *required* FE is given: *1*. Else: *0*. If there is no required FE: *1*. |
| | Even with 'formModeGlobal=skipRequiredCheck', the variable will be set. |
| | Even with `formModeGlobal` = `requiredOff` | `requiredOffButMark` the variable will be set. |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
.. _`store_vars_form_element_upload`:
......@@ -2484,7 +2484,7 @@ The CLIENT `submit_reason` shows the user action:
Example forwardPage
^^^^^^^^^^^^^^^^^^^
* `{{SELECT IF('{{formModeGlobal:S}}'='skipRequiredCheck', 'no', 'auto') }}`
* `{{SELECT IF('{{formModeGlobal:S}}'='requiredOff', 'no', 'auto') }}`
* `{{SELECT IF('{{submit_reason:CE:alnumx}}'='save', 'no', 'url'), '|http://example.com' }}`
Type: combined dynamic mode & URL/page
......@@ -2693,50 +2693,47 @@ The Form global mode `mode` is given by default with `{{formModeGlobal:SE:alnumx
Optional it might be defined via *Form.parameter* ::
mode=readonly|skipRequiredCheck
mode = readonly | requiredOff | requiredOffButMark
* `readonly`: all `FormElement` of the whole form are temporarily in `readonly` mode. This is a fast way to use an
existing *Form* just to display the form data, without a possibility for the user to change any data of the form.
* `skipRequiredCheck`:
* `requiredOff` | `requiredOffButMark` :
* Both modes are identical, but 'requiredOffButMark' will mark all missing fields to the user.
* All `FormElement` with `mode=required`, will be handled as `mode=show`.
* The user can save the form without providing all necessary data!
* The user will see complains about missing data - but again, the form data is saved!
* Check `STORE_VARS`_ for the variable `{{allRequiredGiven:V}}` - even without forcing the user to fill out all data,
this variable will show if the form has been filled completely.
* Check `STORE_VARS`_ for the variable `{{allRequiredGiven:V}}` - it shows if the form has been filled completely.
* Scenario 1:
* A form has one or more FormElement with 'fe.type=required'.
* Calling the form with `formModeGlobal=skipRequiredCheck` will allow the user to save the form, even if not all
* Calling the form with `formModeGlobal=requiredOff` will allow the user to save the form, even if not all
FE.type=required elements are given. Name this the 'draft' mode.
* Calling the form without `formModeGlobal=skipRequiredCheck` (this is the default), forces the user to fill out
* Calling the form without `formModeGlobal` (this is the default), forces the user to fill out
all FE.type=required fields. Name this the 'final submit' mode.
* Scenario 2:
* A form has one or more FormElement with 'fe.type=required'.
* Calling the form with `formModeGlobal=skipRequiredCheck` will allow the user to save the form, even if not all
* Calling the form with `formModeGlobal=requiredOff` will allow the user to save the form, even if not all
FE.type=required elements are given.
* Define an FE-Action 'afterSave', and do some action on `{{allRequiredGiven:V0}}` like::
{{UPDATE <table> SET dataValid={{allRequiredGiven:V0}} WHERE id={{id:R}} }}
* In your report, mark a button green or red, depending on the saved state.
* In your your application logic, you can open the next process step if all data is given by evaluating `{{allRequiredGiven:V0}}`.
* `requiredOff` is a deprecated synonym of `skipRequiredCheck`.
The following shows the same *Form* in the `regular`, `readonly` and `skipRequiredCheck` mode::
The following shows the same *Form* in the `regular`, `readonly`, `requiredOff` and `requiredOffButMark` mode::
10.sql = SELECT CONCAT('p:{{pageAlias:T}}&form=person&r=', p.id, '|Regular') as _pagee,
CONCAT('p:{{pageAlias:T}}&form=person&formModeGlobal=readonly&r=', p.id, '|Readonly') as _pagee,
CONCAT('p:{{pageAlias:T}}&form=person&formModeGlobal=skipRequiredCheck&r=', p.id, '|Required off') as _pagee
CONCAT('p:{{pageAlias:T}}&form=person&formModeGlobal=requiredOff&r=', p.id, '|Required off') as _pagee
CONCAT('p:{{pageAlias:T}}&form=person&formModeGlobal=requiredOffButMark&r=', p.id, '|Required off') as _pagee
FROM Person AS p
FormElements
------------
......
......@@ -972,7 +972,7 @@ abstract class AbstractBuildForm {
*
* Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
* the other pills are not checked - independent if there was a definition on the first pill or not.
* Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first
* Reason: checks happens per pill - if there is no explicit definition on the first pill, take the first
* editable element of that pill.
*/
private function checkAutoFocus() {
......@@ -987,7 +987,9 @@ abstract class AbstractBuildForm {
for ($i = 0; $i < count($this->feSpecNative); ++$i) {
// Only check native elements which will be shown
if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW
|| $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED
|| $this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW_REQUIRED)
) {
// Check if there is an explicit definition.
if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
......@@ -1102,8 +1104,8 @@ abstract class AbstractBuildForm {
}
/**
* Create an array with standard elements for 'mode' (hidden, disabled, required) and add 'form-element',
* 'value'.
* Create an array with standard elements for 'mode' (hidden, disabled, required)
* and add 'form-element', 'value'.
* 'Generic Element Update': add via API_ELEMENT_UPDATE 'label' and 'note'.
* All collected data as array - will be later converted to JSON.
*
......@@ -1143,7 +1145,7 @@ abstract class AbstractBuildForm {
// }
}
if ($formElement[FE_MODE] == FE_MODE_REQUIRED) {
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
......@@ -1249,6 +1251,7 @@ abstract class AbstractBuildForm {
switch ($feMode) {
case FE_MODE_SHOW:
case FE_MODE_SHOW_REQUIRED:
break;
case FE_MODE_REQUIRED:
$required = 'yes';
......@@ -1677,6 +1680,7 @@ abstract class AbstractBuildForm {
switch ($feMode) {
case FE_MODE_HIDDEN:
case FE_MODE_SHOW:
case FE_MODE_SHOW_REQUIRED:
break;
case FE_MODE_REQUIRED:
case FE_MODE_READONLY:
......
......@@ -599,9 +599,10 @@ class BuildFormBootstrap extends AbstractBuildForm {
$formModeGlobal = $this->formSpec[F_MODE_GLOBAL] ?? '';
}
if ($formModeGlobal == F_MODE_SKIP_REQUIRED_CHECK || $formModeGlobal == F_MODE_REQUIRED_OFF) {
if ($formModeGlobal == F_MODE_REQUIRED_OFF_BUT_MARK || $formModeGlobal == F_MODE_REQUIRED_OFF) {
$attribute[DATA_SKIP_REQUIRED_CHECK] = 'true';
}
if (isset($this->formSpec[F_SAVE_BUTTON_ACTIVE]) && $this->formSpec[F_SAVE_BUTTON_ACTIVE] != '0') {
$attribute[DATA_ENABLE_SAVE_BUTTON] = 'true';
}
......@@ -803,7 +804,7 @@ EOF;
}
}
if ($formElement[FE_MODE] == FE_MODE_REQUIRED) {
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
......
......@@ -1010,8 +1010,9 @@ const F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN = 'typeAheadLdapSearchPerToken';
const F_MODE = 'mode';
const F_MODE_READONLY = 'readonly';
const F_MODE_REQUIRED_OFF = 'requiredOff'; // deprecated, #9617
const F_MODE_SKIP_REQUIRED_CHECK = 'skipRequiredCheck';
const F_MODE_REQUIRED_OFF = 'requiredOff';
const F_MODE_REQUIRED_OFF_BUT_MARK = 'requiredOffButMark';
const F_MODE_SKIP_REQUIRED_CHECK = 'skipRequiredCheck'; // deprecated since third revision of #9617
const F_MODE_GLOBAL = 'formModeGlobal';
const F_SAVE_BUTTON_ACTIVE = 'saveButtonActive';
......@@ -1063,6 +1064,7 @@ const CLIENT_REST_FORM = '_form';
const FE_MODE_SHOW = 'show';
const FE_MODE_READONLY = 'readonly';
const FE_MODE_REQUIRED = 'required';
const FE_MODE_SHOW_REQUIRED = 'showRequired';
const FE_MODE_HIDDEN = 'hidden';
const FE_CLASS_NATIVE = 'native';
......
......@@ -408,7 +408,9 @@ EOF;
EOF;
}
$skip = (!($formElement[FE_MODE] == FE_MODE_SHOW || $formElement[FE_MODE] == FE_MODE_REQUIRED));
$skip = (!($formElement[FE_MODE] == FE_MODE_SHOW
|| $formElement[FE_MODE] == FE_MODE_REQUIRED
|| $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED));
// LOCK
if (!$skip && HelperFormElement::booleParameter($formElement[FE_INPUT_EXTRA_BUTTON_LOCK] ?? '-')) {
......
......@@ -1209,6 +1209,8 @@ class Support {
case FE_MODE_REQUIRED:
if ($formMode == F_MODE_READONLY) {
$feMode = FE_MODE_READONLY;
} elseif ($formMode == F_MODE_REQUIRED_OFF && $feMode == FE_MODE_REQUIRED) {
$feMode = FE_MODE_SHOW_REQUIRED;
}
break;
......
......@@ -549,7 +549,13 @@ class Save {
$formModeGlobal = $this->formSpec[F_MODE_GLOBAL] ?? '';
}
$reportRequiredFailed = ($formModeGlobal != F_MODE_REQUIRED_OFF && $formModeGlobal != F_MODE_SKIP_REQUIRED_CHECK);
$reportRequiredFailed = true;
switch ($formModeGlobal) {
case F_MODE_REQUIRED_OFF:
case F_MODE_REQUIRED_OFF_BUT_MARK:
$reportRequiredFailed = false;
break;
}
$clientValues = $this->store::getStore(STORE_FORM);
......
......@@ -184,7 +184,7 @@ class FillStoreForm {
if ($formMode == FORM_UPDATE && $formModeGlobal == '') {
# During 'update': fake all elements to be not 'required'.
$formModeGlobal = F_MODE_SKIP_REQUIRED_CHECK;
$formModeGlobal = F_MODE_REQUIRED_OFF;
}
// If called through 'api/...': get STORE_TYPO3 via SIP parameter.
......@@ -289,6 +289,7 @@ class FillStoreForm {
if ($formElement[FE_DYNAMIC_UPDATE] === 'yes' ||
$formElement[FE_MODE] === FE_MODE_REQUIRED ||
$formElement[FE_MODE] === FE_MODE_SHOW_REQUIRED ||
$formElement[FE_MODE] === FE_MODE_SHOW ||
(isset($formElement[FE_PROCESS_READ_ONLY]) && $formElement[FE_PROCESS_READ_ONLY] != '0')) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment