mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 13:49:13 +00:00
[fix] [wip] cleanup for collaborative pm
This commit is contained in:
@@ -30,9 +30,9 @@
|
||||
|
||||
{% block page_content %}
|
||||
|
||||
{% include 'templates/includes/project_search_box.html' %}
|
||||
{% include 'templates/includes/projects/project_search_box.html' %}
|
||||
|
||||
{% if frappe.form_dict.q %}
|
||||
<!-- {% if frappe.form_dict.q %}
|
||||
<p class="text-muted"> <a href="/projects?project={{doc.name}}" class="text-muted">
|
||||
Filtered by "{{ frappe.form_dict.q }}" Clear</a></p>
|
||||
{% else %}
|
||||
@@ -43,56 +43,48 @@
|
||||
{% if doc.timelines|length > 9 %}
|
||||
<p><a class='more-timelines small underline'>{{ _("More") }}</a><p>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endif %} -->
|
||||
|
||||
<div class='padding'></div>
|
||||
|
||||
<h3>{{ _("Tasks") }}</h3>
|
||||
|
||||
<p>
|
||||
<a class='small underline' href='/tasks?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>New task</a>
|
||||
<a class='small underline task-status-switch' data-status='Open'>{{ _("Show closed") }}</a>
|
||||
</p>
|
||||
|
||||
{% if doc.tasks %}
|
||||
<div class='project-tasks-section'>
|
||||
<div>
|
||||
<div class="btn-group btn-toggle">
|
||||
<button class="btn btn-link btn-open-tasks"><span class="indicator orange"></span>Open</button>
|
||||
<button class="btn btn-link btn-closed-tasks"><span class="indicator green"></span>Closed</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class='small underline' href='/tasks?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>New task</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='project-tasks'>
|
||||
<div class='project-task-section'>
|
||||
<div class='project-task'>
|
||||
{% include "erpnext/templates/includes/projects/project_tasks.html" %}
|
||||
</div>
|
||||
<p><a id= 'more-tasks' style='display: none;' class='more-tasks small underline'>{{ _("More") }}</a><p>
|
||||
<p><a id= 'more-task' style='display: none;' class='more-tasks small underline'>{{ _("More") }}</a><p>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted">No tasks</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<div class='padding'></div>
|
||||
<!-- <div class='padding'></div>
|
||||
<h3>{{ _("Issues") }}</h3>
|
||||
|
||||
<p>
|
||||
<a class='small underline' href='/issues?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>New issue</a>
|
||||
<a class='small underline issue-status-switch' data-status='Open'>{{ _("Show closed") }}</a>
|
||||
</p>
|
||||
|
||||
{% if doc.issues %}
|
||||
<div class='project-issues-section'>
|
||||
<div>
|
||||
<div class="btn-group btn-toggle">
|
||||
<button class="btn btn-link btn-open-issues"><span class="indicator red"></span>Open</button>
|
||||
<button class="btn btn-link btn-closed-issues"><span class="indicator green"></span>Closed</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a class='small underline' href='/issues?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>New issue</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='project-issues'>
|
||||
<div class='project-issue-section'>
|
||||
<div class='project-issue'>
|
||||
{% include "erpnext/templates/includes/projects/project_issues.html" %}
|
||||
</div>
|
||||
<p><a id='more-issues' style='display: none;' class='more-issues small underline'>{{ _("More") }}</a><p>
|
||||
<p><a id='more-issue' style='display: none;' class='more-issues small underline'>{{ _("More") }}</a><p>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted">No Issues</p>
|
||||
{% endif %}
|
||||
{% endif %} -->
|
||||
|
||||
<div class='padding'></div>
|
||||
|
||||
|
||||
@@ -1,53 +1,60 @@
|
||||
frappe.ready(function() {
|
||||
$( window ).load(function() {
|
||||
$(".btn-open-tasks").click();
|
||||
$(".btn-open-issues").click();
|
||||
});
|
||||
|
||||
$('.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');
|
||||
});
|
||||
$('.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');
|
||||
// });
|
||||
|
||||
var start = 10;
|
||||
$(".more-tasks").click(function() {
|
||||
more_items('tasks', true);
|
||||
});
|
||||
|
||||
more_items('task', true);
|
||||
});
|
||||
|
||||
$(".more-issues").click(function() {
|
||||
more_items('issues', true);
|
||||
});
|
||||
|
||||
more_items('issue', true);
|
||||
});
|
||||
|
||||
$(".more-timelogs").click(function() {
|
||||
more_items('timelogs', false);
|
||||
});
|
||||
|
||||
more_items('timelog', 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) {
|
||||
more_items('timeline', false);
|
||||
});
|
||||
|
||||
|
||||
var reload_items = function(item_status, item, $btn) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/",
|
||||
@@ -59,25 +66,28 @@ frappe.ready(function() {
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
console.log(data.message);
|
||||
if(typeof data.message == 'undefined') {
|
||||
$('.project-'+ item).html("No "+ item_status +" "+ item);
|
||||
if(typeof data.message == 'undefined') {
|
||||
$('.project-'+ item).html("No "+ item_status +" "+ item);
|
||||
$(".more-"+ item).toggle(false);
|
||||
}
|
||||
$('.project-'+ item).html(data.message);
|
||||
$('.project-'+ item +'-section .btn-group .bold').removeClass('bold');
|
||||
$('.btn-'+ item_status +'-'+ item).addClass( "bold" );
|
||||
$(".more-"+ item).toggle(true);
|
||||
|
||||
// update status
|
||||
if(item_status==='open') {
|
||||
$btn.html(__('Show closed')).attr('data-status', 'Open');
|
||||
} else {
|
||||
$btn.html(__('Show open')).attr('data-status', 'Closed');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
var more_items = function(item, item_status){
|
||||
if(item_status)
|
||||
{
|
||||
var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-closed-'+ item)
|
||||
var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-closed-'+ item)
|
||||
? 'closed' : 'open';
|
||||
}
|
||||
$.ajax({
|
||||
@@ -92,21 +102,21 @@ frappe.ready(function() {
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
|
||||
$(data.message).appendTo('.project-'+ item);
|
||||
if(typeof data.message == 'undefined') {
|
||||
$(".more-"+ item).toggle(false);
|
||||
if(typeof data.message == 'undefined') {
|
||||
$(".more-"+ item).toggle(false);
|
||||
}
|
||||
start = start+10;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var close_item = function(item, item_name){
|
||||
var args = {
|
||||
project: '{{ doc.name }}',
|
||||
item_name: item_name,
|
||||
}
|
||||
}
|
||||
frappe.call({
|
||||
btn: this,
|
||||
type: "POST",
|
||||
|
||||
@@ -15,11 +15,14 @@ def get_context(context):
|
||||
context.issues = frappe.get_all('Issue', filters={'project': project.project_name},
|
||||
fields=['subject', 'opening_date', 'resolution_date', 'status', 'name', 'resolution_details','modified','modified_by'])
|
||||
|
||||
project.tasks = get_tasks(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
project.tasks = get_tasks(project.name, start=0, item_status='open',
|
||||
search=frappe.form_dict.get("q"))
|
||||
|
||||
project.timelogs = get_timelogs(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
project.issues = get_issues(project.name, start=0, item_status='open',
|
||||
search=frappe.form_dict.get("q"))
|
||||
|
||||
project.issues = get_issues(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
project.timelogs = get_timelogs(project.name, start=0,
|
||||
search=frappe.form_dict.get("q"))
|
||||
|
||||
project.timelines = get_timeline(project.project_name, start=0)
|
||||
|
||||
@@ -60,11 +63,15 @@ def get_timeline(project, start=10):
|
||||
@frappe.whitelist()
|
||||
def get_timelines_html(project, start=0):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/timeline.html",
|
||||
{"doc": {"timelines": get_timeline(project, start)}}, is_path=True)
|
||||
{"doc": {
|
||||
"timelines": get_timeline(project, start)}
|
||||
}, is_path=True)
|
||||
|
||||
def get_issue_list(project):
|
||||
return [issue.name for issue in get_issues(project)]
|
||||
|
||||
|
||||
|
||||
def get_tasks(project, start=0, search=None, item_status=None):
|
||||
filters = {"project": project}
|
||||
if search:
|
||||
@@ -72,24 +79,37 @@ def get_tasks(project, start=0, search=None, item_status=None):
|
||||
if item_status:
|
||||
filters["status"] = item_status
|
||||
tasks = frappe.get_all("Task", filters=filters,
|
||||
fields=["name", "subject", "status", "exp_start_date", "exp_end_date", "priority"],
|
||||
fields=["name", "subject", "status", "exp_start_date", "exp_end_date", "priority", "_seen"],
|
||||
limit_start=start, limit_page_length=10)
|
||||
|
||||
for task in tasks:
|
||||
print task._comments
|
||||
task.todo = frappe.get_all('ToDo',filters={'reference_name':task.name, 'reference_type':'Task'},
|
||||
fields=["assigned_by", "owner", "modified", "modified_by"])
|
||||
|
||||
if task.todo:
|
||||
task.todo=task.todo[0]
|
||||
task.todo.user_image = frappe.db.get_value('User', task.todo.owner, 'user_image')
|
||||
|
||||
if task._comments:
|
||||
task.comment_count = len(json.loads(task._comments or "[]"))
|
||||
|
||||
task.css_seen = ''
|
||||
if task._seen:
|
||||
if frappe.session.user in json.loads(task._seen):
|
||||
task.css_seen = 'seen'
|
||||
|
||||
return tasks
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_tasks_html(project, start=0, item_status=None):
|
||||
def get_task_html(project, start=0, item_status=None):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_tasks.html",
|
||||
{"doc": {"tasks": get_tasks(project, start, item_status=item_status)}}, is_path=True)
|
||||
{"doc": {
|
||||
"name": project,
|
||||
"project_name": project,
|
||||
"tasks": get_tasks(project, start, item_status=item_status)}
|
||||
}, is_path=True)
|
||||
|
||||
|
||||
|
||||
|
||||
def get_issues(project, start=0, search=None, item_status=None):
|
||||
@@ -113,9 +133,17 @@ def get_issues(project, start=0, search=None, item_status=None):
|
||||
return issues
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_issues_html(project, start=0, item_status=None):
|
||||
def get_issue_html(project, start=0, item_status=None):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_issues.html",
|
||||
{"doc": {"issues": get_issues(project, start, item_status=item_status)}}, is_path=True)
|
||||
{"doc": {
|
||||
"name": project,
|
||||
"project_name": project,
|
||||
"issues": get_issues(project, start, item_status=item_status)}
|
||||
}, is_path=True)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_timelogs(project, start=0, search=None):
|
||||
filters = {"project": project}
|
||||
@@ -130,19 +158,7 @@ def get_timelogs(project, start=0, search=None):
|
||||
return timelogs
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_timelogs_html(project, start=0):
|
||||
def get_timelog_html(project, start=0):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_timelogs.html",
|
||||
{"doc": {"timelogs": get_timelogs(project, start)}}, is_path=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_task_status(project, item_name):
|
||||
task = frappe.get_doc("Task", item_name)
|
||||
task.status = 'Closed'
|
||||
task.save(ignore_permissions=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_issue_status(project, item_name):
|
||||
issue = frappe.get_doc("Issue", item_name)
|
||||
issue.status = 'Closed'
|
||||
issue.save(ignore_permissions=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user