Commit 781c09a5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractBuildForm.php, BuildFormBootstrap.php, BuildFormTable.php,...

AbstractBuildForm.php, BuildFormBootstrap.php, BuildFormTable.php, Constants.php, QuickFormQuery.php, Index.rst: Implemented Paramater 'extraDeleteForm' for 'forms' and 'subrecords'. Doku update.
parent 5fc80b2f
......@@ -557,6 +557,8 @@ parameter
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| 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:
......@@ -611,6 +613,25 @@ classBody
* 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)
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
------------
* Each *form* contains one or more *FormElement*.
......@@ -1048,6 +1069,7 @@ will be rendered inside the form as a HTML table.
* *form*: Target form, e.g. *form=person*
* *page*: Target page with detail form. If none specified, use the current page.
* *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=...`).
* Syntax::
......
......@@ -1403,6 +1403,9 @@ abstract class AbstractBuildForm {
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'));
// Decode settings in subrecordOption
......@@ -1423,8 +1426,9 @@ abstract class AbstractBuildForm {
$columns .= '<th>' . implode('</th><th>', $control['title']) . '</th>';
}
if ($flagDelete)
if ($flagDelete) {
$columns .= '<th></th>';
}
// Table head
$html = Support::wrapTag('<tr>', $columns);
......@@ -1449,12 +1453,12 @@ abstract class AbstractBuildForm {
$toolTip = 'Delete';
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_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);
$s = $this->createDeleteUrl($formElement[SUBRECORD_PARAMETER_FORM], '', $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' " . Support::doAttribute('title', $toolTip) . ">", '<span class="glyphicon ' . GLYPH_ICON_DELETE . '"></span>'));
......
......@@ -158,10 +158,6 @@ class BuildFormBootstrap extends AbstractBuildForm {
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) {
$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);
}
......@@ -170,7 +166,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$disabled = ($recordId > 0) ? '' : 'disabled';
......@@ -345,7 +341,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$tabId = $this->getTabId();
if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) {
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_NAME], '', $recordId);
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_FINAL_DELETE_FORM], '', $recordId);
}
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
......
......@@ -77,7 +77,7 @@ class BuildFormTable extends AbstractBuildForm {
$formEditUrl = $this->createFormEditUrl();
$html .= "<p><a " . Support::doAttribute('href', $formEditUrl) . ">Edit</a><small>[$sipParamString]</small></p>";
$deleteUrl = $this->createDeleteUrl($this->formSpec[F_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 .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
......
......@@ -445,6 +445,8 @@ const GLYPH_ICON_CLOSE = 'glyphicon-remove';
const F_NAME = 'name';
const F_TABLE_NAME = 'tableName';
const F_REQUIRED_PARAMETER = 'requiredParameter';
const F_EXTRA_DELETE_FORM = 'extraDeleteForm';
const F_FINAL_DELETE_FORM = 'finalDeleteForm';
const F_SUBMIT_BUTTON_TEXT = 'submitButtonText';
......
......@@ -233,7 +233,7 @@ class QuickFormQuery {
$sipFound = $this->validateForm($foundInStore, $formMode);
} 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);
if ($table === false) {
throw new UserFormException("No 'form' and no 'table' definition found.", ERROR_MISSING_VALUE);
......@@ -388,6 +388,10 @@ class QuickFormQuery {
Support::setIfNotSet($this->formSpec, F_BS_NOTE_COLUMNS, 3, '');
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
$class = $this->store->getVar(SYSTEM_CSS_CLASS_QFQ_FORM_PILL, STORE_SYSTEM);
......
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