diff --git a/extension/Documentation/UsersManual/Index.rst b/extension/Documentation/UsersManual/Index.rst index 295c014734b0ee4600dbef35bec084be0417301e..ee932088c7bada5fcdf8c8be2b2e3501c559891a 100644 --- a/extension/Documentation/UsersManual/Index.rst +++ b/extension/Documentation/UsersManual/Index.rst @@ -781,7 +781,8 @@ Type: subrecord 'subrecord' present a list of records (called secondary records), typically to edit, delete or add such records. The list is defined as a SQL query. The number of records shown is not limited. These formelement will be rendered inside the - form as a HTML table. + form as a HTML table. The list is ordered by 1) formelement.class (action, container, native), 2) formelement.container, + 3) formelement.ord * *sql1*: SQL query to select records. E.g.:: @@ -818,6 +819,10 @@ Type: subrecord * Text color: *text-muted|text-primary|text-success|text-info|text-warning|text-danger* (http://getbootstrap.com/css/#helper-classes) * Row background: *active|success|info|warning|danger* (http://getbootstrap.com/css/#tables-contextual-classes) + * *_rowTitle* + + * Defines the title attribute of a subrecod table row (tooltip). + * *parameter* * *form*: Target form, e.g. *form=person* diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 602c745720e6d4c54d726d6f673df75e807cc6fb..7a10ac7e18573db1fe05db379217090b9c24f851 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -1241,11 +1241,6 @@ abstract class AbstractBuildForm { // construct column attributes $control = $this->getSubrecordColumnControl(array_keys($formElement['sql1'][0])); - // Skip '_rowClass': should not be shown in the title. - if (isset($control['title'][FE_SUBRECORD_ROW_CLASS])) { - unset($control['title'][FE_SUBRECORD_ROW_CLASS]); - } - // Subrecord: Column titles $columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>'; } @@ -1266,12 +1261,8 @@ abstract class AbstractBuildForm { // All columns foreach ($row as $columnName => $value) { - // Skip class control column - if ($columnName === FE_SUBRECORD_ROW_CLASS) { - continue; - } - - $rowHtml .= Support::wrapTag('<td>', $this->renderCell($control, $columnName, $value)); + if (isset($control['title'][$columnName])) + $rowHtml .= Support::wrapTag('<td>', $this->renderCell($control, $columnName, $value)); } if ($flagDelete) { @@ -1279,9 +1270,16 @@ abstract class AbstractBuildForm { $rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>')); } - $class = 'record '; - $class .= (isset($row[FE_SUBRECORD_ROW_CLASS]) ? $row[FE_SUBRECORD_ROW_CLASS] : '') . ' '; - $html .= Support::wrapTag("<tr class='$class'>", $rowHtml, true); + Support::setIfNotSet($row, FE_SUBRECORD_ROW_CLASS); + $rowClass = 'record '; + $rowClass .= $row[FE_SUBRECORD_ROW_CLASS]; + + Support::setIfNotSet($row, FE_SUBRECORD_ROW_TITLE); + $rowTitle = $row[FE_SUBRECORD_ROW_TITLE]; + + $rowAttribute = Support::doAttribute('class', $rowClass); + $rowAttribute .= Support::doAttribute('title', $rowTitle); + $html .= Support::wrapTag("<tr $rowAttribute>", $rowHtml, true); } return Support::wrapTag('<table class="table table-hover">', $html, true); @@ -1428,6 +1426,15 @@ abstract class AbstractBuildForm { $control = array(); foreach ($titleRaw AS $columnName) { + + switch ($columnName) { + case FE_SUBRECORD_ROW_CLASS: + case FE_SUBRECORD_ROW_TITLE: + continue 2; + default: + break; + } + $flagWidthLimit = true; $control['width'][$columnName] = SUBRECORD_COLUMN_WIDTH; @@ -1482,6 +1489,14 @@ abstract class AbstractBuildForm { */ private function renderCell(array $control, $columnName, $value) { + switch ($columnName) { + case FE_SUBRECORD_ROW_CLASS: + case FE_SUBRECORD_ROW_TITLE: + return ''; + default: + break; + } + $arr = explode('|', $value); if (count($arr) == 1) $arr[1] = $arr[0]; diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index e06175cc5f8746a8e00187e45d09b14eb3891d20..1814fa1a14d51423151f071d4b935d54037cec93 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -369,6 +369,7 @@ const FE_MODE_LOCK = 'lock'; const FE_MODE_DISABLED = 'disabled'; const FE_SUBRECORD_ROW_CLASS = '_rowClass'; +const FE_SUBRECORD_ROW_TITLE = '_rowTitle'; // FormElement columns: real const FE_TYPE = 'type'; diff --git a/extension/qfq/sql/formEditor.sql b/extension/qfq/sql/formEditor.sql index c737fcf7fe3e478ad4135d33a054a52af43cb3a3..ed94c35ed2e6a282c9604f39a1f1fb8feef4bccd 100644 --- a/extension/qfq/sql/formEditor.sql +++ b/extension/qfq/sql/formEditor.sql @@ -167,7 +167,7 @@ VALUES '', '', 4, ''), (1, '', 'FormElements', 'show', 'subrecord', 'all', 'native', 500, 0, 0, '', '', '', - '{{!SELECT IF(enabled="yes", IF(class="container","info", IF(class="action","success","")), "text-muted") AS _rowClass, id, feIdContainer, name, label, mode, class, type, ord, size, sql1, parameter FROM FormElement WHERE formId={{id:R0}} ORDER BY ord, id}}', + '{{!SELECT IF( fe.enabled="yes", IF( fe.enabled="yes" AND fe.feIdContainer=0 AND !ISNULL(feCX.id) AND fe.class="native", "danger", IF( fe.class="container", "text-info", IF( fe.class="action", "text-success", ""))), "text-muted") AS _rowClass, IF( fe.enabled="yes", IF(fe.feIdContainer=0 AND !ISNULL(feCX.id) AND fe.class="native", "Please choose a container for this formelement", fe.class), "Disabled") AS _rowTitle, fe.id, CONCAT( IFNULL( CONCAT( feC.name, " (", fe.feIdContainer, ")"),"")) AS Container, fe.name, fe.label, fe.mode, fe.class, fe.type, fe.ord, fe.size, fe.sql1, fe.parameter FROM FormElement AS fe LEFT JOIN FormElement AS feC ON feC.id=fe.feIdContainer AND feC.formId=fe.formId LEFT JOIN FormElement AS feCX ON feCX.class="container" AND feCX.enabled="yes" AND feCX.formId=fe.formId WHERE fe.formId={{id:R0}} GROUP BY fe.id ORDER BY fe.class DESC, fe.feIdContainer, fe.ord, fe.id}}', '', 'form=formElement\ndetail=id:formId', 5, 'new,edit,delete'); # @@ -198,7 +198,7 @@ VALUES '{{!SELECT fe.id, CONCAT(fe.class, " / ", fe.label) FROM FormElement As fe WHERE fe.formId={{formId}} AND fe.class="container" ORDER BY fe.ord }}', '', 'emptyItemAtStart', 100, '', 'no', '', '', ''), (2, 'enabled', 'Enabled', 'show', 'checkbox', 'all', 'native', 130, 0, 0, '', '', '', '', '', '', 100, '', 'no', '', '', ''), - (2, 'dynamicUpdate', 'Dynamic Update', 'show', 'checkbox', 'all', 'native', 135, 0, 0, 'This element will be updated on change and trigger other.', '', '', '', '', '', 100, '', 'no', '3', '2', '7'), + (2, 'dynamicUpdate', 'Dynamic Update', 'show', 'checkbox', 'all', 'native', 135, 0, 0, 'On change, this element will be updated and trigger other.', '', '', '', '', '', 100, '', 'no', '3', '2', '7'), (2, 'name', 'Name', 'show', 'text', 'all', 'native', 140, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), (2, 'label', 'Label', 'show', 'text', 'all', 'native', 150, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''), (2, 'mode', 'Mode', 'show', 'select', 'all', 'native', 160, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''),