Skip to content
Snippets Groups Projects
Commit 8595e0c5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#1931 - Form: FE 'subrecord' zeigt keinen 'new' Button an wenn es keine Subrecords gibt.

UsersManual/index.rst: more details to 'Type: subrecord'
AbstracctBuildForm.php: check if there are no subrecords. No subrecors mean: display only the 'new' button. prepareSubrecord() returns now 'true' even if there are no subrecords.
parent 3f282465
No related branches found
No related tags found
No related merge requests found
......@@ -788,7 +788,8 @@ Type: subrecord
# Notice the **exclamation mark** after '{{' - this is necessary to return an array of elements, instead of a single string.
* Exactly one column 'id' has to exist; it specifies the primary record for the target form.
* Exactly one column 'id' has to exist; it specifies the primary record for the target form. If the column 'id' should
not be shown to the user, it's ok to hide the columen by name it '_id'.
* Columnname: *<title>[|<number>][|width=<number>][|nostrip][|icon][|url][|mailto]*
......@@ -806,8 +807,10 @@ Type: subrecord
'checked.png' AS 'Status\|icon', email AS 'mailto', CONCAT(homepage, '\|Homepage') AS 'url' ...
* Special column name: *_rowClass*
* Defines CSS class name(s) which will be rendered in the *<tr class="<_rowClass>">*.
* Define CSS class name(s) which will be rendered in the *<tr class="<_rowClass>">* of the subrecord table.
* By using Bootstrap, the following predefined classes are available:
* 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)
......
......@@ -1208,6 +1208,7 @@ abstract class AbstractBuildForm {
$flagEdit = false;
$flagDelete = false;
$linkNew = '';
$control = array();
$primaryRecord = $this->store->getStore(STORE_RECORD);
......@@ -1227,17 +1228,21 @@ abstract class AbstractBuildForm {
}
}
// construct column attributes
$control = $this->getSubrecordColumnControl(array_keys($formElement['sql1'][0]));
$columns = $linkNew;
if (isset($formElement['sql1'][0])) {
// 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]);
}
// Skip class control column
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>';
}
// Subrecord: Column titles
$columns = $linkNew;
$columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>';
if ($flagDelete)
$columns .= '<th></th>';
......@@ -1263,10 +1268,6 @@ abstract class AbstractBuildForm {
}
if ($flagDelete) {
// $rowHtml .= Support::wrapTag('<td>', $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $this->showDebugInfo));
// $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $this->showDebugInfo)
// <button type="button" class="record-delete" data-sip={{SIP}}><span class="glyphicon glyphicon-trash"></span></button>
$s = $this->createDeleteUrl($targetTableName, $row['id'], RETURN_SIP);
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>'));
}
......@@ -1280,6 +1281,10 @@ abstract class AbstractBuildForm {
}
/**
* Prepare Subrecord:
* - check if the current record has an recordId>0. If not, subrecord can't be edited. Return a message.
* - check if there is an SELECT statement for the subrecords.
*
* @param $formElement
* @param $primaryRecord
* @param $rcText
......@@ -1301,14 +1306,14 @@ abstract class AbstractBuildForm {
// No records?
if (count($formElement['sql1']) == 0) {
$rcText = '';
return false;
return true;
}
if (!isset($formElement['sql1'][0][$nameColumnId]))
$nameColumnId = '_id';
if (!isset($formElement['sql1'][0][$nameColumnId])) {
throw new UserFormException('Missing column \'id\' (or "@_id") in \'sql1\' Query', ERROR_DB_MISSING_COLUMN_ID);
throw new UserFormException('Missing column \'id\' (or "_id") in \'sql1\' Query', ERROR_DB_MISSING_COLUMN_ID);
}
return true;
......
......@@ -60,7 +60,7 @@ class Evaluate {
}
/**
* Recursive evaluation of 'line'. Constant string, Variables or SQL Query or all of them.
* Recursive evaluation of 'line'. Constant string, Variables or SQL Query or all of them. All queries will be fired.
*
* Token to replace have to be enclosed by '{{' and '}}'
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment