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

Commit 8d188df

Browse files
committed
documentation link on formulas
1 parent 46f1f73 commit 8d188df

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/automations/formula_functions/FormulaFunctions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { IGenerateObject } from "automations/IGenerateObject";
2-
import { UserScriptFunctions } from "automations/formula_functions/ScriptFunctions";
2+
import { ScriptFunctions } from "automations/formula_functions/ScriptFunctions";
33
import { LocalSettings } from "cdm/SettingsModel";
44

55
export class FormulaFunctions implements IGenerateObject {
6-
private js_script_functions: UserScriptFunctions;
6+
private js_script_functions: ScriptFunctions;
77

88
constructor(private config: LocalSettings) {
9-
this.js_script_functions = new UserScriptFunctions(config);
9+
this.js_script_functions = new ScriptFunctions(config);
1010
}
1111

1212
async generate_object(
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Notice, TFile } from "obsidian";
1+
import { TFile } from "obsidian";
22
import { IGenerateObject } from "automations/IGenerateObject";
33
import { get_tfiles_from_folder } from "helpers/FileManagement";
44
import { LocalSettings } from "cdm/SettingsModel";
55
import { LOGGER } from "services/Logger";
66

7-
export class UserScriptFunctions implements IGenerateObject {
7+
export class ScriptFunctions implements IGenerateObject {
88
constructor(private config: LocalSettings) { }
99

10-
async generate_user_script_functions(
10+
async generate_script_functions(
1111
): Promise<Map<string, Function>> {
12-
const user_script_functions: Map<string, Function> = new Map();
12+
const script_functions: Map<string, Function> = new Map();
1313
const files =
1414
get_tfiles_from_folder(
1515
this.config.formula_folder_path,
@@ -21,18 +21,18 @@ export class UserScriptFunctions implements IGenerateObject {
2121

2222
for (const file of files) {
2323
if (file.extension.toLowerCase() === "js") {
24-
await this.load_user_script_function(
24+
await this.load_script_function(
2525
file,
26-
user_script_functions
26+
script_functions
2727
);
2828
}
2929
}
30-
return user_script_functions;
30+
return script_functions;
3131
}
3232

33-
async load_user_script_function(
33+
async load_script_function(
3434
file: TFile,
35-
user_script_functions: Map<string, Function>
35+
script_functions: Map<string, Function>
3636
): Promise<void> {
3737
let req = (s: string) => {
3838
return window.require && window.require(s);
@@ -48,20 +48,20 @@ export class UserScriptFunctions implements IGenerateObject {
4848
const formula_function = exp['default'] || mod.exports;
4949

5050
if (!formula_function) {
51-
const msg = `Failed to load user script ${file.path}. No exports detected.`;
51+
const msg = `Failed to load script ${file.path}. No exports detected.`;
5252
LOGGER.error(msg);
5353
return;
5454
}
5555
if (!(formula_function instanceof Function)) {
56-
const msg = `Failed to load user script ${file.path}. Default export is not a function.`
56+
const msg = `Failed to load script ${file.path}. Default export is not a function.`
5757
LOGGER.error(msg);
5858
return;
5959
}
60-
user_script_functions.set(`${file.basename}`, formula_function);
60+
script_functions.set(`${file.basename}`, formula_function);
6161
}
6262

6363
async generate_object(): Promise<Record<string, unknown>> {
64-
const user_script_functions = await this.generate_user_script_functions();
65-
return Object.fromEntries(user_script_functions);
64+
const script_functions = await this.generate_script_functions();
65+
return Object.fromEntries(script_functions);
6666
}
6767
}

src/components/modals/columnSettings/handlers/automations/FormulaInputHandler.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ export class FormulaInputHandler extends AbstractHandlerClass<ColumnSettingsHand
2424
textArea.setPlaceholder('Write here your formula');
2525
textArea.onChange(formula_promise);
2626
});
27+
const mainDesc = containerEl.createEl('p');
2728

29+
mainDesc.appendText('Check our ');
30+
mainDesc.appendChild(
31+
createEl('a', {
32+
text: "documentation",
33+
href: "https://rafaelgb.github.io/obsidian-db-folder/features/Formulas/",
34+
})
35+
);
36+
37+
mainDesc.appendText(' for more information about how to use formulas');
2838
return this.goNext(columnHandlerResponse);
2939
}
3040
}

0 commit comments

Comments
 (0)