Implement sorting by URL

fixes #1183

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2022-12-13 16:36:23 +01:00
parent 4f15f05ac8
commit ecd123c393
3 changed files with 6 additions and 1 deletions

View File

@ -92,7 +92,7 @@ class SettingsController extends ApiController {
* @NoAdminRequired
*/
public function setSorting($sorting = ""): JSONResponse {
$legalArguments = ['title', 'added', 'clickcount', 'lastmodified', 'index'];
$legalArguments = ['title', 'added', 'clickcount', 'lastmodified', 'index', 'url'];
if (!in_array($sorting, $legalArguments)) {
return new JSONResponse(['status' => 'error'], Http::STATUS_BAD_REQUEST);
}

View File

@ -355,6 +355,8 @@ class BookmarkMapper extends QBMapper {
} elseif ($sqlSortColumn === 'index') {
$qb->addOrderBy('tree.idx', 'ASC');
$qb->addGroupBy('tree.idx');
} elseif ($sqlSortColumn === 'url') {
$qb->addOrderBy('b.url', 'ASC');
} else {
$qb->addOrderBy('b.'.$sqlSortColumn, 'DESC');
}

View File

@ -125,6 +125,7 @@ import SortAlphabeticalAscendingIcon from 'vue-material-design-icons/SortAlphabe
import SortBoolAscendingIcon from 'vue-material-design-icons/SortBoolAscending.vue'
import SortClockAscendingOutlineIcon from 'vue-material-design-icons/SortClockAscendingOutline.vue'
import SortCalendarAscendingIcon from 'vue-material-design-icons/SortCalendarAscending.vue'
import SortNumericAscendingIcon from 'vue-material-design-icons/SortNumericAscending.vue'
import SortAscendingIcon from 'vue-material-design-icons/SortAscending.vue'
import ShareVariantIcon from 'vue-material-design-icons/ShareVariant.vue'
import TagIcon from 'vue-material-design-icons/Tag.vue'
@ -148,6 +149,7 @@ export default {
SortAlphabeticalAscendingIcon,
SortClockAscendingOutlineIcon,
SortBoolAscendingIcon,
SortNumericAscendingIcon,
FolderIcon,
ArrowLeftIcon,
PlusIcon,
@ -170,6 +172,7 @@ export default {
title: { icon: 'SortAlphabeticalAscendingIcon', description: this.t('bookmarks', 'Sort by title') },
clickcount: { icon: 'SortBoolAscendingIcon', description: this.t('bookmarks', 'Sort by click count') },
index: { icon: 'SortAscendingIcon', description: this.t('bookmarks', 'Sort by manual order') },
url: { icon: 'SortNumericAscendingIcon', description: this.t('bookmarks', 'Sort by URL') },
},
}
},