wn.provide('erpnext.desktop');
erpnext.desktop.refresh = function() {
erpnext.desktop.render();
$("#icon-grid").sortable({
update: function() {
new_order = [];
$("#icon-grid .case-wrapper").each(function(i, e) {
new_order.push($(this).attr("data-name"));
});
wn.defaults.set_default("_desktop_items", new_order);
}
});
}
erpnext.desktop.render = function() {
document.title = "Desktop";
var add_icon = function(m) {
var module = wn.modules[m];
if(!module.label)
module.label = m;
module.name = m;
module.label = wn._(module.label);
//module.gradient_css = wn.get_gradient_css(module.color, 45);
module._link = module.link.toLowerCase().replace("/", "-");
$module_icon = $(repl('
', module)).click(function() {
wn.set_route($(this).attr("data-link"));
}).css({
cursor:"pointer"
}).appendTo("#icon-grid");
}
// modules
var modules_list = wn.user.get_desktop_items();
$.each(modules_list, function(i, m) {
if(m!="Setup")
add_icon(m);
})
// setup
if(user_roles.indexOf('System Manager')!=-1)
add_icon('Setup')
// notifications
erpnext.desktop.show_pending_notifications();
}
erpnext.desktop.show_pending_notifications = function() {
var add_circle = function(str_module, id, title) {
var module = $('#'+str_module);
module.prepend(
repl('\
\
', {id: id, title: wn._(title)}));
}
add_circle('module-icon-messages', 'unread_messages', 'Unread Messages');
add_circle('module-icon-support-home', 'open_support_tickets', 'Open Support Tickets');
add_circle('module-icon-todo', 'things_todo', 'Things To Do');
add_circle('module-icon-calendar-event', 'todays_events', 'Todays Events');
add_circle('module-icon-projects-home', 'open_tasks', 'Open Tasks');
add_circle('module-icon-questions', 'unanswered_questions', 'Unanswered Questions');
add_circle('module-icon-selling-home', 'open_leads', 'Open Leads');
erpnext.update_messages();
}
pscript.onload_desktop = function(wrapper) {
// load desktop
erpnext.desktop.refresh();
$(wrapper).css({"background-color": "transparent", "box-shadow":"none"});
}