186 lines
3.6 KiB
Markdown
186 lines
3.6 KiB
Markdown
---
|
|
date: <% tp.date.now("YYYY-MM-DD") %>
|
|
status: proposed
|
|
owner: Amadou
|
|
project:
|
|
---
|
|
---
|
|
|
|
<%*
|
|
const date = tp.date.now("YYYY-MM-DD");
|
|
const year = tp.date.now("YYYY");
|
|
const month = tp.date.now("MM");
|
|
|
|
// --------------------------------------------------
|
|
// 1. Ask for decision title
|
|
// --------------------------------------------------
|
|
|
|
const title = await tp.system.prompt("Decision title");
|
|
|
|
if (!title) {
|
|
new Notice("Decision cancelled: no title entered.");
|
|
return;
|
|
}
|
|
|
|
const safeTitle = title
|
|
.replace(/[\\/:*?"<>|]/g, "-")
|
|
.trim();
|
|
|
|
// --------------------------------------------------
|
|
// 2. Find project folders for current year
|
|
// --------------------------------------------------
|
|
|
|
const projectsFolder = `20 Work/Projects/${year}`;
|
|
const projectsRoot = app.vault.getAbstractFileByPath(projectsFolder);
|
|
|
|
let projectFolders = [];
|
|
|
|
if (projectsRoot && projectsRoot.children) {
|
|
projectFolders = projectsRoot.children
|
|
.filter(item => item.children)
|
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
}
|
|
|
|
// --------------------------------------------------
|
|
// 3. Project dropdown
|
|
// --------------------------------------------------
|
|
|
|
const projectLabels = [
|
|
"— No project —",
|
|
...projectFolders.map(folder => folder.name)
|
|
];
|
|
|
|
const projectValues = [
|
|
null,
|
|
...projectFolders
|
|
];
|
|
|
|
const selectedProject = await tp.system.suggester(
|
|
projectLabels,
|
|
projectValues,
|
|
false,
|
|
"Related project"
|
|
);
|
|
|
|
if (selectedProject === undefined) {
|
|
new Notice("Decision cancelled.");
|
|
return;
|
|
}
|
|
|
|
const projectName = selectedProject
|
|
? selectedProject.name
|
|
: "";
|
|
|
|
const projectLink = selectedProject
|
|
? `[[${projectName}]]`
|
|
: "";
|
|
|
|
// --------------------------------------------------
|
|
// 4. Create Decisions/YYYY/MM
|
|
// --------------------------------------------------
|
|
|
|
const baseFolder = "20 Work/Decisions";
|
|
const yearFolder = `${baseFolder}/${year}`;
|
|
const monthFolder = `${yearFolder}/${month}`;
|
|
|
|
if (!app.vault.getAbstractFileByPath(yearFolder)) {
|
|
await app.vault.createFolder(yearFolder);
|
|
}
|
|
|
|
if (!app.vault.getAbstractFileByPath(monthFolder)) {
|
|
await app.vault.createFolder(monthFolder);
|
|
}
|
|
|
|
// --------------------------------------------------
|
|
// 5. Build filename
|
|
// --------------------------------------------------
|
|
|
|
let filename = `${date} - ${safeTitle}`;
|
|
|
|
if (selectedProject) {
|
|
const safeProject = projectName
|
|
.replace(/[\\/:*?"<>|]/g, "-")
|
|
.trim();
|
|
|
|
filename = `${date} - ${safeProject} - ${safeTitle}`;
|
|
}
|
|
|
|
// --------------------------------------------------
|
|
// 6. Move + rename
|
|
// --------------------------------------------------
|
|
|
|
await tp.file.move(`${monthFolder}/${filename}`);
|
|
|
|
// --------------------------------------------------
|
|
// 7. Update Properties AFTER Templater finishes
|
|
// --------------------------------------------------
|
|
|
|
tp.hooks.on_all_templates_executed(async () => {
|
|
|
|
const file = tp.file.find_tfile(
|
|
`${monthFolder}/${filename}`
|
|
);
|
|
|
|
if (!file) return;
|
|
|
|
await tp.app.fileManager.processFrontMatter(
|
|
file,
|
|
(frontmatter) => {
|
|
frontmatter.date = date;
|
|
frontmatter.status = "proposed";
|
|
frontmatter.owner = "Amadou";
|
|
frontmatter.project = projectLink;
|
|
}
|
|
);
|
|
});
|
|
-%>
|
|
|
|
> 🟡 **Proposed** · 🟢 **Decided** · 🔴 **Rejected** · ⚫ **Superseded**
|
|
|
|
## Context
|
|
|
|
Why is a decision needed?
|
|
|
|
<% tp.file.cursor() %>
|
|
|
|
## Options Considered _(optional)_
|
|
|
|
### Option 1
|
|
|
|
**Description:**
|
|
|
|
**Pros:**
|
|
-
|
|
|
|
**Cons:**
|
|
-
|
|
|
|
### Option 2
|
|
|
|
**Description:**
|
|
|
|
**Pros:**
|
|
-
|
|
|
|
**Cons:**
|
|
-
|
|
|
|
## Decision
|
|
|
|
What was decided?
|
|
|
|
## Why
|
|
|
|
Why was this option chosen?
|
|
|
|
-
|
|
|
|
## Consequences
|
|
|
|
What are we accepting by making this decision?
|
|
|
|
-
|
|
|
|
## Related
|
|
|
|
<% projectLink ? `- ${projectLink}` : "-" %> |