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

Fixes #10505 Drag'n'Drop broken on Multi DB Instance - first fix, further checks necessary

parent b1a46b51
Pipeline #5186 passed with stages
in 3 minutes and 47 seconds
......@@ -2261,6 +2261,7 @@ abstract class AbstractBuildForm {
$dataDndApi .= '&' . FE_ORDER_INTERVAL . '=' . $orderInterval;
$dataDndApi .= '&' . FE_ORDER_COLUMN . '=' . $orderColumn;
$dataDndApi .= '&' . FE_DND_TABLE . '=' . $dndTable;
$dataDndApi .= '&' . DND_DB_INDEX . '=' . $this->formSpec[F_DB_INDEX];
$dndAttributes = Support::doAttribute('class', 'qfq-dnd-sort');
$dndAttributes .= $this->evaluate->parse("{{ '$dataDndApi' AS _data-dnd-api }}") . ' ';
......
......@@ -1986,6 +1986,7 @@ 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_FORM_SIP_VALUES = '_sipForm';
const DND_DB_INDEX = 'dnd-db-index';
// Application Test: SELENIUM
const ATTRIBUTE_DATA_REFERENCE = 'data-reference';
......
......@@ -8,10 +8,9 @@
namespace IMATHUZH\Qfq\Core\Form;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Evaluate;
use IMATHUZH\Qfq\Core\Store\Store;
/**
......@@ -54,7 +53,7 @@ class DragAndDrop {
#TODO: rewrite $phpUnit to: "if (!defined('PHPUNIT_QFQ')) {...}"
$this->formSpec = $formSpec;
$dbIndex = DB_INDEX_DEFAULT; //Hier muss noch die aktuelle DB ermittelt werden (kann im Form angegeben sein) - Gerade im Formular FORM Editor genau testen!
$dbIndex = $formSpec[F_DB_INDEX]; //Hier muss noch die aktuelle DB ermittelt werden (kann im Form angegeben sein) - Gerade im Formular FORM Editor genau testen!
$this->db = new Database($dbIndex);
$this->store = Store::getInstance('', $phpUnit);
......
......@@ -1889,8 +1889,12 @@ class QuickFormQuery {
$dndSubrecordId = $this->store::getVar(DND_SUBRECORD_ID, STORE_SIP . STORE_CLIENT . STORE_ZERO);
if ($dndSubrecordId > 0) {
// Subrecord DragAndDrop
$subrecord = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_BY_ID, ROW_REGULAR, [$dndSubrecordId]);
// Save dbIndex
$dbIndex = $this->store::getVar(DND_DB_INDEX, STORE_SIP . STORE_ZERO);
// Get FormElement of current 'Subrecord' DragAndDrop
$feSubrecord = $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);
$tableName = $this->store::getVar(DND_SUBRECORD_FORM_TABLE, STORE_SIP);
......@@ -1902,8 +1906,19 @@ class QuickFormQuery {
$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]);
$sql = $feSubrecord[0][FE_SQL1];
$sqlSelect = str_replace(' ', '', substr($sql, 0, 9));
$sqlRest = substr($sql, 9);
// In case there is already a dbIndex given: change nothing '{{[123]!SELECT'. Else set the one defined by the SIP
if ($sqlSelect[2] != '[') {
$sqlSelect = str_replace('{{', '{{[' . $dbIndex . ']', $sqlSelect);
$sql = $sqlSelect . $sqlRest;
}
$dndOrderSql = $this->evaluate->parse($sql);
// Restore STORE_SIP
$this->store::setStore($save, STORE_SIP, true);
......@@ -1921,6 +1936,7 @@ class QuickFormQuery {
F_ORDER_INTERVAL => $this->store->getVar(FE_ORDER_INTERVAL, STORE_SIP . STORE_ZERO),
F_ORDER_COLUMN => $this->store->getVar(FE_ORDER_COLUMN, STORE_SIP . STORE_ZERO),
F_DRAG_AND_DROP_ORDER_SQL => $dndOrderSql,
F_DB_INDEX => $dbIndex,
F_TABLE_NAME => $this->store->getVar(FE_DND_TABLE, STORE_SIP . STORE_ZERO)
];
......
......@@ -264,6 +264,7 @@ CREATE TABLE IF NOT EXISTS `Split`
AUTO_INCREMENT = 0
DEFAULT CHARSET = utf8;
# Used to save tablesorter.js column selection settings. Free to use for other settings as well.
CREATE TABLE IF NOT EXISTS `Setting`
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
......
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