diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 499bb678136a89c42fd73e77e806e1fcc1c8b149..cfef9fbf82d6052d610bec8893dd5e1623aff73d 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -62,7 +62,7 @@ Preparation for Ubuntu 14.04:: sudo php5enmod mysqlnd sudo service apache2 restart -Preparation steps for Ubuntu 16.04:: +Preparation for Ubuntu 16.04:: sudo apt install php7.0-intl sudo apt install pdftk libxrender1 file # for file upload, PDF and 'HTML to PDF' (wkhtmltopdf) @@ -1340,7 +1340,7 @@ Form during the installation of new QFQ versions. * Every form consist of a) a *Form* record and b) multiple *FormElement* records. * A form is assigned to a *table*. Such a table is called the *primary table* for this form. -* There are three types of forms which can roughly categorized into: +* Forms can roughly categorized into: * *Simple* form: the form acts on one record, stored in one table. @@ -1355,6 +1355,8 @@ Form * The *FormElements* are defined as a regular *simple* / or *advanced* form, plus a SQL Query, which selects and iterates over all records. Those records will be loaded at the same time. + * *Delete* form: any form can be used as a form to `delete-record`_. + * Form mode: The parameter 'r' (given via URL or via SIP) decide if the form is in mode: * `New`: @@ -1491,7 +1493,7 @@ showButton Display or hide the button `new`, `delete`, `close`, `save`. * *new*: Creates a new record. If the form needs any special parameter via SIP or Client (=browser), hide this 'new' button - the necessary parameter are not provided. -* *delete*: This either deletes the current record only, or (if defined via action *FormElement* 'before Delete' ) any specified subrecords. +* *delete*: This either deletes the current record only, or (if defined via action *FormElement* 'beforeDelete' ) any specified subrecords. * *close*: Close the current form. If there are changes, a popup opens and ask to save / close / cancel. The last page from the history will be shown. * *save*: Save the form. @@ -3021,6 +3023,37 @@ form with the following parameter * sql1: `{{!SELECT i.id AS id, {{basketId:P}} AS basketId FROM Item AS i WHERE i.basketId={{id:P}} }}` * Parameter: `recordDestinationTable=Item` +.. _delete-record: + +Delete Record +------------- + +Deleting record(s) via QFQ might be solved by either: + +* using the `delete` button on a form on the top right corner. +* by letting `report`_ creating a special link (see below). The link contains the record id and: + + * a form name, or + * a table name. + +Deleting a record just by specifying a table name, will only delete the defined record (no slave records). + +* By using a delete button via `report` or in a `subrecord` row, a ajax request is send. +* By using a delete button on the top right corner of the form, the form will be closed after deleting the record. + +Example for report:: + + SELECT p.name, CONCAT('form=person&r=', p.id) AS _Paged FROM Person AS p + SELECT p.name, CONCAT('table=Person&r=', p.id) AS _Paged FROM Person AS p + +To automatically delete slave records, use a form and create `beforeDelete` FormElement(s) on the form: + + * class: action + * type: beforeDelete + * parameter: sqlAfter={{DELETE FROM <slaveTable> WHERE <slaveTable>.<masteId>={{id:R}} }} + +You might also check the form 'form' how the slave records 'FormElement' will be deleted. + Best practice ------------- diff --git a/extension/qfq/sql/formEditor.sql b/extension/qfq/sql/formEditor.sql index 701de67ad3f50d4cb9a9e05e6296c6b98b77abd6..4ad5af5685b6ca5153bec9bc117e1d4e29f4648b 100644 --- a/extension/qfq/sql/formEditor.sql +++ b/extension/qfq/sql/formEditor.sql @@ -157,6 +157,8 @@ VALUES INSERT INTO FormElement (formId, name, label, mode, type, checkType, class, ord, size, maxLength, note, clientJs, value, sql1, parameter, feIdContainer, subrecordOption, modeSql, placeholder, encode, dynamicUpdate) VALUES + (1, 'Delete FE', '', 'show', 'beforeDelete', 'all', 'action', 100, 0, 0, '', '', '', '', + 'sqlAfter={{DELETE FROM FormElement WHERE formId={{id:R}} }}', 0, '', '', '', 'none', 'no'), (1, 'name', 'Name', 'required', 'text', 'alnumx', 'native', 120, 0, 0, '', '', '', '', 'autofocus', 1, '', '', '', 'specialchar', 'no'), (1, 'title', 'Title', 'show', 'text', 'all', 'native', 130, 0, 0, '', '', '', '', '', 1, '', '', '', 'none', 'no'),