2016-03-16 12:31:22 +00:00
|
|
|
frappe.ready(function() {
|
2016-03-22 10:30:41 +00:00
|
|
|
|
2016-03-25 11:49:28 +00:00
|
|
|
$('.task-status-switch').on('click', function() {
|
|
|
|
var $btn = $(this);
|
|
|
|
if($btn.attr('data-status')==='Open') {
|
|
|
|
reload_items('closed', 'task', $btn);
|
|
|
|
} else {
|
|
|
|
reload_items('open', 'task', $btn);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
$('.issue-status-switch').on('click', function() {
|
|
|
|
var $btn = $(this);
|
|
|
|
if($btn.attr('data-status')==='Open') {
|
|
|
|
reload_items('closed', 'issue', $btn);
|
|
|
|
} else {
|
|
|
|
reload_items('open', 'issue', $btn);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
//
|
|
|
|
// $('.btn-closed-tasks').click(function() {
|
|
|
|
// reload_items('closed','tasks');
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// $('.btn-open-tasks').click(function() {
|
|
|
|
// reload_items('open','tasks');
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// $('.btn-closed-issues').click(function() {
|
|
|
|
// reload_items('closed','issues');
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// $('.btn-open-issues').click(function() {
|
|
|
|
// 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-25 11:49:28 +00:00
|
|
|
more_items('task', true);
|
|
|
|
});
|
|
|
|
|
2016-03-16 12:31:22 +00:00
|
|
|
$(".more-issues").click(function() {
|
2016-03-25 11:49:28 +00:00
|
|
|
more_items('issue', true);
|
|
|
|
});
|
|
|
|
|
2016-03-16 12:31:22 +00:00
|
|
|
$(".more-timelogs").click(function() {
|
2016-03-25 11:49:28 +00:00
|
|
|
more_items('timelog', false);
|
|
|
|
});
|
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
$(".more-timelines").click(function() {
|
2016-03-25 11:49:28 +00:00
|
|
|
more_items('timeline', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var reload_items = function(item_status, item, $btn) {
|
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-25 11:49:28 +00:00
|
|
|
if(typeof data.message == 'undefined') {
|
|
|
|
$('.project-'+ item).html("No "+ item_status +" "+ item);
|
2016-03-25 06:34:54 +00:00
|
|
|
$(".more-"+ item).toggle(false);
|
|
|
|
}
|
2016-03-22 10:30:41 +00:00
|
|
|
$('.project-'+ item).html(data.message);
|
|
|
|
$(".more-"+ item).toggle(true);
|
2016-03-25 11:49:28 +00:00
|
|
|
|
|
|
|
// update status
|
|
|
|
if(item_status==='open') {
|
|
|
|
$btn.html(__('Show closed')).attr('data-status', 'Open');
|
|
|
|
} else {
|
|
|
|
$btn.html(__('Show open')).attr('data-status', 'Closed');
|
|
|
|
}
|
2016-03-16 12:31:22 +00:00
|
|
|
}
|
2016-03-25 11:49:28 +00:00
|
|
|
});
|
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
}
|
2016-03-25 11:49:28 +00:00
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
var more_items = function(item, item_status){
|
|
|
|
if(item_status)
|
|
|
|
{
|
2016-03-25 11:49:28 +00:00
|
|
|
var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-closed-'+ item)
|
2016-03-22 10:30:41 +00:00
|
|
|
? '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-25 11:49:28 +00:00
|
|
|
|
2016-03-22 10:30:41 +00:00
|
|
|
$(data.message).appendTo('.project-'+ item);
|
2016-03-25 11:49:28 +00:00
|
|
|
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-25 11:49:28 +00:00
|
|
|
});
|
2016-03-22 10:30:41 +00:00
|
|
|
}
|
2016-03-25 11:49:28 +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-25 11:49:28 +00:00
|
|
|
}
|
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
|
|
|
});
|