Skip to content

Commit

Permalink
feat(List/Matrix View): ✨ Setting: Filter implied siblings of differe…
Browse files Browse the repository at this point in the history
…nt types
  • Loading branch information
SkepticMystic committed Aug 15, 2021
1 parent 9197442 commit 5e528b7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
})
);

// TODO I don't think this setting works anymore. I removed it's functionality when adding multiple hierarchies
new Setting(MLViewDetails)
.setName("Show all field names or just relation types")
.setDesc(
Expand Down Expand Up @@ -361,6 +362,21 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
})
);

new Setting(MLViewDetails)
.setName("Filter Implied Siblings")
.setDesc(
"Implied siblings are: 1) notes with the same parent, or 2) notes that are real siblings. This setting only applies to type 1 implied siblings. If enabled, Breadcrumbs will filter type 1 implied siblings so that they not only share the same parent, but the parent relation has the exact same type. For example, the two real relations B --parent-> A, and A --parent-> A create an implied sibling between B and C (they have the same parent, A). The two real relations B --parent-> A, and A --up-> A create an implied sibling between B and C (they also have the same parent, A). But if this setting is turned on, the second implied sibling would not show, because the parent types are differnet (parent versus up)."
)
.addToggle((toggle) =>
toggle
.setValue(plugin.settings.filterImpliedSiblingsOfDifferentTypes)
.onChange(async (value) => {
plugin.settings.filterImpliedSiblingsOfDifferentTypes = value;
await plugin.saveSettings();
await plugin.getActiveMatrixView().draw();
})
);

new Setting(MLViewDetails)
.setName("Open View in Right or Left side")
.setDesc(
Expand Down
10 changes: 9 additions & 1 deletion src/MatrixView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,15 @@ export default class MatrixView extends ItemView {
const indexCurrNote = impliedSiblings.indexOf(currFile.basename);
impliedSiblings.splice(indexCurrNote, 1);

// Create thie implied sibling SquareProps
if (settings.filterImpliedSiblingsOfDifferentTypes) {
impliedSiblings = impliedSiblings.filter((iSibling) => {
const iSiblingType = currUpG.node(iSibling).fieldName;
const currNodeType = currUpG.node(currFile.basename).fieldName;
console.log({ iSiblingType, currNodeType });
return iSiblingType === currNodeType;
});
}
// Create the implied sibling SquareProps
impliedSiblings.forEach((impliedSibling) => {
iSameArr.push({
to: impliedSibling,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface BreadcrumbsSettings {
defaultView: boolean;
showNameOrType: boolean;
showRelationType: boolean;
filterImpliedSiblingsOfDifferentTypes: boolean;
rlLeaf: boolean;
showTrail: boolean;
trailOrTable: 1 | 2 | 3;
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = {
defaultView: true,
showNameOrType: true,
showRelationType: true,
filterImpliedSiblingsOfDifferentTypes: false,
rlLeaf: true,
showTrail: true,
trailOrTable: 3,
Expand Down
5 changes: 4 additions & 1 deletion src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ export function mergeGs(...graphs: Graph[]) {
const outG = new Graph();
graphs.forEach((graph) => {
graph.edges().forEach((edge) => {
outG.setEdge(edge);
const nodeLabel = graph.node(edge.v);
outG.setNode(edge.v, nodeLabel);
const edgeLabel = graph.edge(edge);
outG.setEdge(edge, edgeLabel);
});
});
return outG;
Expand Down

0 comments on commit 5e528b7

Please sign in to comment.