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

Merge remote-tracking branch 'origin/master'

parents 72e16b77 6c276cf5
Pipeline #2068 passed with stages
in 2 minutes and 39 seconds
...@@ -2518,6 +2518,8 @@ Parameter ...@@ -2518,6 +2518,8 @@ Parameter
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| maxFileSize | int | Overwrite default from configuration_ . | | maxFileSize | int | Overwrite default from configuration_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
* Example: * Example:
...@@ -3029,6 +3031,8 @@ See also at specific *FormElement* definitions. ...@@ -3029,6 +3031,8 @@ See also at specific *FormElement* definitions.
| messageFail | string | | | messageFail | string | |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+ +------------------------+--------+----------------------------------------------------------------------------------------------------------+
| dataReference | string | Optional. See `applicationTest`_ | | dataReference | string | Optional. See `applicationTest`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+ +------------------------+--------+----------------------------------------------------------------------------------------------------------+
...@@ -3092,6 +3096,21 @@ extraButtonInfo ...@@ -3092,6 +3096,21 @@ extraButtonInfo
* For `FormElement` with mode `below`, a `span` element with the given class in `extraButtonInfoClass` (FE, F, configuration_) * For `FormElement` with mode `below`, a `span` element with the given class in `extraButtonInfoClass` (FE, F, configuration_)
will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element. will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element.
.. _`requiredPosition`:
Required Position
^^^^^^^^^^^^^^^^^
By default, input elements with `Mode=required` will be displayed with a 'red asterix' right beside the label. The position
of the 'red asterix' can be choosen via the `parameter` field::
requiredPosition = label-left|label-right|input-left|input-right|note-left|note-right
The default is 'label-right'.
The definition can be set per Form (=affects all FormElements) or per FormElement.
.. _`input-checkbox`: .. _`input-checkbox`:
Type: checkbox Type: checkbox
......
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
namespace IMATHUZH\Qfq\Core; namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Database\Database; use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement; use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\OnArray; use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Ldap; use IMATHUZH\Qfq\Core\Helper\Ldap;
use IMATHUZH\Qfq\Core\Helper\Logger; use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser; use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Report\Link;
use IMATHUZH\Qfq\Core\Helper\Sanitize; use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\HelperFile; use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Link;
use IMATHUZH\Qfq\Core\Report\Report; use IMATHUZH\Qfq\Core\Report\Report;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
/** /**
* Class AbstractBuildForm * Class AbstractBuildForm
...@@ -958,6 +958,7 @@ abstract class AbstractBuildForm { ...@@ -958,6 +958,7 @@ abstract class AbstractBuildForm {
* @throws \UserFormException * @throws \UserFormException
*/ */
private function getFormElementForJson($htmlFormElementName, $value, array $formElement) { private function getFormElementForJson($htmlFormElementName, $value, array $formElement) {
$addClassRequired = array();
$json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required $json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required
...@@ -984,14 +985,20 @@ abstract class AbstractBuildForm { ...@@ -984,14 +985,20 @@ abstract class AbstractBuildForm {
// } // }
} }
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
if (isset($formElement[FE_LABEL])) { if (isset($formElement[FE_LABEL])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL;
$addClass = ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) ? CSS_REQUIRED : ''; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass);
} }
if (isset($formElement[FE_NOTE])) { if (isset($formElement[FE_NOTE])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE;
if (!empty($addClassRequired[FE_NOTE])) {
$formElement[FE_NOTE] = Support::wrapTag('<span class="' . $addClassRequired[FE_NOTE] . '">', $formElement[FE_NOTE]);
}
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE]; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE];
} }
...@@ -1041,6 +1048,10 @@ abstract class AbstractBuildForm { ...@@ -1041,6 +1048,10 @@ abstract class AbstractBuildForm {
$class .= ' hidden'; $class .= ' hidden';
} }
if (!empty($addClassRequired[FE_INPUT])) {
$class .= ' ' . $addClassRequired[FE_INPUT];
}
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class;
} }
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
namespace IMATHUZH\Qfq\Core; namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\Logger; use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray; use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Support; use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
/** /**
* Class BuildFormBootstrap * Class BuildFormBootstrap
...@@ -728,6 +728,7 @@ EOF; ...@@ -728,6 +728,7 @@ EOF;
$htmlLabel = ''; $htmlLabel = '';
$classHideRow = ''; $classHideRow = '';
$classHideElement = ''; $classHideElement = '';
$addClassRequired = array();
if ($formElement[FE_MODE] == FE_MODE_HIDDEN) { if ($formElement[FE_MODE] == FE_MODE_HIDDEN) {
if ($formElement[FE_FLAG_ROW_OPEN_TAG] && $formElement[FE_FLAG_ROW_CLOSE_TAG]) { if ($formElement[FE_FLAG_ROW_OPEN_TAG] && $formElement[FE_FLAG_ROW_CLOSE_TAG]) {
...@@ -737,23 +738,32 @@ EOF; ...@@ -737,23 +738,32 @@ EOF;
} }
} }
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
// Label // Label
if ($formElement[FE_BS_LABEL_COLUMNS] != '0') { if ($formElement[FE_BS_LABEL_COLUMNS] != '0') {
$addClass = ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) ? CSS_REQUIRED : ''; $htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass);
} }
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS], $html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
[$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL); [$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL);
// Input // Input
if (!empty($addClassRequired[FE_INPUT])) {
$htmlElement = Support::wrapTag('<span class="' . $addClassRequired[FE_INPUT] . '">', $htmlElement);
}
$html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS], $html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS],
[$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]], [$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]],
$formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT, $classHideElement); $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT, $classHideElement);
if (!empty($addClassRequired[FE_NOTE])) {
$formElement[FE_NOTE] = Support::wrapTag('<span class="' . $addClassRequired[FE_NOTE] . '">', $formElement[FE_NOTE]);
}
// Note // Note
$note = $formElement[FE_NOTE]; $html .= $this->customWrap($formElement, $formElement[FE_NOTE], FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
$html .= $this->customWrap($formElement, $note, FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
[$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE); [$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE);
// Row // Row
......
...@@ -674,7 +674,8 @@ const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#'; ...@@ -674,7 +674,8 @@ const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#';
const SYSTEM_DRAG_AND_DROP_JS = 'hasDragAndDropJS'; const SYSTEM_DRAG_AND_DROP_JS = 'hasDragAndDropJS';
const SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME = 'parameterLanguageFieldName'; const SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME = 'parameterLanguageFieldName';
const CSS_REQUIRED = 'required-field'; const CSS_REQUIRED_RIGHT = 'required-right';
const CSS_REQUIRED_LEFT = 'required-left';
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen globale Vars benutzt. // die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen globale Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting. //const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
...@@ -963,6 +964,13 @@ const F_FE_DATA_MATCH_ERROR_DEFAULT = 'Fields do not match'; // Attention: the d ...@@ -963,6 +964,13 @@ const F_FE_DATA_MATCH_ERROR_DEFAULT = 'Fields do not match'; // Attention: the d
const F_FE_LABEL_ALIGN = SYSTEM_LABEL_ALIGN; const F_FE_LABEL_ALIGN = SYSTEM_LABEL_ALIGN;
const F_FE_LABEL_ALIGN_DEFAULT = 'default'; const F_FE_LABEL_ALIGN_DEFAULT = 'default';
const F_FE_REQUIRED_POSITION = 'requiredPosition';
const F_FE_REQUIRED_POSITION_LABEL_LEFT = 'label-left';
const F_FE_REQUIRED_POSITION_LABEL_RIGHT = 'label-right';
const F_FE_REQUIRED_POSITION_INPUT_LEFT = 'input-left';
const F_FE_REQUIRED_POSITION_INPUT_RIGHT = 'input-right';
const F_FE_REQUIRED_POSITION_NOTE_LEFT = 'note-left';
const F_FE_REQUIRED_POSITION_NOTE_RIGHT = 'note-right';
const F_PARAMETER = 'parameter'; // valid for F_ and FE_ const F_PARAMETER = 'parameter'; // valid for F_ and FE_
...@@ -1059,6 +1067,7 @@ const FE_VALUE = 'value'; ...@@ -1059,6 +1067,7 @@ const FE_VALUE = 'value';
const FE_CLASS = 'class'; const FE_CLASS = 'class';
const FE_LABEL = 'label'; const FE_LABEL = 'label';
const FE_NOTE = 'note'; const FE_NOTE = 'note';
const FE_INPUT = 'input';
const FE_BS_LABEL_COLUMNS = F_BS_LABEL_COLUMNS; const FE_BS_LABEL_COLUMNS = F_BS_LABEL_COLUMNS;
const FE_BS_INPUT_COLUMNS = F_BS_INPUT_COLUMNS; const FE_BS_INPUT_COLUMNS = F_BS_INPUT_COLUMNS;
const FE_BS_NOTE_COLUMNS = F_BS_NOTE_COLUMNS; const FE_BS_NOTE_COLUMNS = F_BS_NOTE_COLUMNS;
......
...@@ -851,7 +851,7 @@ class Database { ...@@ -851,7 +851,7 @@ class Database {
$feSpecNative = $this->sql($sql, ROW_REGULAR, $param); $feSpecNative = $this->sql($sql, ROW_REGULAR, $param);
$feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative); $feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative, $formSpec);
// Explode and Do $FormElement.parameter // Explode and Do $FormElement.parameter
HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER); HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace IMATHUZH\Qfq\Core\Helper; namespace IMATHUZH\Qfq\Core\Helper;
use IMATHUZH\Qfq\Core\Store\Store; use IMATHUZH\Qfq\Core\Store\Store;
/** /**
* Class HelperFormElement * Class HelperFormElement
...@@ -40,16 +40,20 @@ class HelperFormElement { ...@@ -40,16 +40,20 @@ class HelperFormElement {
/** /**
* Set default values for given FormElement.
* Hint: to copy values from Form, copyAttributesToFormElements() is more appropriate.
*
* @param array $elements * @param array $elements
* *
* @param array $formSpec
* @return array * @return array
*/ */
public static function formElementSetDefault(array $elements) { public static function formElementSetDefault(array $elements, array $formSpec) {
foreach ($elements AS $key => $element) { foreach ($elements AS $key => $element) {
$elements[$key][FE_TG_INDEX] = 0; $elements[$key][FE_TG_INDEX] = 0;
unset($elements[$key][FE_ADMIN_NOTE]); unset($elements[$key][FE_ADMIN_NOTE]);
// $elements[$key][FE_DATA_REFERENCE] = ''; // $elements[$key][FE_DATA_REFERENCE] = '';
} }
return $elements; return $elements;
...@@ -89,9 +93,11 @@ class HelperFormElement { ...@@ -89,9 +93,11 @@ class HelperFormElement {
// For retype elements: copy the language specific value. // For retype elements: copy the language specific value.
if (isset($element[FE_RETYPE_SOURCE_NAME])) { if (isset($element[FE_RETYPE_SOURCE_NAME])) {
if (!empty($element[FE_RETYPE_LABEL])) { if (!empty($element[FE_RETYPE_LABEL])) {
$element[FE_LABEL] = $element[FE_RETYPE_LABEL]; $element[FE_LABEL] = $element[FE_RETYPE_LABEL];
} }
if (!empty($element[FE_RETYPE_NOTE])) { if (!empty($element[FE_RETYPE_NOTE])) {
$element[FE_NOTE] = $element[FE_RETYPE_NOTE]; $element[FE_NOTE] = $element[FE_RETYPE_NOTE];
} }
...@@ -271,6 +277,7 @@ class HelperFormElement { ...@@ -271,6 +277,7 @@ class HelperFormElement {
if ($feSpecNative[$key][F_FE_LABEL_ALIGN] == F_FE_LABEL_ALIGN_DEFAULT) { if ($feSpecNative[$key][F_FE_LABEL_ALIGN] == F_FE_LABEL_ALIGN_DEFAULT) {
$feSpecNative[$key][F_FE_LABEL_ALIGN] = $formSpec[F_FE_LABEL_ALIGN]; $feSpecNative[$key][F_FE_LABEL_ALIGN] = $formSpec[F_FE_LABEL_ALIGN];
} }
Support::setIfNotSet($feSpecNative[$key], F_FE_REQUIRED_POSITION, $formSpec[F_FE_REQUIRED_POSITION]);
} }
return $feSpecNative; return $feSpecNative;
...@@ -464,4 +471,41 @@ EOF; ...@@ -464,4 +471,41 @@ EOF;
return json_encode($rgb); return json_encode($rgb);
} }
/**
* Depending on value in $requiredPosition the array $classArr will contain the CSS class to align the required mark.
* @param $requiredPosition
* @return array
* @throws \UserFormException
*/
public static function getRequiredPositionClass($requiredPosition) {
$classArr[FE_LABEL] = '';
$classArr[FE_TYPE] = '';
$classArr[FE_NOTE] = '';
switch ($requiredPosition) {
case F_FE_REQUIRED_POSITION_LABEL_LEFT:
$classArr[FE_LABEL] = CSS_REQUIRED_LEFT;
break;
case F_FE_REQUIRED_POSITION_LABEL_RIGHT:
$classArr[FE_LABEL] = CSS_REQUIRED_RIGHT;
break;
case F_FE_REQUIRED_POSITION_INPUT_LEFT:
$classArr[FE_INPUT] = CSS_REQUIRED_LEFT;
break;
case F_FE_REQUIRED_POSITION_INPUT_RIGHT:
$classArr[FE_INPUT] = CSS_REQUIRED_RIGHT;
break;
case F_FE_REQUIRED_POSITION_NOTE_LEFT:
$classArr[FE_NOTE] = CSS_REQUIRED_LEFT;
break;
case F_FE_REQUIRED_POSITION_NOTE_RIGHT:
$classArr[FE_NOTE] = CSS_REQUIRED_RIGHT;
break;
default:
throw new \UserFormException('Unkown value for ' . F_FE_REQUIRED_POSITION . ': ' . $requiredPosition, ERROR_INVALID_VALUE);
}
return $classArr;
}
} }
\ No newline at end of file
...@@ -1144,7 +1144,7 @@ class QuickFormQuery { ...@@ -1144,7 +1144,7 @@ class QuickFormQuery {
$feSpecNative = $this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_REGULAR, $param); $feSpecNative = $this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_REGULAR, $param);
$feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative); $feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative, $formSpec);
// Explode and Do $FormElement.parameter // Explode and Do $FormElement.parameter
HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER); HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER);
...@@ -1403,6 +1403,7 @@ class QuickFormQuery { ...@@ -1403,6 +1403,7 @@ class QuickFormQuery {
Support::setIfNotSet($formSpec, F_DB_INDEX, $this->store->getVar(F_DB_INDEX, STORE_SYSTEM)); Support::setIfNotSet($formSpec, F_DB_INDEX, $this->store->getVar(F_DB_INDEX, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_ENTER_AS_SUBMIT, $this->store->getVar(SYSTEM_ENTER_AS_SUBMIT, STORE_SYSTEM)); Support::setIfNotSet($formSpec, F_ENTER_AS_SUBMIT, $this->store->getVar(SYSTEM_ENTER_AS_SUBMIT, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_SESSION_TIMEOUT_SECONDS, $this->store->getVar(SYSTEM_SESSION_TIMEOUT_SECONDS, STORE_SYSTEM)); Support::setIfNotSet($formSpec, F_SESSION_TIMEOUT_SECONDS, $this->store->getVar(SYSTEM_SESSION_TIMEOUT_SECONDS, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_FE_REQUIRED_POSITION, F_FE_REQUIRED_POSITION_LABEL_RIGHT);
// In case there is no F_MODE defined on the form, check if there is one in STORE_SIP. // In case there is no F_MODE defined on the form, check if there is one in STORE_SIP.
if ($formSpec[F_MODE] == '') { if ($formSpec[F_MODE] == '') {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
namespace IMATHUZH\Qfq\Core\Report; namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\HelperFile; use IMATHUZH\Qfq\Core\Helper\HelperFile;
require_once __DIR__ . '/../../../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
......
# phpunit # Phpunit
## run unit tests from commandline ## Setup
After running `make bootstrap` go to the extension folder and run: Requirements for running the php unittests:
- `make bootstrap` was executed
- The following files exist at the same location (either `extension/` or `typo3conf/`):
* `config.qfq.php`
* `LocalConfiguration.php`
- The database credentials in `config.qfq.php` are correct
- The database with the name `DB_1_NAME` followed by `_phpunit` exists. E.g. `app_qfq_phpunit` where `DB_1_NAME=app_qfq`
In Tests/Unit/ you may find a mockup of `LocalConfiguration.php`
and a template for `config.qfq.php`.
## Run unit tests from commandline
REMARK: Running the unit tests without specifying the configuration file `phpunit.xml` will not work. See section "Autoloader" for explanation.
From the extension folder run:
`vendor/bin/phpunit --configuration phpunit.xml` `vendor/bin/phpunit --configuration phpunit.xml`
## phpunit configurations ## Phpunit configurations
Phpunit configurations are stored in extension/phpunit.xml Phpunit configurations are stored in extension/phpunit.xml
Running the tests without specifying these configurations will not work. Running the tests without specifying these configurations will not work.
...@@ -14,18 +30,11 @@ Running the tests without specifying these configurations will not work. ...@@ -14,18 +30,11 @@ Running the tests without specifying these configurations will not work.
## Autoloader ## Autoloader
The test classes use the composer autoloader to reference to the source classes. The test classes use the composer autoloader to reference to the source classes.
The autoloader is loaded in extension/Classes/bootstrap.php which in turn is executed by phpunit before each test The autoloader is loaded by phpunit before each test
as specified in phpunit.xml by the line `<phpunit bootstrap="Classes/bootstrap.php">` as specified in phpunit.xml by the line `<phpunit bootstrap="vendor/autoload.php">`
## run tests on gitlab runner (i.e. without typo3 installation) ## Run tests without typo3 installation (e.g. gitlab runner)
As defined in the phpunit command of projectRoot/Makefile. As defined in the phpunit command of projectRoot/Makefile.
The files phpunit_config.qfq.php and phpunit_LocalConfiguration.php are copied outside the extension folder by the Makefile.
The files phpunit_config.qfq.php and phpunit_LocalConfiguration.php are copied outside the extension since \ No newline at end of file
they are necessary for the qfq bootstrap process.
## Database Setup
TODO
Needs existing database: <name>_phpunit
\ No newline at end of file
...@@ -98,7 +98,7 @@ select.qfq-locked:invalid { ...@@ -98,7 +98,7 @@ select.qfq-locked:invalid {
// margin-left: -10px; // margin-left: -10px;
//} //}
.required-field:after { .required-right:after {
color: #d00; color: #d00;
content: "*"; content: "*";
//position: absolute; //position: absolute;
...@@ -106,6 +106,14 @@ select.qfq-locked:invalid { ...@@ -106,6 +106,14 @@ select.qfq-locked:invalid {
//top: 10px; //top: 10px;
} }
.required-left:before {
color: #d00;
content: "*";
//position: absolute;
margin-right: 3px;
//top: 10px;
}
.qfq-table-50 { .qfq-table-50 {
min-width: 50%; min-width: 50%;
width: auto; width: auto;
......
Supports Markdown
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