[enhancement] activity summary in projects
This commit is contained in:
parent
863cb12426
commit
360b05f0f5
@ -43,11 +43,32 @@ frappe.ui.form.on("Project", {
|
||||
});
|
||||
}
|
||||
|
||||
frm.trigger('show_dashboard');
|
||||
}
|
||||
},
|
||||
show_dashboard: function(frm) {
|
||||
frm.dashboard.show_heatmap = true;
|
||||
frm.dashboard.heatmap_message = __('This is based on the Time Logs created against this project');
|
||||
frm.dashboard.show_dashboard();
|
||||
}
|
||||
|
||||
if(frm.doc.__onload.activity_summary.length) {
|
||||
var hours = $.map(frm.doc.__onload.activity_summary, function(d) { return d.total_hours });
|
||||
var max_count = Math.max.apply(null, hours);
|
||||
var sum = hours.reduce(function(a, b) { return a + b; }, 0);
|
||||
var section = frm.dashboard.add_section(
|
||||
frappe.render_template('project_dashboard',
|
||||
{
|
||||
data: frm.doc.__onload.activity_summary,
|
||||
max_count: max_count,
|
||||
sum: sum
|
||||
}));
|
||||
|
||||
section.on('click', '.time-log-link', function() {
|
||||
var activity_type = $(this).attr('data-activity_type');
|
||||
frappe.set_route('List', 'Time Log',
|
||||
{'activity_type': activity_type, 'project': frm.doc.name});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -27,6 +27,8 @@ class Project(Document):
|
||||
})
|
||||
|
||||
self.set_onload('links', self.meta.get_links_setup())
|
||||
self.set_onload('activity_summary', frappe.db.sql('''select activity_type, sum(hours) as total_hours
|
||||
from `tabTime Log` where project=%s group by activity_type order by total_hours desc''', self.name, as_dict=True))
|
||||
|
||||
def __setup__(self):
|
||||
self.onload()
|
||||
|
@ -1,10 +1,26 @@
|
||||
<h5 style="margin-top: 0px;">Tasks</h5>
|
||||
{% if(project.tasks.length) { %}
|
||||
{% project.tasks.forEach(function(d) { %}
|
||||
<p><span class="indicator {{
|
||||
{"Open": "red", "Closed": "green", "Cancelled": "darkgrey"}[d.status] || "orange" }}"><a style="font-weight: normal"
|
||||
href="#Form/Task/{{ d.task_id }}">{{ d.title }}</a></span></p>
|
||||
{% }); %}
|
||||
{% } else { %}
|
||||
<p class="text-muted small">No Tasks Defined</p>
|
||||
{% } %}
|
||||
<h5 style="margin-top: 0px;">Activity Summary</h5>
|
||||
<h6 style="margin-bottom: 25px;">{{ __("Total hours: {0}", [flt(sum, 2) ]) }}</h6>
|
||||
{% for d in data %}
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<a class="small time-log-link" data-activity_type="{{ d.activity_type || "" }}">
|
||||
{{ d.activity_type || __("Unknown") }}</a>
|
||||
</div>
|
||||
<div class="col-xs-8">
|
||||
<span class="inline-graph">
|
||||
<span class="inline-graph-half">
|
||||
</span>
|
||||
<span class="inline-graph-half" title="{{ __("hours") }}">
|
||||
<span class="inline-graph-count">
|
||||
{{ __("{0} hours", [flt(d.total_hours, 2)]) }}
|
||||
</span>
|
||||
<span class="inline-graph-bar">
|
||||
<span class="inline-graph-bar-inner dark"
|
||||
style="width: {{ cint(d.total_hours/max_count * 100) }}%">
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
Loading…
Reference in New Issue
Block a user