Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit de92b33

Browse files
committed
outgoing & incoming
1 parent efa155b commit de92b33

File tree

5 files changed

+51
-23
lines changed

5 files changed

+51
-23
lines changed

src/helpers/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ export const StyleVariables = Object.freeze({
178178
export const SourceDataTypes = Object.freeze({
179179
CURRENT_FOLDER: 'current_folder',
180180
TAG: 'tag',
181+
OUTGOING_LINK: 'outgoing_link',
182+
INCOMING_LINK: 'incoming_link',
181183
});
182184

183185
export const WidthVariables = Object.freeze({

src/helpers/VaultManagement.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export function sourceDataviewPages(folderPath: string, dbYaml: DatabaseYaml): D
8989
switch (dbYaml.config.source_data) {
9090
case SourceDataTypes.TAG:
9191
return DataviewService.getDataviewAPI().pages(`#${dbYaml.config.source_form_result}`);
92+
case SourceDataTypes.INCOMING_LINK:
93+
return DataviewService.getDataviewAPI().pages(`[[${dbYaml.config.source_form_result}]]`);
94+
case SourceDataTypes.OUTGOING_LINK:
95+
return DataviewService.getDataviewAPI().pages(`outgoing([[${dbYaml.config.source_form_result}]])`);
9296
default:
9397
return DataviewService.getDataviewAPI().pages(`"${folderPath}"`);
9498
}

src/parsers/handlers/unmarshall/UnmarshallConfigHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export class UnmarshallConfigHandler extends AbstractDiskHandler {
99
const { config } = handlerResponse.yaml;
1010
// Lvl1: config
1111
this.localDisk.push(`${this.handlerName}:`);
12-
console.log(`${this.handlerName}:`);
1312
Object.entries(config).forEach(([key, value]) => {
1413
if (typeof value === 'object') {
1514
this.localDisk.push(`${YAML_INDENT.repeat(1)}${key}:`);

src/settings/handlers/source/SourceDropDownHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class SourceDropDownHandler extends AbstractSettingsHandler {
2121
{
2222
current_folder: SourceDataTypes.CURRENT_FOLDER,
2323
tag: SourceDataTypes.TAG,
24+
outgoing_link: SourceDataTypes.OUTGOING_LINK,
25+
incoming_link: SourceDataTypes.INCOMING_LINK,
2426
},
2527
source_dropdown_promise
2628
);
Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1+
import { DatabaseView } from "DatabaseView";
12
import { SourceDataTypes } from "helpers/Constants";
2-
import { getAllTags } from "obsidian";
3-
import { DataviewService } from "services/DataviewService";
4-
import { LOGGER } from "services/Logger";
53
import { AbstractSettingsHandler, SettingHandlerResponse } from "settings/handlers/AbstractSettingHandler";
64
import { add_dropdown } from "settings/SettingsComponents";
75

@@ -11,30 +9,53 @@ export class SourceFormHandler extends AbstractSettingsHandler {
119
const { containerEl, view } = settingHandlerResponse;
1210
switch (view.diskConfig.yaml.config.source_data) {
1311
case SourceDataTypes.TAG:
14-
const tagArray: Record<string, number> = (app.metadataCache as unknown as any).getTags();
15-
if (tagArray) {
16-
const tagRecords: Record<string, string> = {};
17-
Object.keys(tagArray).forEach((tag) => {
18-
tagRecords[tag] = tag;
19-
});
20-
const source_form_promise = async (value: string): Promise<void> => {
21-
// update settings
22-
view.diskConfig.updateConfig('source_form_result', value.slice(1));
23-
};
12+
tagHandler(view, containerEl);
13+
break;
14+
case SourceDataTypes.OUTGOING_LINK:
15+
case SourceDataTypes.INCOMING_LINK:
16+
const filePaths: Record<string, string> = {}
17+
app.vault.getMarkdownFiles().forEach(file => { filePaths[file.path] = file.basename });
18+
const source_form_promise = async (value: string): Promise<void> => {
19+
// update settings
20+
view.diskConfig.updateConfig('source_form_result', value);
21+
};
2422

25-
add_dropdown(
26-
containerEl,
27-
'Select a tag',
28-
'Select tag to get data from',
29-
`#${view.diskConfig.yaml.config.source_form_result}`,
30-
tagRecords,
31-
source_form_promise
32-
);
33-
}
23+
add_dropdown(
24+
containerEl,
25+
'Select a tag',
26+
'Select tag to get data from',
27+
`#${view.diskConfig.yaml.config.source_form_result}`,
28+
filePaths,
29+
source_form_promise
30+
);
31+
break;
3432
default:
3533
//Current folder
3634
}
3735

3836
return this.goNext(settingHandlerResponse);
3937
}
38+
}
39+
40+
function tagHandler(view: DatabaseView, containerEl: HTMLElement) {
41+
const tagArray: Record<string, number> = (app.metadataCache as unknown as any).getTags();
42+
if (tagArray) {
43+
const tagRecords: Record<string, string> = {};
44+
Object.keys(tagArray).forEach((tag) => {
45+
tagRecords[tag] = tag;
46+
});
47+
const source_form_promise = async (value: string): Promise<void> => {
48+
// update settings
49+
view.diskConfig.updateConfig('source_form_result', value.slice(1));
50+
};
51+
52+
add_dropdown(
53+
containerEl,
54+
'Select a tag',
55+
'Select tag to get data from',
56+
`#${view.diskConfig.yaml.config.source_form_result}`,
57+
tagRecords,
58+
source_form_promise
59+
);
60+
}
4061
}

0 commit comments

Comments
 (0)