2016-03-16 12:31:22 +00:00
|
|
|
frappe.ready(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
$( window ).load(function() {
|
|
|
|
$(".btn-open-tasks").click();
|
|
|
|
$(".btn-open-issues").click();
|
|
|
|
});
|
2016-03-16 12:31:22 +00:00
|
|
|
|
|
|
|
$('.btn-closed-tasks').click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
reload_items('closed','tasks');
|
2016-03-16 12:31:22 +00:00
|
|
|
});
|
2016-03-22 10:30:41 +00:00
|
|
|
|
2016-03-16 12:31:22 +00:00
|
|
|
$('.btn-open-tasks').click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
reload_items('open','tasks');
|
2016-03-16 12:31:22 +00:00
|
|
|
});
|
2016-03-22 10:30:41 +00:00
|
|
|
|
2016-03-16 12:31:22 +00:00
|
|
|
$('.btn-closed-issues').click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
reload_items('closed','issues');
|
2016-03-16 12:31:22 +00:00
|
|
|
});
|
2016-03-22 10:30:41 +00:00
|
|
|
|
2016-03-16 12:31:22 +00:00
|
|
|
$('.btn-open-issues').click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
reload_items('open','issues');
|
2016-03-16 12:31:22 +00:00
|
|
|
});
|
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
var start = 10;
|
2016-03-16 12:31:22 +00:00
|
|
|
$(".more-tasks").click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
more_items('tasks', true);
|
|
|
|
});
|
2016-03-16 12:31:22 +00:00
|
|
|
|
|
|
|
$(".more-issues").click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
more_items('issues', true);
|
|
|
|
});
|
2016-03-16 12:31:22 +00:00
|
|
|
|
|
|
|
$(".more-timelogs").click(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
more_items('timelogs', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".more-timelines").click(function() {
|
|
|
|
more_items('timelines', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
$( ".project-tasks" ).on('click', '.task-x', function() {
|
|
|
|
var item_name = $(this).attr('id');
|
|
|
|
close_item('task', item_name);
|
|
|
|
});
|
|
|
|
|
|
|
|
$( ".project-issues" ).on('click', '.issue-x', function() {
|
|
|
|
var item_name = $(this).attr('id');
|
|
|
|
close_item('issue', item_name);
|
|
|
|
});
|
|
|
|
|
|
|
|
var reload_items = function(item_status, item) {
|
2016-03-16 12:31:22 +00:00
|
|
|
$.ajax({
|
|
|
|
method: "GET",
|
|
|
|
url: "/",
|
|
|
|
dataType: "json",
|
|
|
|
data: {
|
2016-03-22 10:30:41 +00:00
|
|
|
cmd: "erpnext.templates.pages.projects.get_"+ item +"_html",
|
2016-03-16 12:31:22 +00:00
|
|
|
project: '{{ doc.name }}',
|
2016-03-22 10:30:41 +00:00
|
|
|
item_status: item_status,
|
2016-03-16 12:31:22 +00:00
|
|
|
},
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
2016-03-22 10:30:41 +00:00
|
|
|
$('.project-'+ item).html(data.message);
|
2016-03-16 12:31:22 +00:00
|
|
|
|
2016-03-23 08:44:38 +00:00
|
|
|
$('.project-'+ item +'-section .btn-group .bold').removeClass('bold');
|
|
|
|
$('.btn-'+ item_status +'-'+ item).addClass( "bold" );
|
2016-03-22 10:30:41 +00:00
|
|
|
$(".more-"+ item).toggle(true);
|
2016-03-16 12:31:22 +00:00
|
|
|
}
|
|
|
|
});
|
2016-03-22 10:30:41 +00:00
|
|
|
|
|
|
|
}
|
2016-03-16 12:31:22 +00:00
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
var more_items = function(item, item_status){
|
|
|
|
if(item_status)
|
|
|
|
{
|
|
|
|
var item_status = $('.project-'+ item +'-section .btn-group .btn-primary').hasClass('btn-closed-'+ item)
|
|
|
|
? 'closed' : 'open';
|
|
|
|
}
|
2016-03-16 12:31:22 +00:00
|
|
|
$.ajax({
|
|
|
|
method: "GET",
|
|
|
|
url: "/",
|
|
|
|
dataType: "json",
|
|
|
|
data: {
|
2016-03-22 10:30:41 +00:00
|
|
|
cmd: "erpnext.templates.pages.projects.get_"+ item +"_html",
|
2016-03-16 12:31:22 +00:00
|
|
|
project: '{{ doc.name }}',
|
2016-03-22 10:30:41 +00:00
|
|
|
start: start,
|
|
|
|
item_status: item_status,
|
2016-03-16 12:31:22 +00:00
|
|
|
},
|
|
|
|
dataType: "json",
|
|
|
|
success: function(data) {
|
2016-03-22 10:30:41 +00:00
|
|
|
$(data.message).appendTo('.project-'+ item);
|
|
|
|
if(typeof data.message == 'undefined') {
|
|
|
|
$(".more-"+ item).toggle(false);
|
2016-03-16 12:31:22 +00:00
|
|
|
}
|
2016-03-22 10:30:41 +00:00
|
|
|
start = start+10;
|
2016-03-16 12:31:22 +00:00
|
|
|
}
|
2016-03-22 10:30:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var close_item = function(item, item_name){
|
2016-03-16 12:31:22 +00:00
|
|
|
var args = {
|
|
|
|
project: '{{ doc.name }}',
|
2016-03-22 10:30:41 +00:00
|
|
|
item_name: item_name,
|
|
|
|
}
|
2016-03-16 12:31:22 +00:00
|
|
|
frappe.call({
|
|
|
|
btn: this,
|
|
|
|
type: "POST",
|
2016-03-22 10:30:41 +00:00
|
|
|
method: "erpnext.templates.pages.projects.set_"+ item +"_status",
|
2016-03-16 12:31:22 +00:00
|
|
|
args: args,
|
|
|
|
callback: function(r) {
|
|
|
|
if(r.exc) {
|
|
|
|
if(r._server_messages)
|
|
|
|
frappe.msgprint(r._server_messages);
|
|
|
|
} else {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return false;
|
2016-03-22 10:30:41 +00:00
|
|
|
}
|
2016-03-23 08:44:38 +00:00
|
|
|
});
|