Skip to content

Commit 8326afc

Browse files
committed
Check for missed templates
1 parent 68572ae commit 8326afc

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "bibtex-manager",
33
"name": "BibTeX Manager",
4-
"version": "0.9.0",
4+
"version": "0.9.1",
55
"minAppVersion": "1.5.0",
66
"description": "Create a literature notes from a BibTeX entries.",
77
"author": "Akop Kesheshyan",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bibtex-manager",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "Create notes and citations from BibTeX files",
55
"main": "main.js",
66
"scripts": {

src/components/modals/base.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ export class BaseModal extends Modal {
1818
this.settings = settings;
1919
}
2020

21+
checkTemplatesExists(): boolean {
22+
for (const type of BibTeXTypes) {
23+
const templateName = "template" + type;
24+
if (!this.settings[templateName]) {
25+
return false;
26+
}
27+
}
28+
return true;
29+
}
30+
2131
async getTemplate(entry: Entry): Promise<string> {
2232
const templateName =
2333
entry.type.charAt(0).toUpperCase() + entry.type.slice(1);
@@ -102,8 +112,28 @@ export class BaseModal extends Modal {
102112
async onOpen() {
103113
const { contentEl } = this;
104114

105-
contentEl.createEl("h2", { text: `${this.title} a note` });
115+
const isTemplateExists = this.checkTemplatesExists();
116+
117+
if (!isTemplateExists) {
106118

119+
contentEl.createEl("h2", { text: `Missed templates` });
120+
const errorMessage = contentEl.createEl("div", { cls: "bibtex-manager-no-settings" });
121+
errorMessage.createSpan({
122+
cls: "bibtex-manager-no-settings-text", text: `Please set the template for each BibTeX entry type in plugin settings.`
123+
});
124+
125+
new Setting(contentEl)
126+
.addButton((btn) => {
127+
btn.setButtonText("Open settings").setCta().onClick(() => {
128+
const commands = (this.app as any).commands;
129+
commands.executeCommandById("app:open-settings", { tab: "plugins/bibtex-manager" });
130+
this.close();
131+
});
132+
});
133+
return;
134+
}
135+
136+
contentEl.createEl("h2", { text: `${this.title} a note` });
107137
new Setting(contentEl)
108138
.addSearch((text) => {
109139
text.setPlaceholder("Enter a URL or arXiv ID").onChange((value) => {

styles.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@
6666
border-top: 1px solid var(--background-modifier-border);
6767
margin: 0 10px;
6868
}
69+
70+
.bibtex-manager-no-settings{
71+
display: flex;
72+
flex-direction: column;
73+
align-items: center;
74+
justify-content: center;
75+
height: 100%;
76+
padding: 20px;
77+
border: 0 !important;
78+
}

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"0.9.0": "1.5.0"
2+
"0.9.0": "1.5.0",
3+
"0.9.1": "1.5.0"
34
}

0 commit comments

Comments
 (0)