mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
incr: allow deletion of groups if no children
This commit is contained in:
parent
a0aaa8c52b
commit
e9fe08e1f8
@ -101,7 +101,6 @@
|
|||||||
type="text"
|
type="text"
|
||||||
v-model="newAccountName"
|
v-model="newAccountName"
|
||||||
:disabled="insertingAccount"
|
:disabled="insertingAccount"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
v-if="!insertingAccount"
|
v-if="!insertingAccount"
|
||||||
@ -164,7 +163,7 @@ export default {
|
|||||||
if (fyo.store.isDevelopment) {
|
if (fyo.store.isDevelopment) {
|
||||||
window.coa = this;
|
window.coa = this;
|
||||||
}
|
}
|
||||||
docsPath.value = docsPathMap.ChartOfAccounts
|
docsPath.value = docsPathMap.ChartOfAccounts;
|
||||||
},
|
},
|
||||||
deactivated() {
|
deactivated() {
|
||||||
docsPath.value = '';
|
docsPath.value = '';
|
||||||
@ -184,28 +183,44 @@ export default {
|
|||||||
};
|
};
|
||||||
this.accounts = await this.getChildren();
|
this.accounts = await this.getChildren();
|
||||||
},
|
},
|
||||||
onClick(account) {
|
async onClick(account) {
|
||||||
if (!account.isGroup) {
|
let shouldOpen = !account.isGroup;
|
||||||
openQuickEdit({
|
if (account.isGroup) {
|
||||||
|
shouldOpen = !(await this.toggleChildren(account));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await openQuickEdit({
|
||||||
schemaName: ModelNameEnum.Account,
|
schemaName: ModelNameEnum.Account,
|
||||||
name: account.name,
|
name: account.name,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.toggleChildren(account);
|
const doc = await fyo.doc.getDoc(ModelNameEnum.Account, account.name);
|
||||||
}
|
doc.once('afterDelete', () => this.fetchAccounts());
|
||||||
},
|
},
|
||||||
async toggleChildren(account) {
|
async toggleChildren(account) {
|
||||||
await this.fetchChildren(account);
|
const hasChildren = await this.fetchChildren(account);
|
||||||
|
if (!hasChildren) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
account.expanded = !account.expanded;
|
account.expanded = !account.expanded;
|
||||||
if (!account.expanded) {
|
if (!account.expanded) {
|
||||||
account.addingAccount = 0;
|
account.addingAccount = 0;
|
||||||
account.addingGroupAccount = 0;
|
account.addingGroupAccount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
async fetchChildren(account, force = false) {
|
async fetchChildren(account, force = false) {
|
||||||
if (account.children == null || force) {
|
if (account.children == null || force) {
|
||||||
account.children = await this.getChildren(account.name);
|
account.children = await this.getChildren(account.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return !!account?.children?.length;
|
||||||
},
|
},
|
||||||
async getChildren(parent = null) {
|
async getChildren(parent = null) {
|
||||||
const children = await fyo.db.getAll(ModelNameEnum.Account, {
|
const children = await fyo.db.getAll(ModelNameEnum.Account, {
|
||||||
|
Loading…
Reference in New Issue
Block a user