modules_setup

This commit is contained in:
Rushabh Mehta 2012-02-28 18:56:56 +05:30
parent d01cc0bc50
commit 17da764d04
13 changed files with 192 additions and 50 deletions

View File

@ -44,35 +44,60 @@ erpnext.desktop.add_classes = function() {
erpnext.desktop.render = function() {
var icons = [
{ gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates' },
{ gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home' },
{ gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home' },
{ gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home' },
{ gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home' },
{ gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home' },
{ gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources', link: '#!hr-home' },
{ gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home' },
{ gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home' },
{ gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home' },
{ gradient: 'grey', sprite: 'setting', label: 'Settings', link: '#!Setup' },
{ gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' },
//{ gradient: 'dark-blue', sprite: 'report', label: 'Report' },
{ gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' },
{ gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' },
{ gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' },
{ gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base', link: '#!questions' },
{ gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home',
is_module: 'Accounts'},
{ gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home',
is_module: 'Selling'},
{ gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home',
is_module: 'Stock'},
{ gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home',
is_module: 'Buying'},
{ gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home',
is_module: 'Support'},
{ gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources', link: '#!hr-home',
is_module: 'HR'},
{ gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home',
is_module: 'Projects'},
{ gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home',
is_module: 'Production'},
{ gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home',
is_module: 'Website'},
]
$.each(icons, function(i, v) {
var icon_case = $('#icon-grid').append(repl('\
var add_icon = function(v) {
$('#icon-grid').append(repl('\
<div id="%(sprite)s" class="case-wrapper"><a href="%(link)s">\
<div class="case-border case-%(gradient)s">\
<div class="sprite-image sprite-%(sprite)s"></div>\
</div></a>\
<div class="case-label">%(label)s</div>\
</div>', v));
});
</div>', v));
}
var get_module = function(m) {
for(var i in icons) {
if(icons[i].is_module==m) return icons[i]
}
}
// activity
add_icon({ gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates'});
// modules
for(var i in wn.boot.modules_list)
add_icon(get_module(wn.boot.modules_list[i]));
// setup
if(user_roles.indexOf('System Manager')!=-1)
add_icon({ gradient: 'grey', sprite: 'setting', label: 'Setup', link: '#!Setup' });
// apps
add_icon({ gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' });
add_icon({ gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' });
add_icon({ gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' });
add_icon({ gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' });
add_icon({ gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base', link: '#!questions' });
erpnext.desktop.show_pending_notifications();
}

View File

@ -0,0 +1,14 @@
<div class="layout-wrapper">
<a class="close" onclick="window.history.back();">&times;</a>
<h1>Modules Setup</h1>
<hr>
<div class="help" style="width: 300px; float: right">
Select checkbox to show / hide module. Drag around to move order.
</div>
<div id="modules-list">
</div>
<div>
<button class="btn btn-small btn-primary" id="modules-update"
onclick="wn.pages.modules_setup.update()">Update</button>
</div>
</div>

View File

@ -0,0 +1,50 @@
wn.require('lib/js/lib/jquery-ui-sortable.min.js');
$.extend(wn.pages.modules_setup, {
modules: ['Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects',
'Support', 'HR', 'Website'],
onload: function(wrapper) {
wn.pages.modules_setup.refresh(wn.boot.modules_list);
},
refresh: function(ml) {
$('#modules-list').empty();
// checked modules
for(i in ml) {
$('#modules-list').append(repl('<p style="cursor:move;">\
<input type="checkbox" data-module="%(m)s"> \
%(m)s</p>', {m:ml[i]}));
}
$('#modules-list [data-module]').attr('checked', true);
// unchecked modules
var all = wn.pages.modules_setup.modules;
for(i in all) {
if(!$('#modules-list [data-module="'+all[i]+'"]').length) {
$('#modules-list').append(repl('<p style="cursor:move;">\
<input type="checkbox" data-module="%(m)s"> \
%(m)s</p>', {m:all[i]}));
}
}
$('#modules-list').sortable();
},
update: function() {
var ml = [];
$('#modules-list [data-module]').each(function() {
if($(this).attr('checked'))
ml.push($(this).attr('data-module'));
});
wn.call({
method: 'setup.page.modules_setup.modules_setup.update',
args: {
ml: JSON.stringify(ml)
},
callback: function(r) {
},
btn: $('#modules-update').get(0)
});
}
});

View File

@ -0,0 +1,8 @@
import webnotes
@webnotes.whitelist()
def update(arg=None):
"""update modules"""
webnotes.conn.set_global('modules_list', webnotes.form_dict['ml'])
webnotes.msgprint('Updated')
webnotes.clear_cache()

View File

@ -0,0 +1,28 @@
# Page, modules_setup
[
# These values are common in all dictionaries
{
'creation': '2012-02-28 17:48:39',
'docstatus': 0,
'modified': '2012-02-28 17:48:39',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Setup',
'name': '__common__',
'page_name': u'modules_setup',
'standard': u'Yes',
'title': u'Modules Setup'
},
# Page, modules_setup
{
'doctype': 'Page',
'name': u'modules_setup'
}
]

View File

@ -20,7 +20,7 @@
<div class="setup-column">
<h3>Users and Permissions</h3>
<p>
<b><a href="#!My Company">Users</a></b><br>
<b><a href="#!users">Users</a></b><br>
<span class="help">Add/remove users, set roles, passwords etc</span>
</p>
<p>
@ -31,6 +31,10 @@
<b><a href="#!List/Authorization Rule">Amount based Authorization Rules</a></b><br>
<span class="help">Restrict submission rights based on amount</span>
</p>
<p>
<b><a href="#!modules_setup">Modules Setup</a></b><br>
<span class="help">Show, hide modules</span>
</p>
</div>
<div class="setup-column">
<h3>Data</h3>

View File

@ -87,6 +87,8 @@ def boot_session(bootinfo):
import webnotes.model.doctype
bootinfo['docs'] += webnotes.model.doctype.get('Event')
bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
def get_letter_heads():
"""load letter heads with startup"""

View File

@ -73,20 +73,35 @@ erpnext.toolbar.add_modules = function() {
$('<li class="dropdown">\
<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
onclick="return false;">Modules<b class="caret"></b></a>\
<ul class="dropdown-menu">\
<li><a href="#!accounts-home" data-module="Accounts">Accounts</a></li>\
<li><a href="#!selling-home" data-module="Selling">Selling</a></li>\
<li><a href="#!stock-home" data-module="Stock">Stock</a></li>\
<li><a href="#!buying-home" data-module="Buying">Buying</a></li>\
<li><a href="#!support-home" data-module="Support">Support</a></li>\
<li><a href="#!hr-home" data-module="HR">Human Resources</a></li>\
<li><a href="#!projects-home" data-module="Projects">Projects</a></li>\
<li><a href="#!production-home" data-module="Production">Production</a></li>\
<li><a href="#!website-home" data-module="Website">Website</a></li>\
<li class="divider"></li>\
<li><a href="#!Setup" data-module="Setup">Setup</a></li>\
<ul class="dropdown-menu modules">\
</ul>\
</li>').prependTo('.navbar .nav:first');
$('.navbar .nav:first')
// if no modules list then show all
if(wn.boot.modules_list)
wn.boot.modules_list = JSON.parse(wn.boot.modules_list);
else
wn.boot.modules_list = ['Accounts', 'Selling', 'Buying', 'Stock',
'Production', 'Projects', 'Support', 'HR', 'Website'];
// add to dropdown
for(var i in wn.boot.modules_list) {
var m = wn.boot.modules_list[i]
args = {
module: m,
module_page: m.toLowerCase(),
module_label: m=='HR' ? 'Human Resources' : m
}
$('.navbar .modules').append(repl('<li><a href="#!%(module_page)s-home" \
data-module="%(module)s">%(module_label)s</a></li>', args));
}
// setup for system manager
if(user_roles.indexOf("System Manager")!=-1) {
$('.navbar .modules').append('<li class="divider"></li>\
<li><a href="#!Setup" data-module="Setup">Setup</a></li>');
}
}

View File

@ -2240,20 +2240,16 @@ $.each(new_comments,function(i,v){var msg='New Message: '+(v[1].length<=100?v[1]
erpnext.toolbar.add_modules=function(){$('<li class="dropdown">\
<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
onclick="return false;">Modules<b class="caret"></b></a>\
<ul class="dropdown-menu">\
<li><a href="#!accounts-home" data-module="Accounts">Accounts</a></li>\
<li><a href="#!selling-home" data-module="Selling">Selling</a></li>\
<li><a href="#!stock-home" data-module="Stock">Stock</a></li>\
<li><a href="#!buying-home" data-module="Buying">Buying</a></li>\
<li><a href="#!support-home" data-module="Support">Support</a></li>\
<li><a href="#!hr-home" data-module="HR">Human Resources</a></li>\
<li><a href="#!projects-home" data-module="Projects">Projects</a></li>\
<li><a href="#!production-home" data-module="Production">Production</a></li>\
<li><a href="#!website-home" data-module="Website">Website</a></li>\
<li class="divider"></li>\
<li><a href="#!Setup" data-module="Setup">Setup</a></li>\
<ul class="dropdown-menu modules">\
</ul>\
</li>').prependTo('.navbar .nav:first');$('.navbar .nav:first')}
</li>').prependTo('.navbar .nav:first');if(wn.boot.modules_list)
wn.boot.modules_list=JSON.parse(wn.boot.modules_list);else
wn.boot.modules_list=['Accounts','Selling','Buying','Stock','Production','Projects','Support','HR','Website'];for(var i in wn.boot.modules_list){var m=wn.boot.modules_list[i]
args={module:m,module_page:m.toLowerCase(),module_label:m=='HR'?'Human Resources':m}
$('.navbar .modules').append(repl('<li><a href="#!%(module_page)s-home" \
data-module="%(module)s">%(module_label)s</a></li>',args));}
if(user_roles.indexOf("System Manager")!=-1){$('.navbar .modules').append('<li class="divider"></li>\
<li><a href="#!Setup" data-module="Setup">Setup</a></li>');}}
/*
* erpnext/startup/feature_setup.js
*/

View File

@ -1086,4 +1086,4 @@ item.route=item.url||item.custom_page;$parent_li.find('.dropdown-menu').append(r
<a href="https://erpnext.com">erpnext.com</a></div>\
</div>',wn.boot.website_settings));this.make_items();},make_items:function(){var items=wn.boot.website_menus
for(var i=0;i<items.length;i++){var item=items[i];if(!item.parent_label&&item.parentfield=='footer_items'){item.route=item.url||item.custom_page;$('.web-footer-menu ul').append(repl('<li><a href="#!%(route)s" \
data-label="%(label)s">%(label)s</a></li>',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.navbar();})
data-label="%(label)s">%(label)s</a></li>',item))}}}});$(document).bind('startup',function(){erpnext.footer=new erpnext.Footer();erpnext.navbar.navbar=new erpnext.navbar.navbar();})

View File

@ -1 +1 @@
748
752