Skip to content

Commit

Permalink
feat(List/Matrix View): ✨ Option to sort by note name, but show it's …
Browse files Browse the repository at this point in the history
…alias. Default is to sort by alias if one is found (fix #255)
  • Loading branch information
SkepticMystic committed Jan 10, 2022
1 parent 0904bee commit bb25b48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,21 @@ export class BCSettingTab extends PluginSettingTab {
})
);

new Setting(MLViewDetails)
.setName("Sort by note name, but show alias")
.setDesc(
"When this is turned off, notes will first be sorted by their alias, and then by their name if no alias is found. Turn this on to sort by note name always, but still show the alias in the results."
)
.addToggle((toggle) =>
toggle
.setValue(settings.sortByNameShowAlias)
.onChange(async (value) => {
settings.sortByNameShowAlias = value;
await plugin.saveSettings();
await plugin.getActiveTYPEView(MATRIX_VIEW).draw();
})
);

new Setting(MLViewDetails)
.setName("Make Current Note an Implied Sibling")
.setDesc(
Expand Down
4 changes: 3 additions & 1 deletion src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class MatrixView extends ItemView {
enableAlphaSort,
treatCurrNodeAsImpliedSibling,
squareDirectionsOrder,
sortByNameShowAlias,
} = settings;
if (!mainG) return [];

Expand Down Expand Up @@ -208,7 +209,8 @@ export default class MatrixView extends ItemView {
if (enableAlphaSort) {
squares.forEach((sq) =>
sq.sort((a, b) =>
(a.alt ?? a.to) < (b.alt ?? b.to)
(sortByNameShowAlias ? a.to : a.alt ?? a.to) <
(sortByNameShowAlias ? b.to : b.alt ?? b.to)
? alphaSortAsc
? -1
: 1
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export const DEFAULT_SETTINGS: BCSettings = {
showTrail: true,
showGrid: true,
showPrevNext: true,
sortByNameShowAlias: false,
squareDirectionsOrder: [0, 1, 2, 3, 4],
limitTrailCheckboxes: [],
limitJumpToFirstFields: [],
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface BCSettings {
showNameOrType: boolean;
showRelationType: boolean;
showWriteAllBCsCmd: boolean;
sortByNameShowAlias: boolean;
regexNoteField: string;
rlLeaf: boolean;
showBCs: boolean;
Expand Down

0 comments on commit bb25b48

Please sign in to comment.