Commit 6412aa1e authored by Marc Egger's avatar Marc Egger
Browse files

Fix: [FAF] Drag and drop: only export form file once rather than for every formElement

parent 82166203
Pipeline #4247 failed with stages
in 5 minutes and 47 seconds
......@@ -125,6 +125,10 @@ class DragAndDrop {
$nameId = false;
$nameOrd = false;
// Import Form from file if loaded record is Form/FormElement (If form file was changed, throw exception)
// Note: This is here since this code is called outside QuickFormQuery->doForm
$formFileName = FormAsFile::importFormRecordId($dragId, $tableName, $this->db);
// Reorder. Get index for 'drag' and 'hover'
foreach ($rows as $key => $row) {
......@@ -164,6 +168,11 @@ class DragAndDrop {
$ord += $orderInterval;
}
// Export Form file
if ($formFileName !== null) {
FormAsFile::exportForm($formFileName, $this->db);
}
return $data;
}
......@@ -187,6 +196,12 @@ class DragAndDrop {
}
/**
* Helper function to update order column of single element.
*
* WARNING: This does not update Form file if table is FormElement!
*
* Form file is updated in DragAndDrop->reorder()
*
* @param string $tableName
* @param string $orderColumn
* @param int $id
......@@ -204,17 +219,8 @@ class DragAndDrop {
return $data;
}
// Import Form from file if loaded record is Form/FormElement (If form file was changed, throw exception)
// Note: This is here since this code is called outside QuickFormQuery->doForm
$formFileName = FormAsFile::importFormRecordId($id, $tableName, $this->db);
$this->db->sql("UPDATE `$tableName` SET `$orderColumn`=? WHERE `id`=?", ROW_REGULAR, [$ordNew, $id]);
// Export Form file
if ($formFileName !== null) {
FormAsFile::exportForm($formFileName, $this->db);
}
// Converting to string is necessary: JSON detects int else.
$data[API_ELEMENT_UPDATE][DND_ORD_HTML_ID_PREFIX . $id][API_ELEMENT_CONTENT] = (string)$ordNew;
......
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