-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Desktop: Sort Order Buttons and Per-Notebook Sort Order #5437
Merged
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e644195
Initial commit for Sort order buttons, Per-field reversal and Per-not…
ken1kob bf100e3
fixes for lint
ken1kob 91de06d
fix typo.
ken1kob c723ebe
Notebook -> Folder
ken1kob 4cdba95
remove string constants and internal wrapping functions
ken1kob e9dcc3b
add mapStateToProps and connect to avoid using Setting.value().
ken1kob 5d0b0e3
dependency to 'app' is removed from perFolderSortOrder.ts
ken1kob 36e00f8
Per-Notebook Sort Order is refactored.
ken1kob e75b50c
Make sort-order patch auto-mergeable to 2.5
ken1kob 50342cb
Sort order buttons adjustment for 2.5 and some refactoring
ken1kob 6a4d64c
Fixed button size
laurent22 fd2d5f9
Changes: folder to notebook in code, desc. and a tooltip
ken1kob 05e7846
unit tests for notesSortOrderUtils and PerFolderSortOrderService
ken1kob b3cfbc8
Merge branch 'dev' into sort-order_v2.4.5
ken1kob 057460e
Merge branch 'dev' into sort-order_v2.4.5
ken1kob 9bef92d
Merge remote-tracking branch 'remotes/origin/sort-order_v2.4.5' into …
ken1kob 8d75ae2
changes the label of togglePerFolderSortOrder command
ken1kob 31cf9f2
fix for lint
ken1kob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/app-desktop/gui/MainScreen/commands/toggleNotesSortOrderField.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||
import { setNotesSortOrder } from '../../../services/sortOrder/notesSortOrderUtils'; | ||
import { _ } from '@joplin/lib/locale'; | ||
|
||
export const declaration: CommandDeclaration = { | ||
name: 'toggleNotesSortOrderField', | ||
label: () => _('Toggle sort order field'), | ||
parentLabel: () => _('Notes'), | ||
}; | ||
|
||
export const runtime = (): CommandRuntime => { | ||
return { | ||
execute: async (_context: CommandContext, field?: string | Array<any>, reverse?: boolean) => { | ||
// field: Sort order's field. undefined means switching a field. | ||
// reverse: whether the sort order is reversed or not. undefined means toggling. | ||
// | ||
// To support CommandService.scheduleExecute(), field accepts an size-two Array, | ||
// which means [field, reverse]. | ||
if (typeof field !== 'object') { | ||
setNotesSortOrder(field, reverse); | ||
} else { | ||
setNotesSortOrder(field[0], field[1]); | ||
} | ||
}, | ||
}; | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/app-desktop/gui/MainScreen/commands/toggleNotesSortOrderReverse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||
import Setting from '@joplin/lib/models/Setting'; | ||
import { _ } from '@joplin/lib/locale'; | ||
import { setNotesSortOrder } from '../../../services/sortOrder/notesSortOrderUtils'; | ||
|
||
export const declaration: CommandDeclaration = { | ||
name: 'toggleNotesSortOrderReverse', | ||
label: () => _('Reverse sort order'), | ||
parentLabel: () => _('Notes'), | ||
}; | ||
|
||
export const runtime = (): CommandRuntime => { | ||
return { | ||
execute: async (_context: CommandContext) => { | ||
const reverse = Setting.value('notes.sortOrder.reverse'); | ||
setNotesSortOrder(undefined, !reverse); | ||
}, | ||
}; | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/app-desktop/gui/MainScreen/commands/togglePerFolderSortOrder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||
import { _ } from '@joplin/lib/locale'; | ||
import PerFolderSortOrderService from '../../../services/sortOrder/PerFolderSortOrderService'; | ||
|
||
export const declaration: CommandDeclaration = { | ||
name: 'togglePerFolderSortOrder', | ||
label: () => _('Toggle per-folder sort order'), | ||
}; | ||
|
||
export const runtime = (): CommandRuntime => { | ||
return { | ||
enabledCondition: 'oneFolderSelected', | ||
|
||
execute: async (_context: CommandContext, folderId?: string, own?: boolean) => { | ||
PerFolderSortOrderService.set(folderId, own); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"per-notebook".
But also, when the per-notebook option is not enabled on the notebook, this is actually like a global setting that applies not, per-notebook, but to all notebooks, is that correct?
I don't think we can convey all that info in this tooltip, so simply "Toggle sort order" would be sufficient (it's implied it's for the notebook).
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.
When
notes.perFolderSortOrderEnabled
is false, this command has no effect, and it is as expected.Since this feature is not very common, I'm afraid that too brevity introduces misunderstanding such as 'toggle sort order field (title/update time/create time/custom)'. I agree that "Toggle per-notebook sort order" is too long. How about "Toggle own sort order"?