Commit 4af84c2d authored by Henning Leutz's avatar Henning Leutz 🥋

fix: #984 - sort / order fixed

parent 8f7534a6
......@@ -9,7 +9,7 @@
*/
QUI::$Ajax->registerFunction(
'ajax_site_children_sort',
function ($project, $parent, $ids, $from) {
function ($project, $parent, $ids, $from, $sortType) {
$Project = QUI::getProjectManager()->decode($project);
$ids = \json_decode($ids, true);
$from = (int)$from;
......@@ -18,6 +18,11 @@ QUI::$Ajax->registerFunction(
$Parent = $Project->get($parent);
$Parent->checkPermission('quiqqer.projects.site.edit');
if (!empty($sortType)) {
$Parent->setAttribute('order_type', $sortType);
$Parent->save();
}
$childrenIds = $Parent->getChildrenIds();
foreach ($ids as $id) {
......@@ -46,5 +51,5 @@ QUI::$Ajax->registerFunction(
)
);
},
['project', 'parent', 'ids', 'from']
['project', 'parent', 'ids', 'from', 'sortType']
);
......@@ -23,7 +23,7 @@ QUI::$Ajax->registerFunction(
$attributes = \explode(',', $params['attributes']);
}
// forerst kein limit
// vorerst kein limit
if (isset($params['limit']) && $params['limit']) {
$children = $Site->getChildren([
'limit' => $params['limit']
......
......@@ -279,11 +279,12 @@ define('controls/projects/project/site/SiteChildrenSort', [
return new Promise(function (resolve, reject) {
Ajax.post('ajax_site_children_sort', resolve, {
project: Project.encode(),
parent : self.$Site.getId(),
ids : JSON.encode(ids),
start : (page - 1) * perPage,
onError: reject
project : Project.encode(),
parent : self.$Site.getId(),
ids : JSON.encode(ids),
start : (page - 1) * perPage,
sortType: 'manuell',
onError : reject
});
}).then(function () {
return self.displayChildren();
......
......@@ -566,6 +566,7 @@ class Edit extends Site
$order_type = 'manuell';
switch ($this->getAttribute('order_type')) {
case 'manual':
case 'manuell':
case 'name ASC':
case 'name DESC':
......@@ -840,6 +841,7 @@ class Edit extends Site
$params['order'] = $this->getAttribute('order_type');
break;
case 'manual':
case 'manuell':
default:
$params['order'] = 'order_field';
......@@ -1121,6 +1123,7 @@ class Edit extends Site
// get new order_field if manually sorting
if ($Parent->getAttribute('order_type') === ''
|| $Parent->getAttribute('order_type') === 'manuell'
|| $Parent->getAttribute('order_type') === 'manual'
|| !$Parent->getAttribute('order_type')) {
$LastChild = $Parent->lastChild(['active' => '0&1']);
......
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