What I’m trying to do
Within a table generated listing notes in a folder, I am trying to set a variable in a button - ${area} with the value from YAML “area:” for each note in the table.
The purpose: to display a list of notes in a table, select the metadata “area” for each note and then click the button to move the note to the proper folder based on that value.
const {fieldModifier: f} = this.app.plugins.plugins["metadata-menu"].api;
dv.table(["Name", "Area", "Type", "Timing", ""],
dv.pages('"_inbox/Unprocessed Notes"')
.map(p => {
const btn = this.container.createEl('button', {"text": "Move to Area"});
btn.addEventListener('click', async () => {
const area = // <- this is the varible I am looking to set to the value "area" for the note
if (!area) {
alert("Please set area");
return;
}
const destPath = `2. Areas/${area}/${p.file.name}.md`;
console.log(area)
//await this.app.vault.createFolderByPath(`2. Areas/${area}`);
await this.app.vault.rename(p.file, destPath);
await dv.refresh();
console.log(area)
});
return [
p.file.link,
f(dv, p, "area"),
f(dv, p, "note_type"),
f(dv, p, "timing"),
btn,
];
})
);
Things I have tried
The script below is working IF I hard code the value of ${area}. I can’t figure out how to do that programmatically.
I don’t know JavaScript, I’ve just been pulling this together from resources I find - and throwing things at the wall to see what sticks.
Any suggestions on how to get this done?