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

Fixed #7639. Update Manual.rst. Fake STORE_SIP so it can be used during...

Fixed #7639. Update Manual.rst. Fake STORE_SIP so it can be used during processing sql1. Fixed bug that the currently form loaded record is available via STORE_RECORD.
parent b6f342a8
Pipeline #2751 passed with stages
in 3 minutes and 47 seconds
...@@ -3791,17 +3791,23 @@ The following parameters can be used in the `parameter` field to customize/activ ...@@ -3791,17 +3791,23 @@ The following parameters can be used in the `parameter` field to customize/activ
* *orderColumn*: The dedicated order column in the specified dndTable (needs to match a column in the table definition). * *orderColumn*: The dedicated order column in the specified dndTable (needs to match a column in the table definition).
Default is `ord`. Default is `ord`.
If `dndTable` is an actual table with a column `orderColumn`, QFQ automatically applies drag-and-drop logic If `dndTable` is a table with a column `orderColumn`, QFQ automatically applies drag-and-drop logic
to the rendered subrecord. It does so by using the subrecord field *sql1*. The `sql1` query should to the rendered subrecord. It does so by using the subrecord field *sql1*. The `sql1` query should
therefore include both a column id (or _id) and ord (or _ord). include a column `id` (or `_id`) and a column `ord` (or `_ord`). E.g.::
FE.sql1 = {{!SELECT p.id AS _id, p.ord AS _ord, p.name FROM Person WHERE p.email!='' ORDER BY p.ord}}
Tips: Tips:
* If you want to deactivate a drag-and-drop that QFQ automatically renders, set the `orderColumn` to a non-existing column. * If you want to deactivate a drag-and-drop that QFQ automatically renders, set the `orderColumn` to a non-existing column.
E.g., `orderColumn = nonExistingColumn`. This will deactivate drag-and-drop. E.g., `orderColumn = nonExistingColumn`. This will deactivate drag-and-drop.
* In order to evaluate the `sql1` query dynamically during a drag-and-drop event, the fill store R (with the current form) * In order to evaluate the `sql1` query dynamically during a drag-and-drop event, the STORE_RECORD (with the current subrecord)
is loaded. Currently, SIP parameters and other variables are not supplied to be evaluated during a drag-and-drop event. is loaded.
This may be added later upon request. * The stores STORE_RECORD, STORE_SIP and STORE_SYSTEM are supported during a drag-and-drop event and can be used in FE.sql1 query.
* STORE_SIP: SIP values on form load
* STORE_RECORD: values of the current record loaded in the form.
* If the subrecord is rendered with drag-and-drop active, but the order is not affected upon reload, there is * If the subrecord is rendered with drag-and-drop active, but the order is not affected upon reload, there is
most likely a problem with evaluating the `sql1` query at runtime. most likely a problem with evaluating the `sql1` query at runtime.
......
...@@ -2818,6 +2818,7 @@ abstract class AbstractBuildForm { ...@@ -2818,6 +2818,7 @@ abstract class AbstractBuildForm {
$dataDndApi = DND_SUBRECORD_ID . '=' . $formElement[FE_ID]; $dataDndApi = DND_SUBRECORD_ID . '=' . $formElement[FE_ID];
$dataDndApi .= '&' . DND_SUBRECORD_FORM_ID . '=' . $this->store->getVar('id', STORE_RECORD); $dataDndApi .= '&' . DND_SUBRECORD_FORM_ID . '=' . $this->store->getVar('id', STORE_RECORD);
$dataDndApi .= '&' . DND_SUBRECORD_FORM_TABLE . '=' . $this->formSpec[F_TABLE_NAME];
$dataDndApi .= '&' . FE_ORDER_INTERVAL . '=' . $orderInterval; $dataDndApi .= '&' . FE_ORDER_INTERVAL . '=' . $orderInterval;
$dataDndApi .= '&' . FE_ORDER_COLUMN . '=' . $orderColumn; $dataDndApi .= '&' . FE_ORDER_COLUMN . '=' . $orderColumn;
$dataDndApi .= '&' . FE_DND_TABLE . '=' . $dndTable; $dataDndApi .= '&' . FE_DND_TABLE . '=' . $dndTable;
......
...@@ -1888,7 +1888,9 @@ const DND_COLUMN_ORD_NEW = 'ordNew'; ...@@ -1888,7 +1888,9 @@ const DND_COLUMN_ORD_NEW = 'ordNew';
const DND_DATA_DND_API = 'data-dnd-api'; const DND_DATA_DND_API = 'data-dnd-api';
const DND_SUBRECORD_ID = 'dnd-subrecord-id'; // Internal qualifier used to communicate with dnd api for subrecord dnd const DND_SUBRECORD_ID = 'dnd-subrecord-id'; // Internal qualifier used to communicate with dnd api for subrecord dnd
const DND_SUBRECORD_FORM_ID = 'dnd-subrecord-form-id'; const DND_SUBRECORD_FORM_ID = 'dnd-subrecord-form-id';
const DND_SUBRECORD_FORM_TABLE = 'dnd-subrecord-form-table';
const DND_ORD_HTML_ID_PREFIX = 'qfq-dnd-ord-id-'; const DND_ORD_HTML_ID_PREFIX = 'qfq-dnd-ord-id-';
const DND_FORM_SIP_VALUES = '_sipForm';
// Application Test: SELENIUM // Application Test: SELENIUM
const ATTRIBUTE_DATA_REFERENCE = 'data-reference'; const ATTRIBUTE_DATA_REFERENCE = 'data-reference';
......
...@@ -272,6 +272,9 @@ class Evaluate { ...@@ -272,6 +272,9 @@ class Evaluate {
private function inlineDataDndApi($arrToken, $dbIndex, &$foundInStore) { private function inlineDataDndApi($arrToken, $dbIndex, &$foundInStore) {
$token = OnString::trimQuote(trim(implode(' ', $arrToken))); $token = OnString::trimQuote(trim(implode(' ', $arrToken)));
# Include current SIP store, to fetch SIP parameter later.
$token .= '&' . DND_FORM_SIP_VALUES . '=' . $this->store::getVar(SIP_SIP, STORE_SIP);
if (empty($token)) { if (empty($token)) {
throw new \UserReportException('Missing form name for "data-dnd-api"', ERROR_MISSING_FORM); throw new \UserReportException('Missing form name for "data-dnd-api"', ERROR_MISSING_FORM);
} }
...@@ -358,7 +361,7 @@ class Evaluate { ...@@ -358,7 +361,7 @@ class Evaluate {
$type = OnString::stripFirstCharIf('_', $arrToken[$countToken - 1]); $type = OnString::stripFirstCharIf('_', $arrToken[$countToken - 1]);
array_pop($arrToken); // remove 'link' | 'data-dnd-api' | 'ablesorter-view-saver' array_pop($arrToken); // remove 'link' | 'data-dnd-api' | 'tablesorter-view-saver'
array_pop($arrToken); // remove 'as' array_pop($arrToken); // remove 'as'
switch (strtolower($type)) { switch (strtolower($type)) {
......
...@@ -1802,20 +1802,35 @@ class QuickFormQuery { ...@@ -1802,20 +1802,35 @@ class QuickFormQuery {
$json = ""; $json = "";
$dndSubrecordId = $this->store->getVar(DND_SUBRECORD_ID, STORE_SIP . STORE_CLIENT . STORE_ZERO); $dndSubrecordId = $this->store::getVar(DND_SUBRECORD_ID, STORE_SIP . STORE_CLIENT . STORE_ZERO);
if ($dndSubrecordId > 0) { if ($dndSubrecordId > 0) {
// Subrecord DragAndDrop // Subrecord DragAndDrop
$subrecord = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_BY_ID, ROW_REGULAR, [$dndSubrecordId]); $subrecord = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_BY_ID, ROW_REGULAR, [$dndSubrecordId]);
$recordId = $this->store->getVar(DND_SUBRECORD_FORM_ID, STORE_SIP . STORE_ZERO); $recordId = $this->store::getVar(DND_SUBRECORD_FORM_ID, STORE_SIP . STORE_ZERO);
$this->store->fillStoreWithRecord('Form', $recordId, $this->dbArray[$this->dbIndexQfq]);
$tableName = $this->store::getVar(DND_SUBRECORD_FORM_TABLE, STORE_SIP);
// $this->store->fillStoreWithRecord('form', $recordId, $this->dbArray[$this->dbIndexQfq]);
$this->store->fillStoreWithRecord($tableName, $recordId, $this->dbArray[$this->dbIndexQfq]);
$formSip = $this->store::getVar(DND_FORM_SIP_VALUES, STORE_SIP);
// Backup STORE_SIP
$save = $this->store::getStore(STORE_SIP);
// Fake STORE_SIP
$this->store::fillStoreSip($formSip);
// Fire query, which might use SIP Vars
$dndOrderSql = $this->evaluate->parse($subrecord[0][FE_SQL1]); $dndOrderSql = $this->evaluate->parse($subrecord[0][FE_SQL1]);
foreach ($dndOrderSql as $i => $row) {
foreach ($row as $key => $value) { // Restore STORE_SIP
if (substr($key, 0, 1) === '_') { $this->store::setStore($save, STORE_SIP, true);
$dndOrderSql[$i][substr($key, 1)] = $value;
} // Copy all '_...' columns to '...' (without the dash)
} // foreach ($dndOrderSql as $i => $row) {
} // foreach ($row as $key => $value) {
// if (substr($key, 0, 1) === '_') {
// $dndOrderSql[$i][substr($key, 1)] = $value;
// }
// }
// }
$dummyFormSpec = [ $dummyFormSpec = [
F_ORDER_INTERVAL => $this->store->getVar(FE_ORDER_INTERVAL, STORE_SIP . STORE_ZERO), F_ORDER_INTERVAL => $this->store->getVar(FE_ORDER_INTERVAL, STORE_SIP . STORE_ZERO),
......
...@@ -536,15 +536,21 @@ class Store { ...@@ -536,15 +536,21 @@ class Store {
/** /**
* Fills the STORE_SIP. Reads therefore specified SIP, decode the values and stores them in STORE_SIP. * Fills the STORE_SIP. Reads therefore specified SIP, decode the values and stores them in STORE_SIP.
* *
* @param bool|string $s
* @throws \CodeException * @throws \CodeException
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
private static function fillStoreSip() { public static function fillStoreSip($s = false) {
if (self::$sip === null) {
self::$sip = new Sip(self::$phpUnit); self::$sip = new Sip(self::$phpUnit);
}
if ($s === false) {
$s = self::getVar(CLIENT_SIP, STORE_CLIENT); $s = self::getVar(CLIENT_SIP, STORE_CLIENT);
}
if ($s !== false) { if ($s !== false) {
// if session is given, copy values to store // if session is given, copy values to store
$param = self::$sip->getVarsFromSip($s); $param = self::$sip->getVarsFromSip($s);
......
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