Commit 06fa308f authored by Carsten  Rose's avatar Carsten Rose
Browse files

Data Selenium: first implementation for FormElements

parent c0975d27
Pipeline #1332 passed with stage
in 2 minutes and 11 seconds
......@@ -1240,7 +1240,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]);
$attribute .= Support::doAttribute('name', $htmlFormElementName);
$attribute .= Support::doAttribute('class', $class);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
if (isset($formElement[FE_RETYPE_SOURCE_NAME])) {
$htmlFormElementNamePrimary = str_replace(RETYPE_FE_NAME_EXTENSION, '', $htmlFormElementName);
......@@ -1739,7 +1739,7 @@ abstract class AbstractBuildForm {
*
* @param array $formElement
* @param string $htmlFormElementName
* @param $attribute
* @param string $attribute
* @param string $value
* @param array $json
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
......@@ -1796,6 +1796,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('value', $formElement[FE_CHECKBOX_CHECKED], false);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute(FE_INPUT_AUTOCOMPLETE, 'off');
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$classActive = '';
if ($formElement[FE_CHECKBOX_CHECKED] === $value) {
......@@ -1855,6 +1856,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('name', $htmlFormElementName);
$attribute .= Support::doAttribute('value', $formElement[FE_CHECKBOX_CHECKED], false);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
if ($formElement[FE_CHECKBOX_CHECKED] === $value) {
$attribute .= Support::doAttribute('checked', 'checked');
......@@ -1979,6 +1981,8 @@ abstract class AbstractBuildForm {
$htmlFormElementNameUniq = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, $ii);
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-' . $ii);
$attribute .= Support::doAttribute('name', $htmlFormElementNameUniq);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM] . '-' . $ii);
$attribute .= Support::doAttribute('value', $itemKey[$ii]);
......@@ -2053,6 +2057,7 @@ abstract class AbstractBuildForm {
$htmlFormElementNameUniq = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, $ii);
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-' . $ii);
$attribute .= Support::doAttribute('name', $htmlFormElementNameUniq);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM] . '-' . $ii);
// Do this only the first round.
if ($flagFirst) {
......@@ -2221,6 +2226,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-' . $ii);
$attribute .= Support::doAttribute('value', $itemKey[$ii], false); // Always set value, even to '' - #3832
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM] . '-' . $ii);
if ($itemKey[$ii] == $value) {
$attribute .= Support::doAttribute('checked', 'checked');
......@@ -2314,6 +2320,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-' . $ii);
$attribute .= Support::doAttribute('value', $itemKey[$ii], false); // Always set value, even to '' - #3832
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM] . '-' . $ii);
if ($itemKey[$ii] == $value) {
$attribute .= Support::doAttribute('checked', 'checked');
......@@ -2389,6 +2396,7 @@ abstract class AbstractBuildForm {
$attribute .= $this->getAttributeList($formElement, ['autofocus']);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
$attribute .= $this->getAttributeList($formElement, [F_FE_DATA_PATTERN_ERROR, F_FE_DATA_REQUIRED_ERROR, F_FE_DATA_MATCH_ERROR, F_FE_DATA_ERROR]);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
if (isset($formElement[FE_SIZE]) && $formElement[FE_SIZE] > 1) {
$attribute .= Support::doAttribute('size', $formElement[FE_SIZE]);
......@@ -3045,6 +3053,7 @@ abstract class AbstractBuildForm {
$attribute .= $this->getAttributeList($formElement, [FE_AUTOFOCUS, FE_FILE_MIME_TYPE_ACCEPT]);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute('data-sip', $sipUpload);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement); // Below, $formElement[FE_MODE]=FE_MODE_REQUIRED will be changed. Get the JSON unchanged
......@@ -3151,6 +3160,7 @@ abstract class AbstractBuildForm {
$attributeInput .= Support::doAttribute('name', $htmlFormElementName);
$attributeInput .= Support::doAttribute('type', 'hidden');
$attributeInput .= Support::doAttribute('value', htmlentities($value), false);
$attributeInput .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$htmlInput = Support::wrapTag('<input ' . $attributeInput . ' >', '', false);
......@@ -3218,6 +3228,8 @@ abstract class AbstractBuildForm {
$attributeInput = Support::doAttribute('id', $htmlFabricId);
$attributeInput .= Support::doAttribute('name', $htmlFormElementName);
$attributeInput .= Support::doAttribute('type', 'hidden');
$attributeInput .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$htmlInput = Support::wrapTag('<input ' . $attributeInput . ' >', '', false);
// <img id="target-png"> - this element is for future use. It's not necessary for the function and is not used yet.
......@@ -3275,6 +3287,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]);
$attribute .= Support::doAttribute('name', $htmlFormElementName);
$attribute .= Support::doAttribute('class', 'form-control');
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$showTime = ($formElement[FE_TYPE] == 'time' || $formElement[FE_TYPE] == 'datetime') ? 1 : 0;
if ($value == 'CURRENT_TIMESTAMP') {
......@@ -3477,6 +3490,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]);
$attribute .= Support::doAttribute('name', $htmlFormElementName);
// $attribute .= Support::doAttribute('id', $htmlFormElementName);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
$attribute .= Support::doAttribute('class', 'qfq-tinymce');
$attribute .= Support::doAttribute('data-control-name', "$htmlFormElementName");
......@@ -3626,6 +3640,7 @@ abstract class AbstractBuildForm {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
$attribute = Support::doAttribute('id', $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
return Support::wrapTag("<div $attribute class='" . CLASS_NOTE . "'>", $value);
}
......@@ -3672,6 +3687,7 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]);
$attribute .= Support::doAttribute('name', $htmlFormElementName);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
// <fieldset>
$html = '<fieldset ' . $attribute . '>';
......@@ -3803,6 +3819,7 @@ EOT;
$attribute .= Support::doAttribute('id', $targetName);
$attribute .= Support::doAttribute('data-qfq-line-template', '#' . $templateName);
$attribute .= Support::doAttribute('data-qfq-line-add-button', '#' . $addButtonId);
$attribute .= Support::doAttribute(SELENIUM_ATTRIBUTE_DATA, $formElement[FE_DATA_SELENIUM]);
// Element where the effective FormElements will be copied to. The BS 'col-md-* Classes are inside the template, not here. This here should be pure data without wrapping.
$html = Support::wrapTag("<div $attribute>", $html, false);
......
......@@ -987,6 +987,7 @@ const FE_SIZE = 'size';
const FE_SUBRECORD_OPTION = 'subrecordOption';
const FE_SQL1 = 'sql1';
const FE_PLACEHOLDER = 'placeholder';
const FE_DATA_SELENIUM = 'dataSelenium';
// FormElement columns: via parameter field
const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN
......@@ -1675,3 +1676,5 @@ const DND_SUBRECORD_ID = 'dnd-subrecord-id'; // Internal qualifier used to commu
const DND_SUBRECORD_FORM_ID = 'dnd-subrecord-form-id';
const DND_ORD_HTML_ID_PREFIX = 'qfq-dnd-ord-id-';
// SELENIUM
const SELENIUM_ATTRIBUTE_DATA = 'data-selenium';
\ No newline at end of file
......@@ -798,6 +798,8 @@ class Support {
self::setIfNotSet($formElement, FE_HTML_BEFORE);
self::setIfNotSet($formElement, FE_HTML_AFTER);
self::setIfNotSet($formElement, FE_DATA_SELENIUM, ($formElement[FE_NAME]=='' ? $formElement[FE_ID] : $formElement[FE_NAME]) );
self::setIfNotSet($formElement, FE_SUBRECORD_TABLE_CLASS, SUBRECORD_TABLE_CLASS_DEFAULT);
if (isset($formSpec[F_BS_LABEL_COLUMNS])) {
......
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