[modules] [redesign]
This commit is contained in:
parent
eb399f74bd
commit
b6262c1639
38 changed files with 330 additions and 405 deletions
|
|
@ -37,8 +37,6 @@ def get_bootinfo():
|
|||
load_desktop_icons(bootinfo)
|
||||
|
||||
bootinfo.module_app = frappe.local.module_app
|
||||
bootinfo.doctype_icons = dict(frappe.db.sql("""select name, icon from
|
||||
tabDocType where ifnull(icon,'')!=''"""))
|
||||
bootinfo.single_types = frappe.db.sql_list("""select name from tabDocType where issingle=1""")
|
||||
add_home_page(bootinfo, doclist)
|
||||
bootinfo.page_info = get_allowed_pages()
|
||||
|
|
@ -66,7 +64,7 @@ def get_bootinfo():
|
|||
bootinfo.error_report_email = frappe.get_hooks("error_report_email")
|
||||
bootinfo.calendars = sorted(frappe.get_hooks("calendars"))
|
||||
bootinfo["lang_dict"] = get_lang_dict()
|
||||
|
||||
|
||||
return bootinfo
|
||||
|
||||
def load_conf_settings(bootinfo):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from frappe import _
|
|||
def get_data():
|
||||
return [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"label": _("Web Site"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
|
|
@ -12,11 +12,6 @@ def get_data():
|
|||
"name": "Web Page",
|
||||
"description": _("Content web page."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blog Post",
|
||||
"description": _("Single Post (article)."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Web Form",
|
||||
|
|
@ -24,13 +19,28 @@ def get_data():
|
|||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blogger",
|
||||
"description": _("User ID of a blog writer."),
|
||||
"name": "Website Slideshow",
|
||||
"description": _("Embed image slideshows in website pages."),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Blog"),
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blog Post",
|
||||
"description": _("Single Post (article)."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Website Slideshow",
|
||||
"description": _("Embed image slideshows in website pages."),
|
||||
"name": "Blog Settings",
|
||||
"description": _("Write titles and introductions to your blog."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blog Category",
|
||||
"description": _("Categorize blog posts."),
|
||||
},
|
||||
]
|
||||
},
|
||||
|
|
@ -45,24 +55,14 @@ def get_data():
|
|||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Style Settings",
|
||||
"description": _("Setup of fonts and background."),
|
||||
"name": "Website Theme",
|
||||
"description": _("List of themes for Website."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Website Script",
|
||||
"description": _("Javascript to append to the head section of the page."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blog Settings",
|
||||
"description": _("Write titles and introductions to your blog."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Blog Category",
|
||||
"description": _("Categorize blog posts."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "About Us Settings",
|
||||
|
|
@ -73,11 +73,6 @@ def get_data():
|
|||
"name": "Contact Us Settings",
|
||||
"description": _("Settings for Contact Us Page."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Website Theme",
|
||||
"description": _("List of themes for Website."),
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ $.extend(frappe.desktop, {
|
|||
|
||||
frappe.desktop.wrapper.html(frappe.render_template(template, {
|
||||
// all visible icons
|
||||
desktop_items: frappe.desktop.get_desktop_items(),
|
||||
desktop_items: frappe.get_desktop_icons(),
|
||||
}));
|
||||
|
||||
frappe.desktop.setup_module_click();
|
||||
|
|
@ -48,44 +48,6 @@ $.extend(frappe.desktop, {
|
|||
$(document).trigger("desktop-render");
|
||||
},
|
||||
|
||||
get_desktop_items: function() {
|
||||
// filter valid icons
|
||||
var out = [];
|
||||
|
||||
var add_to_out = function(module) {
|
||||
var module = frappe.get_module(module.module_name, module);
|
||||
module.app_icon = frappe.ui.app_icon.get_html(module);
|
||||
out.push(module);
|
||||
}
|
||||
|
||||
var is_permitted = function(module) {
|
||||
if(m._doctype) {
|
||||
return frappe.model.can_read(m._doctype);
|
||||
} else {
|
||||
return frappe.boot.user.allow_modules.indexOf(m.module_name) !== -1
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0, l=frappe.boot.desktop_icons.length; i < l; i++) {
|
||||
var m = frappe.boot.desktop_icons[i];
|
||||
if ((['Setup', 'Core'].indexOf(m.module_name) === -1)
|
||||
&& is_permitted(m)
|
||||
&& !m.hidden) {
|
||||
add_to_out(m)
|
||||
}
|
||||
}
|
||||
|
||||
if(user_roles.indexOf('System Manager')!=-1) {
|
||||
add_to_out(frappe.get_module('Setup'))
|
||||
}
|
||||
|
||||
if(user_roles.indexOf('Administrator')!=-1) {
|
||||
add_to_out(frappe.get_module('Core'))
|
||||
}
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
setup_module_click: function() {
|
||||
if(frappe.list_desktop) {
|
||||
frappe.desktop.wrapper.on("click", ".desktop-list-item", function() {
|
||||
|
|
|
|||
|
|
@ -42,13 +42,20 @@ def get_user_icons(user):
|
|||
user_perms = UserPermissions(user)
|
||||
user_perms.build_permissions()
|
||||
|
||||
from frappe.boot import get_allowed_pages
|
||||
|
||||
allowed_pages = get_allowed_pages()
|
||||
|
||||
icons = []
|
||||
for icon in get_desktop_icons(user):
|
||||
print icon.module_name
|
||||
if icon.hidden_in_standard:
|
||||
continue
|
||||
if not icon.custom and not icon.module_name in user_perms.allow_modules:
|
||||
continue
|
||||
if not icon.custom:
|
||||
if icon.type=="page" and icon.link not in allowed_pages:
|
||||
continue
|
||||
|
||||
elif icon.type=="module" and icon.module_name not in user_perms.allow_modules:
|
||||
continue
|
||||
|
||||
icons.append(icon)
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def get_desktop_icons(user=None):
|
|||
|
||||
# override properties from standard icon
|
||||
if standard_icon:
|
||||
for key in ('route', 'label', 'color', 'icon'):
|
||||
for key in ('route', 'label', 'color', 'icon', 'link'):
|
||||
if standard_icon.get(key):
|
||||
icon[key] = standard_icon.get(key)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ frappe.ui.form.on("Event", {
|
|||
if(frm.doc.ref_type && frm.doc.ref_name) {
|
||||
frm.add_custom_button(__(frm.doc.ref_name), function() {
|
||||
frappe.set_route("Form", frm.doc.ref_type, frm.doc.ref_name);
|
||||
}, frappe.boot.doctype_icons[frm.doc.ref_type]);
|
||||
});
|
||||
}
|
||||
},
|
||||
repeat_on: function(frm) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ frappe.ui.form.on("ToDo", {
|
|||
if(frm.doc.reference_type && frm.doc.reference_name) {
|
||||
frm.add_custom_button(__(frm.doc.reference_name), function() {
|
||||
frappe.set_route("Form", frm.doc.reference_type, frm.doc.reference_name);
|
||||
}, frappe.boot.doctype_icons[frm.doc.reference_type]);
|
||||
});
|
||||
}
|
||||
|
||||
if (!frm.doc.__islocal) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def get_data(module):
|
|||
data = combine_common_sections(data)
|
||||
data = apply_permissions(data)
|
||||
|
||||
set_last_modified(data)
|
||||
#set_last_modified(data)
|
||||
|
||||
return data
|
||||
|
||||
|
|
|
|||
|
|
@ -124,12 +124,6 @@ frappe.activity.Feed = Class.extend({
|
|||
data.imgsrc = frappe.utils.get_file_link(frappe.user_info(data.owner).image);
|
||||
|
||||
data.icon = "icon-flag";
|
||||
// if(data.doc_type) {
|
||||
// data.feed_type = data.doc_type;
|
||||
// data.icon = frappe.boot.doctype_icons[data.doc_type];
|
||||
// }
|
||||
|
||||
// data.feed_type = data.feed_type || "Comment";
|
||||
|
||||
// color for comment
|
||||
data.add_class = {
|
||||
|
|
|
|||
|
|
@ -6,34 +6,116 @@ frappe.pages['modules'].on_page_load = function(wrapper) {
|
|||
});
|
||||
|
||||
frappe.modules_page = page;
|
||||
page.section_data = {};
|
||||
|
||||
page.wrapper.find('.page-head').toggle(false);
|
||||
page.wrapper.find('.page-content').css({'margin-top': '0px'});
|
||||
page.wrapper.find('.page-head h1').css({'padding-left': '15px'});
|
||||
// page.wrapper.find('.page-content').css({'margin-top': '0px'});
|
||||
|
||||
// render sidebar
|
||||
page.sidebar.html(frappe.render_template('modules_sidebar', {modules: frappe.get_desktop_icons()}));
|
||||
|
||||
page.wrapper.find('.module-link').on('click', function() {
|
||||
render_section($(this).attr('data-name'));
|
||||
});
|
||||
page.activate_link = function(link) {
|
||||
page.wrapper.find('.module-sidebar-item.active, .module-link.active').removeClass('active');
|
||||
$(link).addClass('active').parent().addClass("active");
|
||||
show_section($(link).attr('data-name'));
|
||||
}
|
||||
|
||||
var render_section = function(module_name) {
|
||||
return frappe.call({
|
||||
method: "frappe.desk.moduleview.get",
|
||||
args: {
|
||||
module: module_name
|
||||
},
|
||||
callback: function(r) {
|
||||
m = frappe.get_module(module_name);
|
||||
m.data = r.message.data;
|
||||
console.log(m);
|
||||
page.main.html(frappe.render_template('modules_section', m));
|
||||
},
|
||||
freeze: true,
|
||||
var show_section = function(module_name) {
|
||||
if(module_name in page.section_data) {
|
||||
render_section(page.section_data[module_name]);
|
||||
} else {
|
||||
page.main.empty();
|
||||
return frappe.call({
|
||||
method: "frappe.desk.moduleview.get",
|
||||
args: {
|
||||
module: module_name
|
||||
},
|
||||
callback: function(r) {
|
||||
m = frappe.get_module(module_name);
|
||||
m.data = r.message.data;
|
||||
process_data(m.data);
|
||||
page.section_data[module_name] = m;
|
||||
render_section(m);
|
||||
},
|
||||
freeze: true,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var render_section = function(m) {
|
||||
page.set_title(__(m.label));
|
||||
page.main.html(frappe.render_template('modules_section', m));
|
||||
|
||||
if(frappe.utils.is_mobile()) {
|
||||
$(document).scrollTop($('.module-body').offset().top - 100);
|
||||
}
|
||||
|
||||
//setup_section_toggle();
|
||||
frappe.app.update_notification_count_in_modules();
|
||||
|
||||
page.main.find('.module-section-link').on("click", function(event) {
|
||||
// if clicked on open notification!
|
||||
if (event.target.classList.contains("open-notification")) {
|
||||
var doctype = event.target.getAttribute("data-doctype");
|
||||
frappe.route_options = frappe.boot.notification_info.conditions[doctype];
|
||||
return false;
|
||||
}
|
||||
if($(this).attr("data-type")==="help") {
|
||||
frappe.help.show_video($(this).attr("data-youtube-id"));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
var process_data = function(data) {
|
||||
data.forEach(function(section) {
|
||||
section.items.forEach(function(item) {
|
||||
item.style = '';
|
||||
if(item.type==="doctype") {
|
||||
item.doctype = item.name;
|
||||
}
|
||||
if(!item.route) {
|
||||
if(item.link) {
|
||||
item.route=strip(item.link, "#")
|
||||
}
|
||||
else if(item.type==="doctype") {
|
||||
item.route="List/" + item.doctype
|
||||
item.style = 'text-decoration: underline;';
|
||||
// item.style = 'font-weight: bold;';
|
||||
}
|
||||
else if(item.type==="report" && item.is_query_report) {
|
||||
item.route="query-report/" + item.name
|
||||
}
|
||||
else if(item.type==="report") {
|
||||
item.route="Report/" + item.doctype + "/" + item.name
|
||||
}
|
||||
else if(item.type==="page") {
|
||||
item.route=item.name;
|
||||
}
|
||||
}
|
||||
|
||||
if(item.route_options) {
|
||||
item.route += "?" + $.map(item.route_options, function(value, key) {
|
||||
return encodeURIComponent(key) + "=" + encodeURIComponent(value) }).join('&')
|
||||
}
|
||||
|
||||
if(item.type==="page" || item.type==="help" ||
|
||||
(item.doctype && frappe.model.can_read(item.doctype))) {
|
||||
item.shown = true;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
frappe.pages['modules'].on_page_show = function(wrapper) {
|
||||
var route = frappe.get_route();
|
||||
if(route.length > 1) {
|
||||
var link = frappe.modules_page.sidebar.find('.module-link[data-name="'+ route[1] +'"]');
|
||||
frappe.modules_page.activate_link(link);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,36 +1,29 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2>{{ label }}</h2>
|
||||
{% for (var i=0; i < data.length; i++) { var section = data[i]; %}
|
||||
<div class="module-section">
|
||||
<h4>{{ section.label }}</h4>
|
||||
{% for (var j=0; j < section.items.length; j++) {
|
||||
var item = section.items[j];
|
||||
if(item.type==="doctype") {
|
||||
item.doctype = item.name;
|
||||
}
|
||||
if(item.doctype && frappe.model.can_read(item.doctype)) {
|
||||
if(item.link) {
|
||||
item.route=strip(item.link, "#")
|
||||
}
|
||||
else if(item.type==="doctype") {
|
||||
item.route="List/" + item.doctype
|
||||
}
|
||||
else if(item.type==="report" && item.is_query_report) {
|
||||
item.route="query-report/" + item.name
|
||||
}
|
||||
else if(item.type==="report") {
|
||||
item.route="Report/" + item.doctype + "/" + item.name
|
||||
}
|
||||
else if(item.type==="page") {
|
||||
item.route=item.name;
|
||||
}
|
||||
%}
|
||||
<p><a href="#{{ item.route }}">{{ item.label }}</a></p>
|
||||
{% } %}
|
||||
<div class="module-body">
|
||||
{% for (var i=0; i < data.length; i++) { var section = data[i]; %}
|
||||
{% if ((i % 2)===0) { %}<div class="row module-section">{% } %}
|
||||
<div class="col-md-6">
|
||||
<div class="h4 section-head">
|
||||
{{ section.label }}
|
||||
</div>
|
||||
<div class="section-body">
|
||||
{% for (var j=0; j < section.items.length; j++) {
|
||||
var item = section.items[j];
|
||||
if(item.shown) { %}
|
||||
<div style="min-height: 22px; margin-top: 8px;">
|
||||
<a class="module-section-link" data-type="{{ item.type }}"
|
||||
{% if(item.type==="help") { %}
|
||||
data-youtube-id="{{ item.youtube_id }}"{% } %}
|
||||
href="#{{ item.route }}" style="{{ item.style }}">
|
||||
{{ item.label }}</a>
|
||||
{% if(item.type==="doctype") { %}
|
||||
<span class="open-notification hide"
|
||||
data-doctype="{{ item.doctype || item.name }}"></span>
|
||||
{% } %}
|
||||
</div>
|
||||
{% } %}
|
||||
{% } %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if ((i % 2)===1 || i===data.length-1) { %}</div>{% } %}
|
||||
{% } %}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
<ul class="module-sidebar-nav nav nav-pills nav-stacked">
|
||||
{% for (var i=0, l= modules.length; i < l; i++) { var item = modules[i]; %}
|
||||
{% for (var i=0, l= modules.length; i < l; i++) { var item = modules[i];
|
||||
if(item.type==="module") { %}
|
||||
<li data-label="{{ item.label }}" class="strong module-sidebar-item">
|
||||
<a class="module-link" data-name="{{ item.module_name }}">
|
||||
<i class="icon icon-chevron-right pull-right"
|
||||
style="display: none;"></i>
|
||||
<span>{{ item.label }}</span></a>
|
||||
<a class="module-link" data-name="{{ item.module_name }}"
|
||||
href="#modules/{{ item.module_name }}">
|
||||
<i class="icon icon-chevron-right pull-right"
|
||||
style="display: none;"></i>
|
||||
<span>{{ item.label }}</span></a>
|
||||
</li>
|
||||
{% } %}
|
||||
{% }; } %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ app_include_js = [
|
|||
"assets/js/editor.min.js",
|
||||
"assets/js/list.min.js",
|
||||
"assets/js/form.min.js",
|
||||
"assets/js/report.min.js",
|
||||
"assets/js/module.min.js"
|
||||
"assets/js/report.min.js"
|
||||
]
|
||||
app_include_css = [
|
||||
"assets/css/desk.min.css",
|
||||
|
|
|
|||
|
|
@ -186,19 +186,17 @@ def remove_app(app_name, dry_run=False):
|
|||
if not dry_run:
|
||||
frappe.delete_doc("Module Def", module_name)
|
||||
|
||||
# delete desktop icons
|
||||
frappe.db.sql('delete from `tabDesktop Icon` where app=%s', app_name)
|
||||
|
||||
remove_from_installed_apps(app_name)
|
||||
|
||||
<<<<<<< HEAD
|
||||
if not dry_run:
|
||||
# drop tables after a commit
|
||||
frappe.db.commit()
|
||||
|
||||
for doctype in set(drop_doctypes):
|
||||
frappe.db.sql("drop table `tab{0}`".format(doctype))
|
||||
=======
|
||||
# delete desktop icons
|
||||
frappe.db.sql('delete from `tabDesktop Icon` where app=%s', app_name)
|
||||
>>>>>>> [enhancement] desktop icons DocType
|
||||
|
||||
def post_install(rebuild_website=False):
|
||||
if rebuild_website:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,5 @@ def execute():
|
|||
|
||||
# set remaining icons as hidden
|
||||
for module_name in list(set([m['module_name'] for m in modules_list]) - set(user_list)):
|
||||
print user, module_name
|
||||
desktop_icon = get_user_copy(module_name, user=user.name)
|
||||
desktop_icon.db_set('hidden', 1)
|
||||
|
|
|
|||
|
|
@ -137,12 +137,6 @@
|
|||
"css/module.min.css": [
|
||||
"public/css/module.css"
|
||||
],
|
||||
"js/module.min.js": [
|
||||
"public/js/frappe/views/module/module_title.html",
|
||||
"public/js/frappe/views/module/module_section.html",
|
||||
"public/js/frappe/views/module/module_sidebar.html",
|
||||
"public/js/frappe/views/module/moduleview.js"
|
||||
],
|
||||
"css/form.min.css": [
|
||||
"public/css/form_grid.css"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
|
||||
body {
|
||||
font-family: "Open Sans", "Helvetica", Arial, "sans-serif";
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
|
||||
body {
|
||||
font-family: "Open Sans", "Helvetica", Arial, "sans-serif";
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,32 @@
|
|||
.module-head {
|
||||
padding: 15px 30px;
|
||||
border-bottom: 1px solid #EBEFF2;
|
||||
}
|
||||
.module-head h1 {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
.module-body {
|
||||
padding: 0px 15px;
|
||||
}
|
||||
.module-body .section-head {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.module-section {
|
||||
padding: 15px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
.module-section .module-section-link {
|
||||
line-height: 1.5em;
|
||||
font-size: 12px;
|
||||
}
|
||||
.module-section .section-head {
|
||||
margin-top: 30px;
|
||||
}
|
||||
.module-item {
|
||||
margin: 0px;
|
||||
padding: 7px;
|
||||
font-weight: 400;
|
||||
border-bottom: 1px solid #d1d8dd;
|
||||
cursor: pointer;
|
||||
transition: 0.2s;
|
||||
|
|
@ -23,8 +49,8 @@
|
|||
.module-item:last-child {
|
||||
border: none;
|
||||
}
|
||||
.module-sidebar-item.active .icon-chevron-right {
|
||||
margin-top: 2px;
|
||||
.module-link.active .icon-chevron-right {
|
||||
margin-top: 4px;
|
||||
display: block !important;
|
||||
}
|
||||
.module-item-progress {
|
||||
|
|
@ -42,6 +68,10 @@
|
|||
width: 0px;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.module-body {
|
||||
border-top: 1px solid #EBEFF2;
|
||||
margin-top: 15px;
|
||||
}
|
||||
body[data-route^="Module"] .page-title {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ select.input-sm {
|
|||
}
|
||||
@media (max-width: 767px) {
|
||||
.page-actions {
|
||||
width: 100px;
|
||||
width: 105px;
|
||||
float: right;
|
||||
}
|
||||
.page-title {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
|
||||
body {
|
||||
font-family: "Open Sans", "Helvetica", Arial, "sans-serif";
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ frappe.get_module = function(m, default_module) {
|
|||
}
|
||||
|
||||
if(module.type==="module" && !module.link) {
|
||||
module.link = "Module/" + module.module_name;
|
||||
module.link = "modules/" + module.module_name;
|
||||
}
|
||||
|
||||
if(module.type==="list" && !module.link) {
|
||||
|
|
@ -353,6 +353,47 @@ frappe.get_module = function(m, default_module) {
|
|||
return module;
|
||||
};
|
||||
|
||||
frappe.get_desktop_icons = function() {
|
||||
// filter valid icons
|
||||
var out = [];
|
||||
|
||||
var add_to_out = function(module) {
|
||||
var module = frappe.get_module(module.module_name, module);
|
||||
module.app_icon = frappe.ui.app_icon.get_html(module);
|
||||
out.push(module);
|
||||
}
|
||||
|
||||
var is_permitted = function(module) {
|
||||
if(m.type==="page") {
|
||||
return m.link in frappe.boot.page_info;
|
||||
}
|
||||
if(m._doctype) {
|
||||
return frappe.model.can_read(m._doctype);
|
||||
} else {
|
||||
return frappe.boot.user.allow_modules.indexOf(m.module_name) !== -1
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0, l=frappe.boot.desktop_icons.length; i < l; i++) {
|
||||
var m = frappe.boot.desktop_icons[i];
|
||||
if ((['Setup', 'Core'].indexOf(m.module_name) === -1)
|
||||
&& is_permitted(m)
|
||||
&& !m.hidden) {
|
||||
add_to_out(m)
|
||||
}
|
||||
}
|
||||
|
||||
if(user_roles.indexOf('System Manager')!=-1) {
|
||||
add_to_out(frappe.get_module('Setup'))
|
||||
}
|
||||
|
||||
if(user_roles.indexOf('Administrator')!=-1) {
|
||||
add_to_out(frappe.get_module('Core'))
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
frappe.add_to_desktop = function(label, doctype) {
|
||||
frappe.call({
|
||||
method: 'frappe.desk.doctype.desktop_icon.desktop_icon.add_user_icon',
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ frappe.ui.form.Dashboard = Class.extend({
|
|||
<div class="alert-badge">\
|
||||
<a class="badge-link h6 text-muted">%(label)s\
|
||||
<span class="badge" style="margin-left: 10px; font-size: 12px;">-</span></a>\
|
||||
</div></div>', {label:label, icon: frappe.boot.doctype_icons[doctype]}))
|
||||
</div></div>', {label:label}))
|
||||
.appendTo(this.body)
|
||||
|
||||
badge.find(".badge-link").click(onclick);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,20 @@ frappe.views.ListFactory = frappe.views.Factory.extend({
|
|||
});
|
||||
},
|
||||
show: function() {
|
||||
this.set_module_breadcrumb();
|
||||
this._super();
|
||||
this.set_cur_list();
|
||||
cur_list && cur_list.refresh();
|
||||
},
|
||||
set_module_breadcrumb: function() {
|
||||
if(frappe.route_history.length > 1) {
|
||||
var prev_route = frappe.route_history[frappe.route_history.length-2];
|
||||
if(prev_route[0]==="modules") {
|
||||
// save the last page from the breadcrumb was accessed
|
||||
frappe.breadcrumbs.set_doctype_module(frappe.get_route()[1], prev_route[1]);
|
||||
}
|
||||
}
|
||||
},
|
||||
set_cur_list: function() {
|
||||
var route = frappe.get_route();
|
||||
cur_list = frappe.container.page && frappe.container.page.doclistview;
|
||||
|
|
|
|||
|
|
@ -141,9 +141,10 @@ $.extend(frappe.user, {
|
|||
},
|
||||
|
||||
is_module: function(m) {
|
||||
frappe.boot.desktop_icons.forEach(function(module) {
|
||||
if(m===module.module_name) return true;
|
||||
});
|
||||
var icons = frappe.get_desktop_icons();
|
||||
for(var i=0; i<icons.length; i++) {
|
||||
if(m===icons[i].module_name) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ frappe.utils = {
|
|||
}
|
||||
return true;
|
||||
},
|
||||
is_mobile: function() {
|
||||
return $(document).width() < 768;
|
||||
},
|
||||
strip_whitespace: function(html) {
|
||||
return (html || "").replace(/<p>\s*<\/p>/g, "").replace(/<br>(\s*<br>\s*)+/g, "<br><br>");
|
||||
},
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ frappe.ui.Dialog = frappe.ui.FieldGroup.extend({
|
|||
var me = this;
|
||||
this.$wrapper
|
||||
.on("hide.bs.modal", function() {
|
||||
if(me.body_hidden) {
|
||||
$("#body_div").toggle(true);
|
||||
}
|
||||
me.display = false;
|
||||
if(frappe.ui.open_dialogs[frappe.ui.open_dialogs.length-1]===me) {
|
||||
frappe.ui.open_dialogs.pop();
|
||||
|
|
@ -49,6 +52,10 @@ frappe.ui.Dialog = frappe.ui.FieldGroup.extend({
|
|||
})
|
||||
.on("shown.bs.modal", function() {
|
||||
// focus on first input
|
||||
if(frappe.utils.is_mobile()) {
|
||||
$("#body_div").toggle(false);
|
||||
me.body_hidden = true;
|
||||
}
|
||||
me.display = true;
|
||||
cur_dialog = me;
|
||||
frappe.ui.open_dialogs.push(me);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ frappe.ui.Page = Class.extend({
|
|||
<div class="layout-footer hide"></div>\
|
||||
</div>\
|
||||
</div>');
|
||||
// this.wrapper.find('.page-title')
|
||||
// .removeClass('col-md-7').addClass('col-md-offset-2 col-md-5')
|
||||
// .css({'padding-left': '45px'});
|
||||
}
|
||||
|
||||
this.$title_area = this.wrapper.find("h1");
|
||||
|
|
@ -299,25 +302,6 @@ frappe.ui.Page = Class.extend({
|
|||
this.$sub_title_area.html(txt).toggleClass("hide", !!!txt);
|
||||
},
|
||||
|
||||
add_module_icon: function(module, doctype, onclick, sub_title) {
|
||||
var module_info = frappe.get_module(module);
|
||||
if(!module_info) {
|
||||
module_info = {
|
||||
icon: "icon-question-sign",
|
||||
color: "#ddd"
|
||||
}
|
||||
}
|
||||
var icon = frappe.boot.doctype_icons[doctype] || module_info.icon;
|
||||
|
||||
this.get_main_icon(icon)
|
||||
.attr("doctype-name", doctype);
|
||||
|
||||
this.set_title_left(function() {
|
||||
var route = frappe.get_route()[0]==module_info.link ? "" : module_info.link;
|
||||
frappe.set_route(route);
|
||||
});
|
||||
},
|
||||
|
||||
get_main_icon: function(icon) {
|
||||
return this.$title_area.find(".title-icon")
|
||||
.html('<i class="'+icon+' icon-fixed-width"></i> ')
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ frappe.ui.notifications.add_notification = function(doctype, notifications_map)
|
|||
%(count)s</span> \
|
||||
%(label)s </a></li>', {
|
||||
label: __(label),
|
||||
icon: frappe.boot.doctype_icons[doctype],
|
||||
count: count > 99 ? '99+' : count,
|
||||
data_doctype: doctype
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,8 +50,9 @@ frappe.breadcrumbs = {
|
|||
icon = module_info && module_info.icon,
|
||||
label = module_info ? module_info.label : breadcrumbs.module;
|
||||
|
||||
|
||||
if(module_info) {
|
||||
$(repl('<li><a href="#Module/%(module)s">%(label)s</a></li>',
|
||||
$(repl('<li><a href="#modules/%(module)s">%(label)s</a></li>',
|
||||
{ module: breadcrumbs.module, label: __(label) }))
|
||||
.appendTo($breadcrumbs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
<div class="module-section">
|
||||
{% for(var i=0, j= data.items.length; i < j; i++) { var item = data.items[i]; %}
|
||||
<div class="row module-item" data-item-index={%= i %}>
|
||||
{% if (item.description) { %}
|
||||
<div class="col-xs-8">
|
||||
<h4>{%= item.label || item.name %}</h4>
|
||||
{% if (item.type==="doctype" || item.type==="page") { %}
|
||||
<span class="open-notification hide" data-doctype="{%= item.data_doctype || item.name %}"></span>
|
||||
{% } %}
|
||||
<p class="text-muted small module-item-description hidden-xs">{%= item.description %}</p>
|
||||
</div>
|
||||
<div class="col-xs-4 text-muted text-right small" style="padding-top: 5px;">
|
||||
{% if (item.last_modified) { %}
|
||||
{%= comment_when(item.last_modified) %}
|
||||
{% } %}
|
||||
</div>
|
||||
{% } else { %}
|
||||
<div class="col-xs-12">
|
||||
<h4>{%= item.label || item.name %}</h4>
|
||||
</div>
|
||||
{% } %}
|
||||
</div>
|
||||
{% } %}
|
||||
<div class="row visible-sm visible-xs" style="padding: 15px;">
|
||||
<div class="col-xs-12">
|
||||
<a onclick="frappe.ui.toolbar.toggle_left_sidebar();" class="text-primary">
|
||||
{%= __("More") %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<ul class="module-sidebar-nav">
|
||||
<li class="divider"></li>
|
||||
{% for (var i=0, l= data.data.length; i < l; i++) { var item = data.data[i]; %}
|
||||
<li data-label="{%= item.label %}" class="strong module-sidebar-item">
|
||||
<a class="module-link">
|
||||
<i class="icon icon-chevron-right pull-right" style="display: none;"></i>
|
||||
<span>{%= item.label %}</span></a>
|
||||
</li>
|
||||
{% } %}
|
||||
</ul>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<div class="mobile-module-icon pull-right small visible-xs">{%= title %}</div>
|
||||
<div class="mobile-title col-sm-8 col-xs-7 visible-xs">
|
||||
<div class="dropdown">
|
||||
<h2 class="dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true"
|
||||
style="cursor: pointer; margin: 15px 0px;">
|
||||
<span class="active-section">{%= section_name %}</span>
|
||||
<span class="caret"></span>
|
||||
</h2>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="ModuleSections">
|
||||
{% for (var i=0, l= data.data.length; i < l; i++) {
|
||||
var item = data.data[i];
|
||||
if (item.label !== section_name) { %}
|
||||
<li role="presentation" data-label="{%= item.label %}">
|
||||
<a role="menuitem" tabindex="-1" class="module-link">{%= item.label %}</a>
|
||||
</li>
|
||||
{% }
|
||||
} %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// MIT License. See license.txt
|
||||
|
||||
frappe.provide("frappe.views.moduleview");
|
||||
frappe.provide("frappe.module_page");
|
||||
|
||||
frappe.views.ModuleFactory = frappe.views.Factory.extend({
|
||||
make: function(route) {
|
||||
var module = route[1];
|
||||
frappe.views.moduleview[module] = parent;
|
||||
new frappe.views.moduleview.ModuleView(module);
|
||||
this.on_show();
|
||||
},
|
||||
on_show: function() {
|
||||
frappe.breadcrumbs.last_module = frappe.get_route()[1];
|
||||
}
|
||||
});
|
||||
|
||||
frappe.views.moduleview.ModuleView = Class.extend({
|
||||
init: function(module) {
|
||||
this.module = module;
|
||||
this.module_info = frappe.get_module(module) || {};
|
||||
this.module_label = __(this.module_info.label || this.module);
|
||||
this.sections = {};
|
||||
this.current_section = null;
|
||||
this.make();
|
||||
$(".navbar-center").html(this.module_label);
|
||||
},
|
||||
|
||||
make: function() {
|
||||
var me = this;
|
||||
return frappe.call({
|
||||
method: "frappe.desk.moduleview.get",
|
||||
args: {
|
||||
module: this.module
|
||||
},
|
||||
callback: function(r) {
|
||||
me.data = r.message;
|
||||
me.parent = frappe.make_page(true);
|
||||
frappe.views.moduleview[me.module] = me.parent;
|
||||
me.page = me.parent.page;
|
||||
me.parent.moduleview = me;
|
||||
me.render();
|
||||
},
|
||||
freeze: true,
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.page.main.empty();
|
||||
this.make_sidebar();
|
||||
this.sections_by_label = {};
|
||||
|
||||
// index by label
|
||||
for(var i in this.data.data) {
|
||||
this.sections_by_label[this.data.data[i].label] = this.data.data[i];
|
||||
}
|
||||
this.activate(this.data.data[0].label);
|
||||
},
|
||||
|
||||
make_sidebar: function(name) {
|
||||
var me = this;
|
||||
var sidebar_content = frappe.render_template("module_sidebar", {data:this.data});
|
||||
var module_sidebar = $(sidebar_content)
|
||||
.addClass("nav nav-pills nav-stacked")
|
||||
.appendTo(this.page.sidebar.addClass("hidden-xs hidden-sm"));
|
||||
var offcanvas_module_sidebar = $(sidebar_content)
|
||||
.addClass("list-unstyled sidebar-menu")
|
||||
.appendTo($(".sidebar-left .module-sidebar").empty());
|
||||
|
||||
this.sidebar = offcanvas_module_sidebar.add(module_sidebar);
|
||||
this.sidebar.on("click", ".module-link", function() {
|
||||
me.activate($(this).parent().attr("data-label"));
|
||||
});
|
||||
},
|
||||
|
||||
activate: function(name) {
|
||||
var me = this;
|
||||
if(this.current_section) {
|
||||
this.current_section.addClass("hide");
|
||||
}
|
||||
if(!this.sections[name]) {
|
||||
var data = this.sections_by_label[name];
|
||||
this.sections[name] = $(frappe.render_template("module_section", { data: data }))
|
||||
.appendTo(this.page.main);
|
||||
|
||||
$(this.sections[name]).find(".module-item").each(function(i, mi) {
|
||||
var item = data.items[$(mi).attr("data-item-index")];
|
||||
$(mi)
|
||||
.attr("data-route", me.get_route(item).join("/"))
|
||||
.attr("data-label", item.name)
|
||||
.on("click", function(event) {
|
||||
// if clicked on open notification!
|
||||
if (event.target.classList.contains("open-notification")) {
|
||||
var doctype = event.target.getAttribute("data-doctype");
|
||||
frappe.route_options = frappe.boot.notification_info.conditions[doctype];
|
||||
}
|
||||
if(item.type==="help") {
|
||||
frappe.help.show_video(item.youtube_id);
|
||||
return false;
|
||||
} else {
|
||||
frappe.set_route(me.get_route(item));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// set title
|
||||
this.page.set_title(repl('<span class="hidden-xs hidden-sm">%(module)s</span>\
|
||||
<span class="hidden-md hidden-lg">%(section)s</span>',
|
||||
{module: this.module_label, section: name}));
|
||||
|
||||
this.current_section = this.sections[name];
|
||||
this.current_section.removeClass("hide");
|
||||
|
||||
// active
|
||||
this.sidebar.find("li.active").removeClass("active");
|
||||
this.sidebar.find('[data-label="'+ name +'"]').addClass("active");
|
||||
|
||||
frappe.app.update_notification_count_in_modules();
|
||||
},
|
||||
|
||||
get_route: function(item) {
|
||||
var route = [item.route || item.link];
|
||||
if (!route[0]) {
|
||||
if (item.type == "doctype") {
|
||||
// save the last page from the breadcrumb was accessed
|
||||
frappe.breadcrumbs.set_doctype_module(item.name, this.module);
|
||||
if(!item.view) item.view = "List"
|
||||
route = [item.view, item.name];
|
||||
} else if (item.type == "page") {
|
||||
route = [item.name]
|
||||
} else if (item.type == "report") {
|
||||
if(item.is_query_report) {
|
||||
route = ["query-report", item.name];
|
||||
} else {
|
||||
route = ["Report", item.doctype, item.name];
|
||||
}
|
||||
}
|
||||
}
|
||||
return route;
|
||||
}
|
||||
});
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
@import "variables.less";
|
||||
@import "mixins.less";
|
||||
|
||||
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
|
||||
|
||||
body {
|
||||
font-family: "Open Sans", "Helvetica", Arial, "sans-serif";
|
||||
}
|
||||
// @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
|
||||
//
|
||||
// body {
|
||||
// font-family: "Open Sans", "Helvetica", Arial, "sans-serif";
|
||||
// }
|
||||
|
||||
a {
|
||||
cursor: pointer;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,41 @@
|
|||
@import "variables.less";
|
||||
|
||||
.module-head {
|
||||
padding: 15px 30px;
|
||||
border-bottom: 1px solid @light-border-color;
|
||||
}
|
||||
|
||||
.module-head h1 {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.module-body {
|
||||
padding: 0px 15px;
|
||||
|
||||
.section-head {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.module-section {
|
||||
padding: 15px;
|
||||
padding-top: 0px;
|
||||
|
||||
.module-section-link {
|
||||
line-height: 1.5em;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.module-section .section-head {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.module-item {
|
||||
margin: 0px;
|
||||
padding: 7px;
|
||||
font-weight: 400;
|
||||
border-bottom: 1px solid @border-color;
|
||||
cursor: pointer;
|
||||
transition: 0.2s;
|
||||
|
|
@ -30,8 +63,8 @@
|
|||
border: none;
|
||||
}
|
||||
|
||||
.module-sidebar-item.active .icon-chevron-right {
|
||||
margin-top: 2px;
|
||||
.module-link.active .icon-chevron-right {
|
||||
margin-top: 4px;
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +86,17 @@
|
|||
}
|
||||
|
||||
@media(max-width: 767px) {
|
||||
.module-body {
|
||||
border-top: 1px solid @light-border-color;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
body[data-route^="Module"] {
|
||||
.page-title {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.page-actions {
|
||||
display: none !important;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ select.input-sm {
|
|||
|
||||
@media(max-width: @screen-xs) {
|
||||
.page-actions {
|
||||
width: 100px;
|
||||
width: 105px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ def render_template(template, context, is_path=None):
|
|||
:param is_path: (optional) assert that the `template` parameter is a path'''
|
||||
|
||||
# if it ends with .html then its a freaking path, not html
|
||||
if is_path or (template.endswith('.html') and '\n' not in template):
|
||||
if (is_path
|
||||
or template.startswith("templates/")
|
||||
or (template.endswith('.html') and '\n' not in template)):
|
||||
return get_jenv().get_template(template).render(context)
|
||||
else:
|
||||
return get_jenv().from_string(template).render(context)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue