brotherton-erpnext/setup/page/modules_setup/modules_setup.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2012-09-24 13:43:42 +00:00
wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');
2012-02-28 13:26:56 +00:00
$.extend(wn.pages.modules_setup, {
modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Manufacturing', 'Projects',
2012-02-29 05:25:43 +00:00
'Support', 'HR', 'Website', 'To Do', 'Messages', 'Calendar', 'Knowledge Base'],
2012-02-28 13:26:56 +00:00
onload: function(wrapper) {
2012-04-10 13:44:37 +00:00
wn.pages.modules_setup.refresh_page(wn.boot.modules_list);
2012-02-28 13:26:56 +00:00
},
2012-04-10 13:44:37 +00:00
refresh_page: function(ml) {
2012-02-28 13:26:56 +00:00
$('#modules-list').empty();
2012-04-10 13:44:37 +00:00
// Hide Setup and Dashboard modules
ml.indexOf('Setup')!=-1 && ml.splice(ml.indexOf('Setup'), 1);
2012-02-28 13:26:56 +00:00
// 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)
});
}
2012-04-10 13:44:37 +00:00
});