Commit 5c3c758b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Add error message in case no records have been found.

parent 4bb218c5
Pipeline #809 passed with stage
in 1 minute and 42 seconds
......@@ -310,7 +310,11 @@ const ERROR_HTML2PDF_MISSING_CONFIG = 2500;
const ERROR_HTML2PDF_WKHTML_NOT_EXECUTABLE = 2501;
const ERROR_HTML2PDF_WKHTML_FAILED = 2502;
// Thumbnail
const ERROR_THUMBNAIL_RENDER = 2600;
// Drag and Drop
const ERROR_DND_EMPTY_REORDER_SQL = 2700;
//
// Store Names: Identifier
//
......
......@@ -72,10 +72,13 @@ class DragAndDrop {
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function process() {
if (!is_array($this->formSpec[F_DRAG_AND_DROP_ORDER_SQL]) || count($this->formSpec[F_DRAG_AND_DROP_ORDER_SQL]) == 0) {
throw new UserFormException('Reorder SQL failed - expect at least one record, but got nothing. Check: Form.parameter.' . F_DRAG_AND_DROP_ORDER_SQL, ERROR_DND_EMPTY_REORDER_SQL);
}
$dragId = $this->store->getVar(DND_DRAG_ID, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
$setTo = $this->store->getVar(DND_SET_TO, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
$hoverId = $this->store->getVar(DND_HOVER_ID, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
......@@ -83,9 +86,9 @@ class DragAndDrop {
$orderInterval = empty($this->formSpec[F_ORDER_INTERVAL]) ? 1 : $this->formSpec[F_ORDER_INTERVAL];
$orderColumn = empty($this->formSpec[F_ORDER_COLUMN]) ? F_ORDER_COLUMN_NAME : $this->formSpec[F_ORDER_COLUMN];
if (!is_array($this->formSpec[F_DRAG_AND_DROP_ORDER_SQL])) {
return [];
}
// if (!is_array($this->formSpec[F_DRAG_AND_DROP_ORDER_SQL])) {
// return [];
// }
$data = $this->reorder($this->formSpec[F_DRAG_AND_DROP_ORDER_SQL], $dragId, $setTo, $hoverId, $orderColumn,
$orderInterval, $this->formSpec[F_TABLE_NAME]);
......@@ -106,13 +109,13 @@ class DragAndDrop {
* ...
* ]
*
* @param array $rows Array with id/ord in the old order.
* @param int $dragId Id of the element which has been drag'ed
* @param string $setTo DND_SET_TO_BEFORE|DND_SET_TO_AFTER Indicates if the drop zone is before or after the $hoverId
* @param int $hoverId Id of element where the drag'ed element has been dropped on.
* @param string $orderColumn Table column where to save the new calculated order.
* @param int $orderInterval Order increment.
* @param string $tableName Table name where to update the order records.
* @param array $rows Array with id/ord in the old order.
* @param int $dragId Id of the element which has been drag'ed
* @param string $setTo DND_SET_TO_BEFORE|DND_SET_TO_AFTER Indicates if the drop zone is before or after the $hoverId
* @param int $hoverId Id of element where the drag'ed element has been dropped on.
* @param string $orderColumn Table column where to save the new calculated order.
* @param int $orderInterval Order increment.
* @param string $tableName Table name where to update the order records.
* @return array Array with html-id references to update order values in the browser. Check PROTOCOL.md for 'element-update'.
*
* @throws CodeException
......@@ -150,7 +153,7 @@ class DragAndDrop {
break;
default:
throw new CodeException('Unkown setTo string', $setTo, ERROR_UNKNOWN_TOKEN);
throw new CodeException(json_encode([ERROR_MESSAGE_TO_USER => 'Unknown "setTo" string', ERROR_MESSAGE_SUPPORT => "Token found: " . $setTo]), ERROR_UNKNOWN_TOKEN);
}
} else {
$data = $this->setNewOrder($tableName, $orderColumn, $row[DND_COLUMN_ID], $row[DND_COLUMN_ORD], $ord, $data);
......
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