-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add sortNodes
and generic orderBy
#961
Conversation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Move the functions from the files app to this library to allow reusing them in other places, like for example the FilePicker or Viewer app. `orderBy` is a generic natural sorting function which allows to pass a collection, identifiers and associated order and sorts the collectiong using the browser native `Intl.Collator`. `sortNodes` is a specialized function based on `orderBy` to sort nodes (files and folders) based on sorting options. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Bundle ReportChanges will increase total bundle size by 5.72kB ⬆️
|
* They key to order the files by | ||
* @default FilesSortingMode.Name | ||
*/ | ||
sortingMode?: FilesSortingMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means we cannot sort by arbitrary values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we allow it? I just wanted to provide a clean interface, but we can of course also accept other values here if you like :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I confused myself.
I was thiking about custom columns, but I apparently had planned this already.
You have to provide a sort function if you want your custom column to be sortable, so this piece of code is not relevant, you're right!
https://github.com/nextcloud/server/blob/a8f4b25ae834778e120ea011a3c98aa77ef90c51/apps/files/src/views/FilesList.vue#L311-L315
https://github.com/nextcloud/server/blob/97cd038cf20c5015d9dfecd0e9283367391358d2/apps/files/src/components/FilesListTableHeader.vue#L61-L69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you ignore types you can even pass every valid property of the Node class^^
SortingService
to fix sorting of files nextcloud/server#45419 (review)Move the functions from the files app to this library to allow reusing them in other places, like for example the FilePicker or Viewer app.
orderBy
is a generic natural sorting function which allows to pass a collection, identifiers and associated order and sorts the collection using the browser nativeIntl.Collator
.sortNodes
is a specialized function based onorderBy
to sort nodes (files and folders) based on sorting options.