mirror of
https://github.com/al0cam/AutoMover.git
synced 2026-07-22 05:41:25 +00:00
updated with callback to display()
This commit is contained in:
parent
c881ce7a4a
commit
c3144528b3
4 changed files with 22 additions and 30 deletions
|
|
@ -5,6 +5,7 @@ import { Setting } from "obsidian";
|
|||
export function exclusionSection(
|
||||
containerEl: HTMLElement,
|
||||
plugin: AutoMoverPlugin,
|
||||
display: () => void,
|
||||
) {
|
||||
/**
|
||||
* Header for excluded folders
|
||||
|
|
@ -31,7 +32,7 @@ export function exclusionSection(
|
|||
});
|
||||
addExclusionButton.addEventListener("click", () => {
|
||||
plugin.settings.exclusionRules.push(new ExclusionRule());
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -56,7 +57,7 @@ export function exclusionSection(
|
|||
});
|
||||
duplicateExclusionButton.addEventListener("click", () => {
|
||||
plugin.settings.exclusionRules.push(new ExclusionRule(exclusion.regex));
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
const deleteExclusionButton = child.createEl("button", {
|
||||
|
|
@ -67,7 +68,7 @@ export function exclusionSection(
|
|||
plugin.settings.exclusionRules = plugin.settings.exclusionRules.filter(
|
||||
(r) => r !== exclusion,
|
||||
);
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import AutoMoverPlugin from "main";
|
||||
import { MovingRule } from "Models/MovingRule";
|
||||
import type AutoMoverPlugin from "main";
|
||||
import { Setting } from "obsidian";
|
||||
|
||||
export default function movingRuleSection(
|
||||
containerEl: HTMLElement,
|
||||
plugin: AutoMoverPlugin,
|
||||
display: () => void,
|
||||
) {
|
||||
/**
|
||||
* Header of the rules
|
||||
|
|
@ -32,8 +33,7 @@ export default function movingRuleSection(
|
|||
});
|
||||
addRuleButton.addEventListener("click", () => {
|
||||
plugin.settings.movingRules.push(new MovingRule());
|
||||
// this is used to rerender the settings tab
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +64,7 @@ export default function movingRuleSection(
|
|||
});
|
||||
duplicateRuleButton.addEventListener("click", () => {
|
||||
plugin.settings.movingRules.push(new MovingRule(rule.regex, rule.folder));
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
const deleteRuleButton = child.createEl("button", {
|
||||
|
|
@ -75,7 +75,7 @@ export default function movingRuleSection(
|
|||
plugin.settings.movingRules = plugin.settings.movingRules.filter(
|
||||
(r) => r !== rule,
|
||||
);
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class SettingsTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
// how to call rerendering from child section?
|
||||
display(): void {
|
||||
display = () => {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
|
|
@ -108,19 +108,6 @@ export class SettingsTab extends PluginSettingTab {
|
|||
}),
|
||||
);
|
||||
|
||||
// there is no default event to move on save, therefore, i'd need to define a new one
|
||||
// running move on change could be an option, but it would produce an overhead in performance because of constant checking for changes
|
||||
//
|
||||
// new obsidian.Setting(containerEl)
|
||||
// .setName("Move on save")
|
||||
// .setDesc("Should the file be moved when it is saved?")
|
||||
// .addToggle((cb) =>
|
||||
// cb.setValue(this.plugin.settings.moveOnSave).onChange(async (value) => {
|
||||
// this.plugin.settings.moveOnSave = value;
|
||||
// await this.plugin.saveData(this.plugin.settings);
|
||||
// }),
|
||||
// );
|
||||
|
||||
// TUTORIAL START
|
||||
/**
|
||||
* Instead of using the default .setting-item class I created a custom class to add other styling,
|
||||
|
|
@ -170,8 +157,8 @@ export class SettingsTab extends PluginSettingTab {
|
|||
example2.createSpan({ text: "Scrolls/$1", cls: "rule_title" });
|
||||
// TUTORIAL END
|
||||
|
||||
movingRuleSection(containerEl, this.plugin);
|
||||
exclusionSection(containerEl, this.plugin);
|
||||
tagSection(containerEl, this.plugin);
|
||||
}
|
||||
movingRuleSection(containerEl, this.plugin, this.display);
|
||||
exclusionSection(containerEl, this.plugin, this.display);
|
||||
tagSection(containerEl, this.plugin, this.display);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ import { MovingRule } from "Models/MovingRule";
|
|||
import * as obsidian from "obsidian";
|
||||
import type AutoMoverPlugin from "main";
|
||||
|
||||
export function tagSection(containerEl: HTMLElement, plugin: AutoMoverPlugin) {
|
||||
export function tagSection(
|
||||
containerEl: HTMLElement,
|
||||
plugin: AutoMoverPlugin,
|
||||
display: () => void,
|
||||
) {
|
||||
/**
|
||||
* Header for excluded folders
|
||||
*/
|
||||
|
|
@ -28,7 +32,7 @@ export function tagSection(containerEl: HTMLElement, plugin: AutoMoverPlugin) {
|
|||
});
|
||||
addTagButton.addEventListener("click", () => {
|
||||
plugin.settings.tagRules.push(new MovingRule());
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +63,7 @@ export function tagSection(containerEl: HTMLElement, plugin: AutoMoverPlugin) {
|
|||
});
|
||||
duplicateRuleButton.addEventListener("click", () => {
|
||||
plugin.settings.tagRules.push(new MovingRule(rule.regex, rule.folder));
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
|
||||
const deleteRuleButton = child.createEl("button", {
|
||||
|
|
@ -70,7 +74,7 @@ export function tagSection(containerEl: HTMLElement, plugin: AutoMoverPlugin) {
|
|||
plugin.settings.tagRules = plugin.settings.tagRules.filter(
|
||||
(r) => r !== rule,
|
||||
);
|
||||
this.display();
|
||||
display();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue