Commit 13647f3a authored by Carsten  Rose's avatar Carsten Rose
Browse files

#4428 / subrecord: mode=readonly

AbstractBuildFrom.php: Add new symbol 'show'. Honor switch between Edit and Show for subrecord elements.
QuickFormQuery.php: If F_MODE is not set, check if there is a SIP var with F_MODE_GLOBAL=F_MODE_READONLY
parent f6e5b99a
...@@ -1819,7 +1819,7 @@ parameter ...@@ -1819,7 +1819,7 @@ parameter
| typeAheadMinLength | int | Minimum number of characters which have to typed to start the search. | | typeAheadMinLength | int | Minimum number of characters which have to typed to start the search. |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| mode | string | The value `readonly` will activate a global readonly mode of the form - the user can't change any data. | | mode | string | The value `readonly` will activate a global readonly mode of the form - the user can't change any data. |
| | | See :ref:`form-mode-readonly` | | | | See :ref:`form-mode-global` |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| saveButtonActive | - | Make the 'save'-button active on *Form* load (instead of waiting for the first user change) | | saveButtonActive | - | Make the 'save'-button active on *Form* load (instead of waiting for the first user change) |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
...@@ -1924,10 +1924,10 @@ The 'extraDeleteForm' parameter might be specified for a 'form' and/or for 'subr ...@@ -1924,10 +1924,10 @@ The 'extraDeleteForm' parameter might be specified for a 'form' and/or for 'subr
See also: `delete-record`_. See also: `delete-record`_.
.. _form-mode-readonly: .. _form-mode-global:
Global Form mode 'readonly' Form mode global - 'readonly'
''''''''''''''''''''''''''' '''''''''''''''''''''''''''''
The form.parameter setting `mode=readonly` will switch the whole form into a `readonly` mode, which is a fast way to use The form.parameter setting `mode=readonly` will switch the whole form into a `readonly` mode, which is a fast way to use
an existing *Form* just to display the form data, without a possibility for the user to change any data of the form. an existing *Form* just to display the form data, without a possibility for the user to change any data of the form.
...@@ -2732,6 +2732,13 @@ The *FormElement* type 'subrecord' renders a list of records (so called secondar ...@@ -2732,6 +2732,13 @@ The *FormElement* type 'subrecord' renders a list of records (so called secondar
or add new records. The list is defined as a SQL query. The number of records shown is not limited. These *FormElement* or add new 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. will be rendered inside the form as a HTML table.
* *mode / modeSql*:
* *show / required*: the regular mode to show the subrecords
* *readonly*: New / Edit / Delete Buttons are disabled
* *hidden*: The FormElement is rendered, but disabled with `display='none'`.
* *dynamicUpdate*: not supported at the moment.
* *sql1*: SQL query to select records. E.g.:: * *sql1*: SQL query to select records. E.g.::
{{!SELECT a.id AS id, CONCAT(a.street, a.streetnumber) AS a, a.city AS b, a.zip AS c FROM Address AS a}} {{!SELECT a.id AS id, CONCAT(a.street, a.streetnumber) AS a, a.city AS b, a.zip AS c FROM Address AS a}}
......
...@@ -127,6 +127,7 @@ abstract class AbstractBuildForm { ...@@ -127,6 +127,7 @@ abstract class AbstractBuildForm {
]; ];
$this->symbol[SYMBOL_EDIT] = "<span class='glyphicon " . GLYPH_ICON_EDIT . "'></span>"; $this->symbol[SYMBOL_EDIT] = "<span class='glyphicon " . GLYPH_ICON_EDIT . "'></span>";
$this->symbol[SYMBOL_SHOW] = "<span class='glyphicon " . GLYPH_ICON_SHOW . "'></span>";
$this->symbol[SYMBOL_NEW] = "<span class='glyphicon " . GLYPH_ICON_NEW . "'></span>"; $this->symbol[SYMBOL_NEW] = "<span class='glyphicon " . GLYPH_ICON_NEW . "'></span>";
$this->symbol[SYMBOL_DELETE] = "<span class='glyphicon " . GLYPH_ICON_DELETE . "'></span>"; $this->symbol[SYMBOL_DELETE] = "<span class='glyphicon " . GLYPH_ICON_DELETE . "'></span>";
...@@ -2309,14 +2310,12 @@ abstract class AbstractBuildForm { ...@@ -2309,14 +2310,12 @@ abstract class AbstractBuildForm {
$formElement[F_FINAL_DELETE_FORM] = $formElement[F_EXTRA_DELETE_FORM] != '' ? $formElement[F_EXTRA_DELETE_FORM] : $formElement[SUBRECORD_PARAMETER_FORM]; $formElement[F_FINAL_DELETE_FORM] = $formElement[F_EXTRA_DELETE_FORM] != '' ? $formElement[F_EXTRA_DELETE_FORM] : $formElement[SUBRECORD_PARAMETER_FORM];
// Decode settings in subrecordOption // Decode settings in subrecordOption
$flagNew = Support::findInSet(SUBRECORD_NEW, $formElement[FE_SUBRECORD_OPTION]); $flagNew = Support::findInSet(SUBRECORD_NEW, $formElement[FE_SUBRECORD_OPTION]) && ($formElement[FE_MODE] != FE_MODE_READONLY);
$flagEdit = Support::findInSet(SUBRECORD_EDIT, $formElement[FE_SUBRECORD_OPTION]); $flagEdit = Support::findInSet(SUBRECORD_EDIT, $formElement[FE_SUBRECORD_OPTION]);
if ($flagDelete = Support::findInSet(SUBRECORD_DELETE, $formElement[FE_SUBRECORD_OPTION])) { $flagDelete = Support::findInSet(SUBRECORD_DELETE, $formElement[FE_SUBRECORD_OPTION]) && ($formElement[FE_MODE] != FE_MODE_READONLY);
// $targetTableName = $this->getFormTable($formElement[SUBRECORD_PARAMETER_FORM]);
}
$linkNew = $flagNew ? Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, $this->symbol[SYMBOL_NEW], 'New')) : '<th></th>'; $linkNew = $flagNew ? Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, $this->symbol[SYMBOL_NEW], 'New')) : '<th></th>';
} }
$columns = $linkNew; $columns = $linkNew;
...@@ -2340,7 +2339,9 @@ abstract class AbstractBuildForm { ...@@ -2340,7 +2339,9 @@ abstract class AbstractBuildForm {
$rowHtml = ''; $rowHtml = '';
if ($flagEdit) { if ($flagEdit) {
$rowHtml .= Support::wrapTag('<td>', $this->createFormLink($formElement, $row[$nameColumnId], $primaryRecord, $this->symbol[SYMBOL_EDIT], 'Edit', $row)); $toolTip = ($formElement[FE_MODE] == FE_MODE_READONLY) ? 'Show' : 'Edit';
$symbol = ($formElement[FE_MODE] == FE_MODE_READONLY) ? $this->symbol[SYMBOL_SHOW] : $this->symbol[SYMBOL_EDIT];
$rowHtml .= Support::wrapTag('<td>', $this->createFormLink($formElement, $row[$nameColumnId], $primaryRecord, $symbol, $toolTip, $row));
} elseif ($flagNew) { } elseif ($flagNew) {
$rowHtml .= Support::wrapTag('<td>', $rowHtml, false); $rowHtml .= Support::wrapTag('<td>', $rowHtml, false);
} }
...@@ -2463,6 +2464,10 @@ abstract class AbstractBuildForm { ...@@ -2463,6 +2464,10 @@ abstract class AbstractBuildForm {
SIP_RECORD_ID => $targetRecordId, SIP_RECORD_ID => $targetRecordId,
]; ];
if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$queryStringArray[F_MODE_GLOBAL] = F_MODE_READONLY;
}
// Add custom query parameter // Add custom query parameter
if (isset($formElement[SUBRECORD_PARAMETER_DETAIL])) { if (isset($formElement[SUBRECORD_PARAMETER_DETAIL])) {
$detailParam = KeyValueStringParser::parse($formElement[SUBRECORD_PARAMETER_DETAIL]); $detailParam = KeyValueStringParser::parse($formElement[SUBRECORD_PARAMETER_DETAIL]);
......
...@@ -661,6 +661,7 @@ const CLASS_FORM_ELEMENT_EDIT = 'qfq-form-element-edit'; ...@@ -661,6 +661,7 @@ const CLASS_FORM_ELEMENT_EDIT = 'qfq-form-element-edit';
// BuildForm // BuildForm
const SYMBOL_NEW = 'new'; const SYMBOL_NEW = 'new';
const SYMBOL_EDIT = 'edit'; const SYMBOL_EDIT = 'edit';
const SYMBOL_SHOW = 'show';
const SYMBOL_DELETE = 'delete'; const SYMBOL_DELETE = 'delete';
//CHECKBOX //CHECKBOX
...@@ -753,6 +754,7 @@ const F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN = 'typeAheadLdapSearchPerToken'; ...@@ -753,6 +754,7 @@ const F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN = 'typeAheadLdapSearchPerToken';
const F_MODE = 'mode'; const F_MODE = 'mode';
const F_MODE_READONLY = 'readonly'; const F_MODE_READONLY = 'readonly';
const F_MODE_GLOBAL = 'formModeGlobal';
const F_SAVE_BUTTON_ACTIVE = 'saveButtonActive'; const F_SAVE_BUTTON_ACTIVE = 'saveButtonActive';
......
...@@ -854,6 +854,10 @@ class QuickFormQuery { ...@@ -854,6 +854,10 @@ class QuickFormQuery {
Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, ''); Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, '');
Support::setIfNotSet($formSpec, F_MODE, ''); Support::setIfNotSet($formSpec, F_MODE, '');
if ($formSpec[F_MODE] == '' && $this->store->getVar(F_MODE_GLOBAL, STORE_SIP . STORE_CLIENT, SANITIZE_ALLOW_ALNUMX) == FE_MODE_READONLY) {
$formSpec[F_MODE] = F_MODE_READONLY;
}
if ($formSpec[F_MODE] == F_MODE_READONLY) { if ($formSpec[F_MODE] == F_MODE_READONLY) {
$formSpec[F_SHOW_BUTTON] = FORM_BUTTON_CLOSE; $formSpec[F_SHOW_BUTTON] = FORM_BUTTON_CLOSE;
$formSpec[F_SUBMIT_BUTTON_TEXT] = ''; $formSpec[F_SUBMIT_BUTTON_TEXT] = '';
......
Markdown is supported
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