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

#4918: remove default 'form=' parameter - has now to be specified in the qfq record.

parent 9dcff2c7
...@@ -6223,14 +6223,16 @@ Drag and drop ...@@ -6223,14 +6223,16 @@ Drag and drop
------------- -------------
Sort/order elements Sort/order elements
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Manually sorting and ordering of elements via HTML5 drag and drop is supported via QFQ JS/API/DB. Any sortable element Manually sorting and ordering of elements via `HTML5 drag and drop` is supported via QFQ. Any sortable element
should be represented by a database record with an order column. should be represented by a database record with an order column. If the elements are unordered, they will be ordered after
the first manual move of an element.
* Display: the records will be displayed via QFQ/report. Functionality is divided into:
* Update: updates of the order column are managed by a specific 'drag and drop' definition Form.
* Display list: the records will be displayed via QFQ/report.
* Update database: updates of the order column are managed by a specific 'drag and drop' definition Form.
Part 1: Display list Part 1: Display list
'''''''''''''''''''' ''''''''''''''''''''
...@@ -6239,7 +6241,7 @@ Display the list of elements via a regular QFQ content record. All 'drag and dro ...@@ -6239,7 +6241,7 @@ Display the list of elements via a regular QFQ content record. All 'drag and dro
element: element:
* With `class="qfq-dnd-sort"`. * With `class="qfq-dnd-sort"`.
* With an automatically SIP protected form name: `{{'<form name>' AS _data-dnd-api}}` * With an automatically SIP protected form name: `{{'form=<form name>' AS _data-dnd-api}}`
* Only direct children of such element can be dragged. * Only direct children of such element can be dragged.
* Every children needs a unique identifier `data-dnd-id="<unique>"`. Typically this is the corresponding record id. * Every children needs a unique identifier `data-dnd-id="<unique>"`. Typically this is the corresponding record id.
* The record needs a dedicated order column, which will be updated through API calls in time. * The record needs a dedicated order column, which will be updated through API calls in time.
...@@ -6266,7 +6268,7 @@ A typical QFQ report which generates those HTML: :: ...@@ -6266,7 +6268,7 @@ A typical QFQ report which generates those HTML: ::
FROM Note AS n FROM Note AS n
ORDER BY n.ord ORDER BY n.ord
head = <div class="qfq-dnd-sort" {{'<form name>' AS _data-dnd-api}}> head = <div class="qfq-dnd-sort" {{'form=dndSortNote&grId=28' AS _data-dnd-api}}>
tail = </div> tail = </div>
} }
...@@ -6278,19 +6280,30 @@ A dedicated `Form`, without any `FormElements`, is needed to define the database ...@@ -6278,19 +6280,30 @@ A dedicated `Form`, without any `FormElements`, is needed to define the database
Fields: Fields:
* Name: <custom formname> * Name: <custom form name> - used in Part 1 in the `_data-dnd-api` variable.
* Table: <table with the element records> * Table: <table with the element records> - used to the update the records specified by `dragAndDropOrderSql`.
* Parameter: * Parameter:
+-------------------------------------+--------------------------------------------------------------------------------+
| Attribute | Description |
+=====================================+================================================================================+ +=====================================+================================================================================+
| orderInterval = <number> | Optional. By default '10'. Might be any number > 0. | | orderInterval = <number> | Optional. By default '10'. Might be any number > 0. |
+-------------------------------------+--------------------------------------------------------------------------------+ +-------------------------------------+--------------------------------------------------------------------------------+
| orderColumn = <column name> | Optional. By default 'ord'. | | orderColumn = <column name> | Optional. By default 'ord'. |
+-------------------------------------+--------------------------------------------------------------------------------+ +-------------------------------------+--------------------------------------------------------------------------------+
| dragAndDropOrderSql = | Query which selects the same records as the report in the | | dragAndDropOrderSql = | Query to selects the *same* records as the report in the |
| {{!SELECT n.id, n.ord FROM Note AS n ORDER BY n.ord}} | same order! Inconsistencies results in sort differences | | {{!SELECT n.id AS id, n.ord AS ord FROM Note AS n | same *order!* Inconsistencies results in sort differences. |
+---------------------------------------------------------+------------------------------------------------------------+ | ORDER BY n.ord}} | The columns `id` and `ord` are *mandatory.* |
+-------------------------------------------------------+--------------------------------------------------------------+
The form related to the example of part 1: ::
Form.name: dndSortNote
Form.table: Note
Form.parameter: orderInterval = 1
Form.parameter: orderColumn = ord
Form.parameter: dragAndDropOrderSql = {{!SELECT n.id AS id, n.ord AS ord FROM Note AS n WHERE n.grId={{grId:S0}} ORDER BY n.ord}}
Report Examples Report Examples
--------------- ---------------
......
...@@ -241,7 +241,7 @@ class Evaluate { ...@@ -241,7 +241,7 @@ class Evaluate {
$foundInStore = TOKEN_FOUND_AS_COLUMN; $foundInStore = TOKEN_FOUND_AS_COLUMN;
$s = $this->link->renderLink('U:form=' . $token . '|s|r:8'); $s = $this->link->renderLink('U:' . $token . '|s|r:8');
// Flag to add DND JS code later on. // Flag to add DND JS code later on.
$this->store->setVar(SYSTEM_DRAG_AND_DROP_JS, 'true', STORE_SYSTEM); $this->store->setVar(SYSTEM_DRAG_AND_DROP_JS, 'true', STORE_SYSTEM);
......
...@@ -1396,7 +1396,7 @@ EOF; ...@@ -1396,7 +1396,7 @@ EOF;
<script type = "text/javascript" > <script type = "text/javascript" >
var dragi = new QfqNS . DragAndDrop($('.qfq-dnd-sort')); var dragi = new QfqNS . DragAndDrop($('.qfq-dnd-sort'));
dragi . makeSortable(); dragi . makeSortable();
</script > </script>
EOF; EOF;
return $code; return $code;
......
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