Commit d84dad1a authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3463 / form.mode=readonly

Implemented the option to make a form `readonly`. this can be done statically or dynamically via variable (e.g. SIP).
QuickFormQuery.php, AbstractBuildForm.php: Force 'readonly' by overwriting FormElement individual 'mode' setting.
BuildFormBootstrap.php: Introduced new variable F_SHOW_BUTTON.
parent e5f2cd88
......@@ -218,7 +218,7 @@ config.qfq.ini
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| FORM_BS_NOTE_COLUMNS | FORM_BS_NOTE_COLUMNS = 3 | Default number of BS columns for the 'note'-column |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| FORM_BUTTON_ON_CHANGE_CLASS | FORM_BUTTON_ON_CHANGE_CLASS=alert-info btn-info | Color for save button after modification |
| FORM_BUTTON_ON_CHANGE_CLASS | FORM_BUTTON_ON_CHANGE_CLASS=alert-info btn-info | Color for save button after modification |
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
| BASE_URL_PRINT | BASE_URL_PRINT=http://example.com | URL where wkhtmltopdf will fetch the HTML (no parameter, those comes later)|
+-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+
......@@ -874,7 +874,7 @@ The *FormElement.parameter*=*typeAheadLdap* will trigger LDAP searches on every
* *typeAheadLdapSearch* = `(|(cn=*?*)(mail=*?*))`
* *typeAheadLdapValuePrintf* = `'%s / %s', cn, email`
* *typeAheadLdapIdPrintf* = `'%s', email`
* Optional: *ldapUseBindCredentials*=1
* Optional: *ldapUseBindCredentials* = 1
All fetched LDAP values will be formatted with:
* *typeAheadLdapValuePrintf*, shown to the user in a drop-down box and
......@@ -920,7 +920,7 @@ Important: LDAP access might slow down the *Form* processing on load, update or
* *typeAheadLdapSearch* = `(|(cn=*?*)(mail=*?*))`
* *ldapAttributes* = `givenName, sn, telephoneNumber, email`
* *ldapSearch* = `(mail={{email::l}})`
* Optional: *ldapUseBindCredentials*=1
* Optional: *ldapUseBindCredentials* = 1
After filling the store, access the content via `{{<attributename>:allbut:L:s}}`.
......@@ -1070,7 +1070,8 @@ parameter
+--------------------------+--------+----------------------------------------------------------------------------------------------------------+
| typeAheadMinLength | int | Minimum number of characters which have to typed to start the search. |
+--------------------------+--------+----------------------------------------------------------------------------------------------------------+
| fillStoreLdap | - | Activate `Fill STORE LDAP` with the first retrieved record |
| 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` |
+--------------------------+--------+----------------------------------------------------------------------------------------------------------+
* Example:
......@@ -1157,6 +1158,30 @@ E.g. if there are multiple different forms to work on the same table, all of the
The 'extraDeleteForm' parameter might be specified for a 'form' and/or for 'subrecords'
.. _form-mode-readonly:
Global Form mode 'readonly'
'''''''''''''''''''''''''''
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.
The mode can be statically defined in the *Form.parameter* field via::
mode=readonly
Or dynamically, e.g. via::
mode={{formModeGlobal:S:alnumx}}
Such variant might be called via SIP. The following shows the same *Form* in the `regular` mode and second in `readonly` mode::
10.sql = SELECT CONCAT('from&form=person&r=', p.id) as _Pagee, CONCAT('from&form=person&formModeGlobal=readonly&r=', p.id) as _Pagee FROM Person AS p
FormElements
------------
......
......@@ -28,7 +28,7 @@ Changes
* #3431, Parameter keyword 'typeAheadLdapKeyPrintf' changed to 'typeAheadLdapIdPrintf'.::
UPDATE FormElement SET parameter = REPLACE(parameter, 'typeAheadLdapKeyPrintf', 'typeAheadLdapIdPrintf')
UPDATE FormElement SET parameter = REPLACE(parameter, 'typeAheadLdapKeyPrintf', 'typeAheadLdapIdPrintf')
Features
^^^^^^^^
......@@ -37,8 +37,8 @@ Features
will direct to that page. Fix #3420 / Quicklink 'editform' on form: directs to the current T3 page which might be insufficient.
* Form 'subrecord' columns: the default width limit of 20 chars are disabled if 'nostrip' is specifed.
* #3431 / typeAheadSql: columnname 'key' is a reserverd SQL statement - replace by 'id'. Additional the parametername
'typeAheadLdapKeyPrintf' renamed to 'typeAheadLdapIdPrintf'. By using 'id' instead of 'key' the quoting of the columnname
is not necessary anoymore.
'typeAheadLdapKeyPrintf' renamed to 'typeAheadLdapIdPrintf'. By using 'id' instead of 'key' the quoting of the columnname
is not necessary anoymore.
......
......@@ -356,7 +356,6 @@ abstract class AbstractBuildForm {
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false,
$storeUseDefault = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$html = '';
$flagOutput = false;
// The following 'FormElement.parameter' will never be used during load (fe.type='upload'). FE_PARAMETER has been already expanded.
$skip = [FE_SQL_UPDATE, FE_SQL_INSERT, FE_SQL_DELETE, FE_SQL_AFTER, FE_SQL_BEFORE, FE_PARAMETER];
......@@ -386,6 +385,12 @@ abstract class AbstractBuildForm {
$debugStack = array();
// Copy global readonly mode.
if ($this->formSpec[F_MODE] == F_MODE_READONLY) {
$fe[FE_MODE] = FE_MODE_READONLY;
$fe[FE_MODE_SQL] = '';
}
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($fe), STORE_SYSTEM);
......
......@@ -164,7 +164,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
// Button: Save
if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec['showButton']) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec[F_SHOW_BUTTON]) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
$toolTip = 'Save';
if ($this->showDebugInfo) {
......@@ -175,14 +175,14 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
// Button: Close
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec['showButton'])) {
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec[F_SHOW_BUTTON])) {
$toolTip = 'Close';
$buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE);
}
// Button: Delete
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec['showButton'])) {
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec[F_SHOW_BUTTON])) {
$toolTip = 'Delete';
if ($this->showDebugInfo && $recordId > 0) {
......@@ -194,7 +194,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
// Button: New
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) {
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec[F_SHOW_BUTTON])) {
$toolTip = 'New';
$url = $this->deriveNewRecordUrlFromExistingSip($toolTip);
......
......@@ -559,6 +559,8 @@ const F_CLASS = 'class';
const F_CLASS_PILL = 'classPill';
const F_CLASS_BODY = 'classBody';
const F_SHOW_BUTTON = 'showButton';
const F_FE_DATA_PATTERN_ERROR = 'data-pattern-error';
const F_FE_DATA_REQUIRED_ERROR = 'data-required-error';
const F_FE_DATA_MATCH_ERROR = 'data-match-error';
......@@ -578,6 +580,9 @@ const F_TYPEAHEAD_LDAP_VALUE_PRINTF = 'typeAheadLdapValuePrintf';
const F_TYPEAHEAD_LDAP_ID_PRINTF = 'typeAheadLdapIdPrintf';
const F_TYPEAHEAD_LDAP_SEARCH = 'typeAheadLdapSearch';
const F_MODE = 'mode';
const F_MODE_READONLY = 'readonly';
// FORM_ELEMENT_STATI
const FE_MODE_SHOW = 'show';
const FE_MODE_READONLY = 'readonly';
......
......@@ -573,16 +573,22 @@ class QuickFormQuery {
/**
* Set form parameter which are expected to exist.
*
* @param array $config
* @param array $formSpec
* @return array
*/
private function initForm(array $config) {
Support::setIfNotSet($config, F_EXTRA_DELETE_FORM, '');
Support::setIfNotSet($config, F_SUBMIT_BUTTON_TEXT, '');
Support::setIfNotSet($config, F_BUTTON_ON_CHANGE_CLASS, '');
Support::setIfNotSet($config, F_LDAP_USE_BIND_CREDENTIALS, '');
private function initForm(array $formSpec) {
Support::setIfNotSet($formSpec, F_EXTRA_DELETE_FORM, '');
Support::setIfNotSet($formSpec, F_SUBMIT_BUTTON_TEXT, '');
Support::setIfNotSet($formSpec, F_BUTTON_ON_CHANGE_CLASS, '');
Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, '');
Support::setIfNotSet($formSpec, F_MODE, '');
if ($formSpec[F_MODE] == F_MODE_READONLY) {
$formSpec[F_SHOW_BUTTON] = FORM_BUTTON_CLOSE;
$formSpec[F_SUBMIT_BUTTON_TEXT] = '';
}
return $config;
return $formSpec;
}
/**
......
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