ERPNext Conference 2019* ERPNext.com Blog

Trouble generating Custom desk page with sidebar and mainbody


#1

Created a new custom page for my custom module list on my custom app and was able to generate the sidebar which contains a lists of doctypes which for my case act as modules.
Can anyone help me generate the main page content
Thanks in advance
screenshots


here’s my code generating the page

frappe.pages['menu-mpya'].on_page_load = function(wrapper) {
	var page = frappe.ui.make_app_page({
		parent: wrapper,
		title: 'Menu Mpya',
		single_column: false
	});

	frappe.breadcrumbs.add("Frappe Light") 

	frappe.modules_page = page;

	let get_sidebar_html = () => {
		var sidebar_items = [];
		var sidebar_items_html = '';
		frappe.call({
	        method: 'frappe_light.frappe_light.page.menu_mpya.menu_mpya.get_menu_details',
	        async: false,
	        args: {
	        	doctype:"Menu Items",     
	            fields: [ "item_label","item_type", "item_link"],
	            parent: ["Custom Menu"],
	      	},

	      	callback: function(menu_items) {
		      	sidebar_items = menu_items.message;
		        //var a=r.message[0]
		        console.log(menu_items);

	        	sidebar_items.forEach(function(item, index){
					var item_html = `<li class="strong module-sidebar-item">
						<a class="module-link" data-name="${item.item_link}" href="#List/${item.item_link}/">
							<i class="fa fa-chevron-right pull-right" style="display: none;"></i>
							<span>${item.item_label}</span>
						</a>
					</li>`;
					sidebar_items_html += item_html;
				});
				console.log(sidebar_items_html);
				page.sidebar.html(`<ul class="module-sidebar-nav overlay-sidebar nav nav-pills nav-stacked">
					${sidebar_items_html}
					<li class="divider"></li>
				</ul>`);
	        }
	     });
	};

	// render sidebar
	page.sidebar.html(get_sidebar_html());

	// render main


};

frappe.pages['menu-mpya'].on_page_show = function(wrapper) {
	$("body").attr("data-sidebar", 1);
};