Commit 576bec10 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'crose_work'

parents 1d9e0702 a9823b0f
...@@ -557,6 +557,8 @@ parameter ...@@ -557,6 +557,8 @@ parameter
+------------------------+--------+----------------------------------------------------------------------------------------------------------+ +------------------------+--------+----------------------------------------------------------------------------------------------------------+
| submitButtonText | string | Show save button, with the <submitButtonText> at the bottom of the form | | submitButtonText | string | Show save button, with the <submitButtonText> at the bottom of the form |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+ +------------------------+--------+----------------------------------------------------------------------------------------------------------+
| extraDeleteForm | string | Name of a form which specifies how to delete the primary record and optional slave records |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
* Example: * Example:
...@@ -611,6 +613,25 @@ classBody ...@@ -611,6 +613,25 @@ classBody
* Predefined background colors: `qfq-color-white`, `qfq-color-grey-1` (dark), `qfq-color-grey-2` (light), * Predefined background colors: `qfq-color-white`, `qfq-color-grey-1` (dark), `qfq-color-grey-2` (light),
`qfq-color-blue-1` (dark), `qfq-color-blue-2`. (light) `qfq-color-blue-1` (dark), `qfq-color-blue-2`. (light)
submitButtonText
''''''''''''''''
If specified and non empty, display a regular submit button at the bottom of the page with the given text.
This gives the form a ordinary HTML-form look'n' feel. With this option, the standard buttons on the top right border
should be hided to not confuse the user.
extraDeleteForm
'''''''''''''''
Depending on the database definition, it might be necessary to delete the primary record *and* corresponding slave records.
To not repeat such 'slave record delete definition', an 'extraDeleteForm' could be specified. If the user open's a record
in a form and clicks on the 'delete' button, a defined 'extraDeleteForm'-form will be used to delete primary and slave
records instead of using the current form.
E.g. if there are multiple different forms to work on the same table, all of theses forms might reference to the same
'extraDeleteForm'-form. This simplifies the maintenance.
The 'extraDeleteForm' parameter might be specified for a 'form' and/or for 'subrecords'
FormElements FormElements
------------ ------------
* Each *form* contains one or more *FormElement*. * Each *form* contains one or more *FormElement*.
...@@ -1048,6 +1069,7 @@ will be rendered inside the form as a HTML table. ...@@ -1048,6 +1069,7 @@ will be rendered inside the form as a HTML table.
* *form*: Target form, e.g. *form=person* * *form*: Target form, e.g. *form=person*
* *page*: Target page with detail form. If none specified, use the current page. * *page*: Target page with detail form. If none specified, use the current page.
* *title*: Title displayed over the table in the current form. * *title*: Title displayed over the table in the current form.
* *extraDeleteForm*: Optional. The per row delete Button will reference such form (for deleting) instead of *form* (default).
* *detail*: Mapping of values from the primary form to the target form (defined via `form=...`). * *detail*: Mapping of values from the primary form to the target form (defined via `form=...`).
* Syntax:: * Syntax::
......
...@@ -1403,6 +1403,9 @@ abstract class AbstractBuildForm { ...@@ -1403,6 +1403,9 @@ abstract class AbstractBuildForm {
if (isset($formElement[SUBRECORD_PARAMETER_FORM])) { if (isset($formElement[SUBRECORD_PARAMETER_FORM])) {
Support::setIfNotSet($formElement, F_EXTRA_DELETE_FORM, '');
$formElement[F_FINAL_DELETE_FORM] = $formElement[F_EXTRA_DELETE_FORM] != '' ? $formElement[F_EXTRA_DELETE_FORM] : $formElement[SUBRECORD_PARAMETER_FORM];
$linkNew = Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, $this->symbol[SYMBOL_NEW], 'New')); $linkNew = Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, $this->symbol[SYMBOL_NEW], 'New'));
// Decode settings in subrecordOption // Decode settings in subrecordOption
...@@ -1423,8 +1426,9 @@ abstract class AbstractBuildForm { ...@@ -1423,8 +1426,9 @@ abstract class AbstractBuildForm {
$columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>'; $columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>';
} }
if ($flagDelete) if ($flagDelete) {
$columns .= '<th></th>'; $columns .= '<th></th>';
}
// Table head // Table head
$html = Support::wrapTag('<tr>', $columns); $html = Support::wrapTag('<tr>', $columns);
...@@ -1449,17 +1453,16 @@ abstract class AbstractBuildForm { ...@@ -1449,17 +1453,16 @@ abstract class AbstractBuildForm {
$toolTip = 'Delete'; $toolTip = 'Delete';
if ($this->showDebugInfo) { if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_NAME] . "'" . PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $row[$nameColumnId] . "'"; $toolTip .= PHP_EOL . "form = '" . $formElement[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $row[$nameColumnId] . "'";
} }
// $buttonDelete = $this->buildButtonCode('delete-button', $toolTip, GLYPH_ICON_DELETE, $disabled); // $buttonDelete = $this->buildButtonCode('delete-button', $toolTip, GLYPH_ICON_DELETE, $disabled);
$s = $this->createDeleteUrl($formElement[SUBRECORD_PARAMETER_FORM], $targetTableName, $row[$nameColumnId], RETURN_SIP); $s = $this->createDeleteUrl($formElement[F_FINAL_DELETE_FORM], '', $row[$nameColumnId], RETURN_SIP);
// $rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s'>", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>')); // $rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s'>", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>'));
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s' " . Support::doAttribute('title', $toolTip) . ">", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>')); $rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s' " . Support::doAttribute('title', $toolTip) . ">", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>'));
} }
Support::setIfNotSet($row, FE_SUBRECORD_ROW_CLASS); Support::setIfNotSet($row, FE_SUBRECORD_ROW_CLASS);
...@@ -1753,15 +1756,19 @@ abstract class AbstractBuildForm { ...@@ -1753,15 +1756,19 @@ abstract class AbstractBuildForm {
*/ */
public function createDeleteUrl($formName, $tableName, $recordId, $mode = RETURN_URL) { public function createDeleteUrl($formName, $tableName, $recordId, $mode = RETURN_URL) {
//TODO: Umstellen auf Benutzung der Link Klasse.
$queryStringArray = [ $queryStringArray = [
SIP_FORM => $formName,
SIP_TABLE => $tableName,
SIP_RECORD_ID => $recordId, SIP_RECORD_ID => $recordId,
SIP_MODE_ANSWER => MODE_JSON SIP_MODE_ANSWER => MODE_JSON
]; ];
if ($formName !== '') {
$queryStringArray[SIP_FORM] = $formName;
}
if ($tableName !== '') {
$queryStringArray[SIP_TABLE] = $tableName;
}
$queryString = Support::arrayToQueryString($queryStringArray); $queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance(); $sip = $this->store->getSipInstance();
......
...@@ -158,10 +158,6 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -158,10 +158,6 @@ class BuildFormBootstrap extends AbstractBuildForm {
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) { if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) {
$toolTip = 'Close'; $toolTip = 'Close';
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE); $buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE);
} }
...@@ -170,7 +166,7 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -170,7 +166,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'Delete'; $toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) { if ($this->showDebugInfo && $recordId > 0) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_NAME] . "'" . PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'"; $toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
} }
$disabled = ($recordId > 0) ? '' : 'disabled'; $disabled = ($recordId > 0) ? '' : 'disabled';
...@@ -345,7 +341,7 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -345,7 +341,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$tabId = $this->getTabId(); $tabId = $this->getTabId();
if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) { if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) {
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_NAME], $this->formSpec[F_TABLE_NAME], $recordId); $deleteUrl = $this->createDeleteUrl($this->formSpec[F_FINAL_DELETE_FORM], '', $recordId);
} }
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD; $actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
......
...@@ -77,7 +77,7 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -77,7 +77,7 @@ class BuildFormTable extends AbstractBuildForm {
$formEditUrl = $this->createFormEditUrl(); $formEditUrl = $this->createFormEditUrl();
$html .= "<p><a " . Support::doAttribute('href', $formEditUrl) . ">Edit</a><small>[$sipParamString]</small></p>"; $html .= "<p><a " . Support::doAttribute('href', $formEditUrl) . ">Edit</a><small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_NAME], $this->formSpec[F_TABLE_NAME], $this->store->getVar(SIP_RECORD_ID, STORE_SIP)); $deleteUrl = $this->createDeleteUrl($this->formSpec[F_FINAL_DELETE_FORM], '', $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
$html .= "<p><a " . Support::doAttribute('href', $deleteUrl) . ">Delete</a>"; $html .= "<p><a " . Support::doAttribute('href', $deleteUrl) . ">Delete</a>";
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
......
...@@ -443,8 +443,11 @@ const GLYPH_ICON_CLOSE = 'glyphicon-remove'; ...@@ -443,8 +443,11 @@ const GLYPH_ICON_CLOSE = 'glyphicon-remove';
// FORM // FORM
const F_NAME = 'name'; const F_NAME = 'name';
const F_TITLE = 'title';
const F_TABLE_NAME = 'tableName'; const F_TABLE_NAME = 'tableName';
const F_REQUIRED_PARAMETER = 'requiredParameter'; const F_REQUIRED_PARAMETER = 'requiredParameter';
const F_EXTRA_DELETE_FORM = 'extraDeleteForm';
const F_FINAL_DELETE_FORM = 'finalDeleteForm';
const F_SUBMIT_BUTTON_TEXT = 'submitButtonText'; const F_SUBMIT_BUTTON_TEXT = 'submitButtonText';
......
...@@ -238,6 +238,7 @@ class Database { ...@@ -238,6 +238,7 @@ class Database {
$sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;; $sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;;
$result = 0; $result = 0;
$stat = array(); $stat = array();
$debugSql = '';
$this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM); $this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM);
$this->store->setVar(SYSTEM_SQL_PARAM_ARRAY, $parameterArray, STORE_SYSTEM); $this->store->setVar(SYSTEM_SQL_PARAM_ARRAY, $parameterArray, STORE_SYSTEM);
...@@ -245,18 +246,26 @@ class Database { ...@@ -245,18 +246,26 @@ class Database {
// Logfile // Logfile
$this->dbLog($sqlLogMode, $sql, $parameterArray); $this->dbLog($sqlLogMode, $sql, $parameterArray);
// If BE User is logged in: report the broken SQL as well.
//TODO: im Fall von delete.php, save.php, kann hier der BE_USER nicht abgefragt werden (laeuft nicht durch T3) - Loesung finden.
if (true) {
$debugSql = '[' . $sql . ']';
}
if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) { if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) {
throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error, ERROR_DB_PREPARE); throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error . $debugSql, ERROR_DB_PREPARE);
} }
if (count($parameterArray) > 0) { if (count($parameterArray) > 0) {
if (false === $this->prepareBindParam($parameterArray)) { if (false === $this->prepareBindParam($parameterArray)) {
throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_BIND); throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_BIND);
} }
} }
if (false === $this->mysqli_stmt->execute()) { if (false === $this->mysqli_stmt->execute()) {
throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_EXECUTE); throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_EXECUTE);
} }
$msg = ''; $msg = '';
......
...@@ -233,7 +233,7 @@ class QuickFormQuery { ...@@ -233,7 +233,7 @@ class QuickFormQuery {
$sipFound = $this->validateForm($foundInStore, $formMode); $sipFound = $this->validateForm($foundInStore, $formMode);
} else { } else {
// FORM_DELETE without a form definition: Fake the form wiht only a tableName. // FORM_DELETE without a form definition: Fake the form with only a tableName.
$table = $this->store->getVar(SIP_TABLE, STORE_SIP); $table = $this->store->getVar(SIP_TABLE, STORE_SIP);
if ($table === false) { if ($table === false) {
throw new UserFormException("No 'form' and no 'table' definition found.", ERROR_MISSING_VALUE); throw new UserFormException("No 'form' and no 'table' definition found.", ERROR_MISSING_VALUE);
...@@ -378,6 +378,8 @@ class QuickFormQuery { ...@@ -378,6 +378,8 @@ class QuickFormQuery {
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f." . F_NAME . " LIKE ? AND f.deleted='no'", ROW_EXPECT_1, $form = $this->db->sql("SELECT * FROM Form AS f WHERE f." . F_NAME . " LIKE ? AND f.deleted='no'", ROW_EXPECT_1,
[$formName], 'Form not found or multiple forms with the same name.'); [$formName], 'Form not found or multiple forms with the same name.');
$form = $this->modeAdjustFormConfig($mode, $form);
$this->formSpec = $this->eval->parseArray($form); $this->formSpec = $this->eval->parseArray($form);
HelperFormElement::explodeParameter($this->formSpec); HelperFormElement::explodeParameter($this->formSpec);
...@@ -388,6 +390,10 @@ class QuickFormQuery { ...@@ -388,6 +390,10 @@ class QuickFormQuery {
Support::setIfNotSet($this->formSpec, F_BS_NOTE_COLUMNS, 3, ''); Support::setIfNotSet($this->formSpec, F_BS_NOTE_COLUMNS, 3, '');
Support::setIfNotSet($this->formSpec, F_SUBMIT_BUTTON_TEXT, ''); Support::setIfNotSet($this->formSpec, F_SUBMIT_BUTTON_TEXT, '');
Support::setIfNotSet($this->formSpec, F_EXTRA_DELETE_FORM, '');
// Set F_FINAL_DELETE_FORM
$this->formSpec[F_FINAL_DELETE_FORM] = $this->formSpec[F_EXTRA_DELETE_FORM] != '' ? $this->formSpec[F_EXTRA_DELETE_FORM] : $this->formSpec[F_NAME];
// Take default from config.ini // Take default from config.ini
$class = $this->store->getVar(SYSTEM_CSS_CLASS_QFQ_FORM_PILL, STORE_SYSTEM); $class = $this->store->getVar(SYSTEM_CSS_CLASS_QFQ_FORM_PILL, STORE_SYSTEM);
...@@ -491,6 +497,27 @@ class QuickFormQuery { ...@@ -491,6 +497,27 @@ class QuickFormQuery {
return $formName; return $formName;
} }
/**
* Depending on $mode various formSpec fields might be adjusted.
* E.g.: the form title is not important during a delete.
*
* @param $mode
* @param array $form
* @return array
*/
private function modeAdjustFormConfig($mode, array $form) {
switch ($mode) {
case FORM_DELETE:
$form[F_TITLE] = '';
break;
default:
break;
}
return $form;
}
/** /**
* Check if loading of the given form is permitted. If not, throw an exception. * Check if loading of the given form is permitted. If not, throw an exception.
* *
......
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