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

Manual.rst: Update for 'dynamicUpdate of pills'.

BuildFormBootstrap.php: make buildPillNavigation dynamicUpdate aware.
QuickFormQuery.php: Fix problem with missing HTML_ID in FE.
parent e7dfc6c4
......@@ -2150,15 +2150,33 @@ Type: fieldset
* *name*: technical name, used as HTML identifier.
* *label*: Shown title of the fieldset.
Type: pill
^^^^^^^^^^
Type: pill (tab)
^^^^^^^^^^^^^^^^
* Pill is synonymous for a tab and looks like a tab.
* If there is at least one pill defined:
* every native *FormElement* needs to be assigned to a pill or to a fieldset.
* every *fieldset* needs to be assigned to a pill.
* Mode:
* `show`: all child elements will be shown.
* `required`: same as 'show'. This mode has no other meaning than 'show'.
* `readonly`: technical it's like HTML/CSS `disabled`.
* The pill title is shown, but not clickable.
* The `FormElements` on the pill still exist, but are not reachable for the user via UI.
* `hidden`:
* The pill is invisible.
* The `FormElements` on the pill still exist, but are not reachable for the user via UI.
* Note: Independent of the *mode*, all child elements are always rendered and processed by the client/server.
* Pill is synonymous for a tab. A pill looks like a tab.
* Pills are only available with mode render='bootstrap'.
* If there is at least one pill defined, every native *FormElement* needs to be assigned to a pill or to a fieldset.
* If there is at least one pill defined, every *fieldset* needs to be assigned to a pill.
* Pills are not 'dynamicUpdate' aware (at the moment). At least during form load, *modeSql* can be dynamically computed to
switch the pill in show / readonly (disabled) / hidden state.
* Pills are 'dynamicUpdate' aware. `title` and `mode` are optional recalculated during 'dynamicUpdate'.
* FormElement settings:
......
......@@ -245,7 +245,7 @@ abstract class AbstractBuildForm {
*
* @return string
*/
public function head() {
public function head($mode = FORM_LOAD) {
$html = '';
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], true) . '>'; // main <div class=...> around everything
......@@ -634,7 +634,7 @@ abstract class AbstractBuildForm {
}
} else {
// for non-container elements: just add the current json status
if ($modeCollectFe === FLAG_ALL || ($modeCollectFe == FLAG_DYNAMIC_UPDATE && $fe[FE_DYNAMIC_UPDATE] == 'yes')) {
if ($modeCollectFe === FLAG_ALL || ($modeCollectFe == FLAG_DYNAMIC_UPDATE && $fe[FE_DYNAMIC_UPDATE] === 'yes')) {
if (isset($jsonElement[0]) && is_array($jsonElement[0])) {
// Checkboxes are delivered as array of arrays: unnest them and append them to the existing json array.
$json = array_merge($json, $jsonElement);
......
......@@ -107,18 +107,18 @@ class BuildFormBootstrap extends AbstractBuildForm {
/**
* @return string
*/
public function head() {
public function head($mode = FORM_LOAD) {
$html = '';
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], true) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
//TODO: nicer error reporting - make test with 'unknown index' here - unset($this->formSpec['title']) - See #3424
$title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec['title']));
$title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec[F_TITLE]));
$button = Support::wrapTag('<div class="col-xs-12 col-sm-6 col-md-4">', $this->buildButtons());
$html .= Support::wrapTag('<div class="row">', $title . $button);
$dummy = array();
$pill = $this->buildPillNavigation(OnArray::filter($this->feSpecNative, 'type', 'pill'), $dummy);
$pill = $this->buildPillNavigation($mode, OnArray::filter($this->feSpecNative, FE_TYPE, FE_TYPE_PILL), $dummy);
$html .= Support::wrapTag('<div class="row">', $pill);
$html .= $this->getFormTag();
......@@ -356,15 +356,17 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
/**
* Builds the BS-pills on top of a form.
*
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @param array $pillArray
*
* @param array $json
* @return string
*
* @throws CodeException
* @throws UserFormException
*/
private function buildPillNavigation(array $pillArray, array &$json) {
private function buildPillNavigation($mode = FORM_LOAD, array $pillArray, array &$json) {
$pillButton = '';
$pillDropdown = '';
$htmlDropdown = '';
......@@ -383,6 +385,10 @@ class BuildFormBootstrap extends AbstractBuildForm {
$recordId = $this->store->getVar(COLUMN_ID, STORE_RECORD . STORE_ZERO);
foreach ($pillArray as $formElement) {
if ($mode != FORM_LOAD && $formElement[FE_DYNAMIC_UPDATE] !== 'yes') {
continue; // During save/update: Process only FE dynamic_update=yes
}
$htmlIdLi = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_PILL_LI;
$htmlIdLiA = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_PILL_LI_A;
......@@ -415,21 +421,24 @@ class BuildFormBootstrap extends AbstractBuildForm {
$json[$htmlFormElementName][API_ELEMENT_UPDATE][$htmlIdLi][API_ELEMENT_ATTRIBUTE][HTML_ATTR_CLASS] = '';
$json[$htmlFormElementName][API_ELEMENT_UPDATE][$htmlIdLiA][API_ELEMENT_ATTRIBUTE][HTML_ATTR_CLASS] = '';
break;
case FE_MODE_READONLY:
$hrefTarget = '#';
$attributeLi = Support::doAttribute('class', 'disabled');
$json[$htmlFormElementName][API_ELEMENT_UPDATE][$htmlIdLi][API_ELEMENT_ATTRIBUTE][HTML_ATTR_CLASS] = 'disabled';
$hrefTarget = '#';
$attributeLiA .= Support::doAttribute('class', 'noclick');
$json[$htmlFormElementName][API_ELEMENT_UPDATE][$htmlIdLiA][API_ELEMENT_ATTRIBUTE][HTML_ATTR_CLASS] = 'noclick';
break;
case FE_MODE_HIDDEN:
// $attributeLi = Support::doAttribute('style', 'display: none');
$attributeLi = Support::doAttribute('class', 'hidden');
$json[$htmlFormElementName][API_ELEMENT_UPDATE][$htmlIdLi][API_ELEMENT_ATTRIBUTE][HTML_ATTR_CLASS] = 'hidden';
$a = '';
break;
default:
throw new UserFormException("Unknown Mode: " . $formElement[FE_MODE], ERROR_UNKNOWN_MODE);
}
......@@ -444,6 +453,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
} else {
$pillDropdown .= '<li ' . $attributeLi . '>' . $a . "</li>";
}
$active = '';
}
......@@ -772,12 +782,13 @@ EOF;
public function process($mode, $htmlElementNameIdZero = false, $latestFeSpecNative = array()) {
$json = array();
$data = parent::process($mode, $htmlElementNameIdZero = false, $latestFeSpecNative = array());
$data = parent::process($mode, $htmlElementNameIdZero, $latestFeSpecNative);
switch ($mode) {
case FORM_SAVE:
case FORM_UPDATE:
$pillArray = OnArray::filter($this->feSpecNative, 'type', 'pill');
$this->buildPillNavigation($pillArray, $json);
$pillArray = OnArray::filter($this->feSpecNative, FE_TYPE, FE_TYPE_PILL);
$this->buildPillNavigation($mode, $pillArray, $json);
$data = array_merge($data, $json);
break;
default:
......
......@@ -974,6 +974,7 @@ const FE_TYPE_SENDMAIL = 'sendMail';
const FE_TYPE_PASTE = 'paste';
const FE_TYPE_TEMPLATE_GROUP = 'templateGroup';
const FE_TYPE_PILL = 'pill';
const FE_HTML_ID = 'htmlId'; // Will be dynamically computed during runtime.
......
......@@ -425,7 +425,10 @@ class QuickFormQuery {
// Values of FormElements might be changed during 'afterSave': rebuild the form to load the new values. Especially for non primary template groups.
// $this->loadFormSpecification($formMode, $recordId, $foundInStore);
$this->feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec["id"]], $this->formSpec);
$feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec[F_ID]], $this->formSpec);
$parameterLanguageFieldName = $this->store->getVar(SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME, STORE_SYSTEM);
$feSpecNative = HelperFormElement::setLanguage($feSpecNative, $parameterLanguageFieldName);
$this->feSpecNative = HelperFormElement::setFeContainerFormElementId($feSpecNative, $this->formSpec[F_ID], $recordId);
// Retrieve FE Values as JSON
// $data['form-update']=...
......@@ -711,7 +714,7 @@ class QuickFormQuery {
case FORM_SAVE:
case FORM_UPDATE:
$feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec["id"]], $this->formSpec);
$feSpecNative = $this->getNativeFormElements(SQL_FORM_ELEMENT_NATIVE_TG_COUNT, [$this->formSpec[F_ID]], $this->formSpec);
break;
case FORM_DELETE:
......
......@@ -256,7 +256,7 @@ EOT;
SYSTEM_DB_INDEX_QFQ => '1',
SYSTEM_DATE_FORMAT => 'yyyy-mm-dd',
SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_NO,
SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_AUTO,
F_BS_COLUMNS => '12',
F_BS_LABEL_COLUMNS => '3',
......
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