Commit 4c49115a authored by Carsten  Rose's avatar Carsten Rose
Browse files

Form/subrecord: implement special column name '_rowTitle' - shows tooltips...

Form/subrecord: implement special column name '_rowTitle' - shows tooltips over a row of subrecords.
UsersManual/index.rst: manual updated
AbstractBuildForm.php Constants.php: recoded handling of '_rowClass' to be more generic, especially to add '_rowTitle' support.
formEditor.sql: Subrecords of the formEditor use _rowClass and _rowTitle.
parent 54310ff0
...@@ -781,7 +781,8 @@ Type: subrecord ...@@ -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 '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 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.:: * *sql1*: SQL query to select records. E.g.::
...@@ -818,6 +819,10 @@ Type: subrecord ...@@ -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) * 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) * 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* * *parameter*
* *form*: Target form, e.g. *form=person* * *form*: Target form, e.g. *form=person*
......
...@@ -1241,11 +1241,6 @@ abstract class AbstractBuildForm { ...@@ -1241,11 +1241,6 @@ abstract class AbstractBuildForm {
// construct column attributes // construct column attributes
$control = $this->getSubrecordColumnControl(array_keys($formElement['sql1'][0])); $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 // Subrecord: Column titles
$columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>'; $columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>';
} }
...@@ -1266,12 +1261,8 @@ abstract class AbstractBuildForm { ...@@ -1266,12 +1261,8 @@ abstract class AbstractBuildForm {
// All columns // All columns
foreach ($row as $columnName => $value) { foreach ($row as $columnName => $value) {
// Skip class control column if (isset($control['title'][$columnName]))
if ($columnName === FE_SUBRECORD_ROW_CLASS) { $rowHtml .= Support::wrapTag('<td>', $this->renderCell($control, $columnName, $value));
continue;
}
$rowHtml .= Support::wrapTag('<td>', $this->renderCell($control, $columnName, $value));
} }
if ($flagDelete) { if ($flagDelete) {
...@@ -1279,9 +1270,16 @@ abstract class AbstractBuildForm { ...@@ -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>')); $rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>'));
} }
$class = 'record '; Support::setIfNotSet($row, FE_SUBRECORD_ROW_CLASS);
$class .= (isset($row[FE_SUBRECORD_ROW_CLASS]) ? $row[FE_SUBRECORD_ROW_CLASS] : '') . ' '; $rowClass = 'record ';
$html .= Support::wrapTag("<tr class='$class'>", $rowHtml, true); $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); return Support::wrapTag('<table class="table table-hover">', $html, true);
...@@ -1428,6 +1426,15 @@ abstract class AbstractBuildForm { ...@@ -1428,6 +1426,15 @@ abstract class AbstractBuildForm {
$control = array(); $control = array();
foreach ($titleRaw AS $columnName) { foreach ($titleRaw AS $columnName) {
switch ($columnName) {
case FE_SUBRECORD_ROW_CLASS:
case FE_SUBRECORD_ROW_TITLE:
continue 2;
default:
break;
}
$flagWidthLimit = true; $flagWidthLimit = true;
$control['width'][$columnName] = SUBRECORD_COLUMN_WIDTH; $control['width'][$columnName] = SUBRECORD_COLUMN_WIDTH;
...@@ -1482,6 +1489,14 @@ abstract class AbstractBuildForm { ...@@ -1482,6 +1489,14 @@ abstract class AbstractBuildForm {
*/ */
private function renderCell(array $control, $columnName, $value) { 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); $arr = explode('|', $value);
if (count($arr) == 1) if (count($arr) == 1)
$arr[1] = $arr[0]; $arr[1] = $arr[0];
......
...@@ -369,6 +369,7 @@ const FE_MODE_LOCK = 'lock'; ...@@ -369,6 +369,7 @@ const FE_MODE_LOCK = 'lock';
const FE_MODE_DISABLED = 'disabled'; const FE_MODE_DISABLED = 'disabled';
const FE_SUBRECORD_ROW_CLASS = '_rowClass'; const FE_SUBRECORD_ROW_CLASS = '_rowClass';
const FE_SUBRECORD_ROW_TITLE = '_rowTitle';
// FormElement columns: real // FormElement columns: real
const FE_TYPE = 'type'; const FE_TYPE = 'type';
......
...@@ -167,7 +167,7 @@ VALUES ...@@ -167,7 +167,7 @@ VALUES
'', '', 4, ''), '', '', 4, ''),
(1, '', 'FormElements', 'show', 'subrecord', 'all', 'native', 500, 0, 0, '', '', '', (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'); '', 'form=formElement\ndetail=id:formId', 5, 'new,edit,delete');
# #
...@@ -198,7 +198,7 @@ VALUES ...@@ -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 }}', '{{!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', '', '', ''), '', 'emptyItemAtStart', 100, '', 'no', '', '', ''),
(2, 'enabled', 'Enabled', 'show', 'checkbox', 'all', 'native', 130, 0, 0, '', '', '', '', '', '', 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, 'name', 'Name', 'show', 'text', 'all', 'native', 140, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''),
(2, 'label', 'Label', 'show', 'text', 'all', 'native', 150, 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', '', '', ''), (2, 'mode', 'Mode', 'show', 'select', 'all', 'native', 160, 0, 255, '', '', '', '', '', '', 100, '', 'no', '', '', ''),
......
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