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

@@ -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>