mirror of
https://github.com/frappe/books.git
synced 2025-01-11 10:38:14 +00:00
update sidebar config to show hide groups and items based on condition
This commit is contained in:
parent
a294ca20bc
commit
41bb11f023
@ -52,7 +52,6 @@
|
|||||||
<div v-if="group.items && isActiveGroup(group)">
|
<div v-if="group.items && isActiveGroup(group)">
|
||||||
<div
|
<div
|
||||||
v-for="item in group.items"
|
v-for="item in group.items"
|
||||||
v-show="item.visible"
|
|
||||||
:key="item.label"
|
:key="item.label"
|
||||||
class="
|
class="
|
||||||
mt-1
|
mt-1
|
||||||
@ -115,7 +114,8 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.companyName = await sidebarConfig.getTitle();
|
this.companyName = await sidebarConfig.getTitle();
|
||||||
this.groups = sidebarConfig.groups.filter((group) => {
|
let groups = sidebarConfig.getGroups();
|
||||||
|
groups = groups.filter((group) => {
|
||||||
if (
|
if (
|
||||||
group.route === '/get-started' &&
|
group.route === '/get-started' &&
|
||||||
frappe.SystemSettings.hideGetStarted
|
frappe.SystemSettings.hideGetStarted
|
||||||
@ -125,6 +125,28 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// use the hidden property in the routes config to show/hide the elements
|
||||||
|
// filter doens't work with async function so using reduce
|
||||||
|
for (let group of groups) {
|
||||||
|
if (group.items) {
|
||||||
|
group.items = await group.items.reduce(async (acc, item) => {
|
||||||
|
if (item.hidden) {
|
||||||
|
const hidden = await item.hidden();
|
||||||
|
if (hidden) {
|
||||||
|
return acc;
|
||||||
|
} else {
|
||||||
|
return (await acc).concat(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await acc).concat(item);
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.groups = groups;
|
||||||
|
|
||||||
this.setActiveGroup();
|
this.setActiveGroup();
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
this.setActiveGroup();
|
this.setActiveGroup();
|
||||||
|
@ -7,7 +7,7 @@ const config = {
|
|||||||
const { companyName } = await frappe.getSingle('AccountingSettings');
|
const { companyName } = await frappe.getSingle('AccountingSettings');
|
||||||
return companyName;
|
return companyName;
|
||||||
},
|
},
|
||||||
groups: [
|
getGroups: () => [
|
||||||
{
|
{
|
||||||
title: _('Get Started'),
|
title: _('Get Started'),
|
||||||
route: '/get-started',
|
route: '/get-started',
|
||||||
@ -27,13 +27,11 @@ const config = {
|
|||||||
label: _('Invoices'),
|
label: _('Invoices'),
|
||||||
route: '/list/SalesInvoice',
|
route: '/list/SalesInvoice',
|
||||||
doctype: 'SalesInvoice',
|
doctype: 'SalesInvoice',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Customers'),
|
label: _('Customers'),
|
||||||
route: '/list/Customer',
|
route: '/list/Customer',
|
||||||
doctype: 'Customer',
|
doctype: 'Customer',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -46,13 +44,11 @@ const config = {
|
|||||||
label: _('Bills'),
|
label: _('Bills'),
|
||||||
route: '/list/PurchaseInvoice',
|
route: '/list/PurchaseInvoice',
|
||||||
doctype: 'PurchaseInvoice',
|
doctype: 'PurchaseInvoice',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Suppliers'),
|
label: _('Suppliers'),
|
||||||
route: '/list/Supplier',
|
route: '/list/Supplier',
|
||||||
doctype: 'Supplier',
|
doctype: 'Supplier',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -65,19 +61,16 @@ const config = {
|
|||||||
label: _('Items'),
|
label: _('Items'),
|
||||||
route: '/list/Item',
|
route: '/list/Item',
|
||||||
doctype: 'Item',
|
doctype: 'Item',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Payments'),
|
label: _('Payments'),
|
||||||
route: '/list/Payment',
|
route: '/list/Payment',
|
||||||
doctype: 'Payment',
|
doctype: 'Payment',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Journal Entry'),
|
label: _('Journal Entry'),
|
||||||
route: '/list/JournalEntry',
|
route: '/list/JournalEntry',
|
||||||
doctype: 'JournalEntry',
|
doctype: 'JournalEntry',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -89,39 +82,33 @@ const config = {
|
|||||||
{
|
{
|
||||||
label: _('General Ledger'),
|
label: _('General Ledger'),
|
||||||
route: '/report/general-ledger',
|
route: '/report/general-ledger',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Profit And Loss'),
|
label: _('Profit And Loss'),
|
||||||
route: '/report/profit-and-loss',
|
route: '/report/profit-and-loss',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Balance Sheet'),
|
label: _('Balance Sheet'),
|
||||||
route: '/report/balance-sheet',
|
route: '/report/balance-sheet',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Trial Balance'),
|
label: _('Trial Balance'),
|
||||||
route: '/report/trial-balance',
|
route: '/report/trial-balance',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('GSTR1'),
|
label: _('GSTR1'),
|
||||||
route: '/report/gstr-1',
|
route: '/report/gstr-1',
|
||||||
visible: async () => {
|
hidden: async () => {
|
||||||
const { country } = await frappe.getSingle('AccountingSettings');
|
const { country } = await frappe.getSingle('AccountingSettings');
|
||||||
if (country === 'India') return 1;
|
return country !== 'India';
|
||||||
return 0;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('GSTR2'),
|
label: _('GSTR2'),
|
||||||
route: '/report/gstr-2',
|
route: '/report/gstr-2',
|
||||||
visible: async () => {
|
hidden: async () => {
|
||||||
const { country } = await frappe.getSingle('AccountingSettings');
|
const { country } = await frappe.getSingle('AccountingSettings');
|
||||||
if (country === 'India') return 1;
|
return country !== 'India';
|
||||||
return 0;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -134,18 +121,15 @@ const config = {
|
|||||||
{
|
{
|
||||||
label: _('Chart of Accounts'),
|
label: _('Chart of Accounts'),
|
||||||
route: '/chart-of-accounts',
|
route: '/chart-of-accounts',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Taxes'),
|
label: _('Taxes'),
|
||||||
route: '/list/Tax',
|
route: '/list/Tax',
|
||||||
doctype: 'Tax',
|
doctype: 'Tax',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: _('Settings'),
|
label: _('Settings'),
|
||||||
route: '/settings',
|
route: '/settings',
|
||||||
visible: 1,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user