Skip to content

Commit 17709fa

Browse files
forbid make child or sibling with -cluster suffix
1 parent 062eb62 commit 17709fa

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/createFamily/commit_info.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
## Did
22

3+
- [*] forbid make child or sibling with -cluster suffix
4+
35
## ToDo
46

57
- [ ] FIX you need to add buttons line when onload if there is an active file
68
- [ ] make the extra buttons [ puzzle ] functionality implementation
79
- [ ] when you rename parent note you need rename the son's containing folder with same name
8-
- [ ] fix prevent making children withe "-cluster" name
910
- [ ] اخفي زر الحذف ضمن مجلد الكلستر عند الصغط على زر اليمين
11+
- [ ] forbid rename CLUSTERS and ORPHANS folders
12+
- [ ] son --> child , father --> parent , brother --> sibling
1013
- [ ] READEME.md
1114
- [ ] modifyFirst Template
12-
- [ ] Make TESTS
13-
- [ ] forbid make sons with -cluster name
14-
- [ ] son --> child , father --> parent , brother --> sibling

src/createFamily/familyModal.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ export default class familyModal extends Modal {
142142
if ((getActiveFile.path.match(/\//g) || []).length == 1) {
143143
const result = await templates(getActiveFile, "clusterSon");
144144
if (result.state) {
145-
145+
const childNameFromInput = this.inputEl.value.trim();
146+
if (childNameFromInput.endsWith("-cluster")) {
147+
new Notice("The name should'nt contain '-cluster' suffix", 3e3)
148+
return
149+
}
146150
const sonsFolderPath = `${getActiveFile?.parent?.path}/${currentActiveFileName}`;
147151
await this.createDirectory(appObject, "", sonsFolderPath);
148152
const newCreatedSonsFolder = getActiveFile.parent?.children?.find(
@@ -151,7 +155,7 @@ export default class familyModal extends Modal {
151155

152156
// @ts-ignore
153157
this.setFolder(newCreatedSonsFolder, "");
154-
await this.createNewNote(appObject, this.inputEl.value.trim(), result.clusterSonTemplate);
158+
await this.createNewNote(appObject, childNameFromInput, result.clusterSonTemplate);
155159
}
156160

157161
} else {
@@ -166,6 +170,11 @@ export default class familyModal extends Modal {
166170
const result = await templates(getActiveFile, "normalSon");
167171

168172
if (result.state) {
173+
const childNameFromInput = this.inputEl.value.trim();
174+
if (childNameFromInput.endsWith("-cluster")) {
175+
new Notice("The name should'nt contain '-cluster' suffix", 3e3)
176+
return
177+
}
169178
const sonsFolderPath = `${getActiveFile!.parent!.path}/${currentActiveFileName}`;
170179
await this.createDirectory(appObject, "", sonsFolderPath);
171180
const newCreatedSonsFolder = getActiveFile.parent!.children.find(
@@ -174,7 +183,7 @@ export default class familyModal extends Modal {
174183

175184
// @ts-ignore
176185
this.setFolder(newCreatedSonsFolder, "");
177-
await this.createNewNote(appObject, this.inputEl.value.trim(), result.normalSonTemplate);
186+
await this.createNewNote(appObject, childNameFromInput, result.normalSonTemplate);
178187
}
179188

180189
} else {
@@ -198,8 +207,13 @@ export default class familyModal extends Modal {
198207
const result = await templates(getActiveFile, "brother");
199208

200209
if (result.state == true) {
210+
const siblingNameFromInput = this.inputEl.value.trim();
211+
if (siblingNameFromInput.endsWith("-cluster")) {
212+
new Notice("The name should'nt contain '-cluster' suffix", 3e3)
213+
return
214+
}
201215
this.setFolder(getActiveFile!.parent!, "");
202-
this.createNewNote(appObject, this.inputEl.value.trim(), result.brotherTemplate);
216+
this.createNewNote(appObject, siblingNameFromInput, result.brotherTemplate);
203217
}
204218
}
205219
} else {

0 commit comments

Comments
 (0)