101 lines
3.0 KiB
JavaScript
Raw Normal View History

2012-02-24 15:29:07 +05:30
wn.provide('erpnext.desktop');
erpnext.desktop.refresh = function() {
erpnext.desktop.render();
2012-12-21 15:00:29 +05:30
$("#icon-grid").sortable({
update: function() {
new_order = [];
$("#icon-grid .case-wrapper").each(function(i, e) {
new_order.push($(this).attr("data-name"));
});
wn.user.set_default("_desktop_items", new_order);
}
2012-02-24 15:29:07 +05:30
});
}
erpnext.desktop.render = function() {
2012-12-28 10:30:46 +05:30
document.title = "Desktop";
2012-02-29 10:55:43 +05:30
var add_icon = function(m) {
2012-12-21 15:00:29 +05:30
var module = wn.modules[m];
if(!module.label)
module.label = m;
module.name = m;
2013-01-07 15:39:54 +05:30
module.label = wn._(module.label);
2012-12-21 15:00:29 +05:30
module.gradient_css = wn.get_gradient_css(module.color, 45);
2013-01-24 16:30:50 +05:30
$module_icon = $(repl('\
<div id="module-icon-%(link)s" class="case-wrapper" \
data-name="%(name)s" data-link="%(link)s">\
2012-12-21 15:00:29 +05:30
<div class="case-border" style="%(gradient_css)s">\
<i class="%(icon)s"></i>\
2013-01-24 16:30:50 +05:30
</div>\
2012-02-24 15:29:07 +05:30
<div class="case-label">%(label)s</div>\
2013-01-24 16:30:50 +05:30
</div>', module)).click(function() {
wn.set_route($(this).attr("data-link"));
}).css({
cursor:"pointer"
}).appendTo("#icon-grid");
2012-02-28 18:56:56 +05:30
}
2012-12-21 15:00:29 +05:30
// modules
2012-12-22 07:42:04 +05:30
var modules_list = wn.user.get_desktop_items();
2012-12-21 15:00:29 +05:30
$.each(modules_list, function(i, m) {
2012-11-15 16:58:27 +05:30
if(!in_list(['Setup', 'Core'], m) && wn.boot.profile.allow_modules.indexOf(m)!=-1)
2012-02-29 10:55:43 +05:30
add_icon(m);
2012-12-21 15:00:29 +05:30
})
2012-03-01 11:24:45 +05:30
2012-12-21 15:00:29 +05:30
// setup
2012-02-28 18:56:56 +05:30
if(user_roles.indexOf('System Manager')!=-1)
2012-02-29 10:55:43 +05:30
add_icon('Setup')
2012-02-24 15:29:07 +05:30
2012-12-21 15:00:29 +05:30
// notifications
2012-02-24 17:56:00 +05:30
erpnext.desktop.show_pending_notifications();
}
erpnext.desktop.show_pending_notifications = function() {
var add_circle = function(str_module, id, title) {
var module = $('#'+str_module);
2013-01-24 16:30:50 +05:30
module.prepend(
repl('<div id="%(id)s" class="circle" title="%(title)s" style="display: None">\
<span class="circle-text"></span>\
2013-01-07 15:39:54 +05:30
</div>', {id: id, title: wn._(title)}));
var case_border = module.find('.case-border');
var circle = module.find('.circle');
var add_hover_and_click = function(primary, secondary, hover_class, click_class) {
primary
.hover(
function() { secondary.addClass(hover_class); },
function() { secondary.removeClass(hover_class); })
.mousedown(function() { secondary.addClass(click_class); })
.mouseup(function() { secondary.removeClass(click_class); })
.focusin(function() { $(this).mousedown(); })
.focusout(function() { $(this).mouseup(); })
}
add_hover_and_click(case_border, circle, 'hover-effect', 'circle-click');
add_hover_and_click(circle, case_border, 'hover-effect', 'case-border-click');
}
2012-12-21 15:00:29 +05:30
add_circle('module-icon-messages', 'unread_messages', 'Unread Messages');
2012-12-21 21:40:19 +05:30
add_circle('module-icon-support-home', 'open_support_tickets', 'Open Support Tickets');
2012-12-21 15:00:29 +05:30
add_circle('module-icon-todo', 'things_todo', 'Things To Do');
add_circle('module-icon-calendar', 'todays_events', 'Todays Events');
2012-12-21 22:49:10 +05:30
add_circle('module-icon-projects-home', 'open_tasks', 'Open Tasks');
2012-12-21 21:40:19 +05:30
add_circle('module-icon-questions', 'unanswered_questions', 'Unanswered Questions');
add_circle('module-icon-selling-home', 'open_leads', 'Open Leads');
2012-05-03 10:44:44 +05:30
erpnext.update_messages();
2012-02-24 17:56:00 +05:30
2012-02-24 15:29:07 +05:30
}
pscript.onload_desktop = function() {
// load desktop
erpnext.desktop.refresh();
}