[fix] [wip] cleanup for collaborative pm
diff --git a/erpnext/templates/includes/projects.css b/erpnext/templates/includes/projects.css
index eede4e2..99ec4c8 100644
--- a/erpnext/templates/includes/projects.css
+++ b/erpnext/templates/includes/projects.css
@@ -13,6 +13,18 @@
padding-bottom: 5px;
}
+#project-search {
+ border: none;
+}
+
+.task-link {
+ font-weight: bold;
+}
+
+.task-link.seen {
+ font-weight: normal;
+}
+
.row-header {
font-size: 14px;
font-weight: 500;
@@ -136,7 +148,7 @@
color: #fff;
}
-
+
.timeline-centered .timeline-entry .timeline-entry-inner .timeline-label {
position: relative;
background: #f5f5f6;
diff --git a/erpnext/templates/includes/projects/macros.html b/erpnext/templates/includes/projects/macros.html
index a4abc94..5b22583 100644
--- a/erpnext/templates/includes/projects/macros.html
+++ b/erpnext/templates/includes/projects/macros.html
@@ -1,2 +1,2 @@
-{% macro back_link(doc) %}&back-to=/projects?project={{ doc.name }}|{{ doc.project_name }}{% endmacro %}
+{% macro back_link(doc) %}&back-to=/projects?project={{ doc.name }}&back-to-title={{ doc.project_name }}{% endmacro %}
diff --git a/erpnext/templates/includes/projects/project_issues.html b/erpnext/templates/includes/projects/project_issues.html
index 5f9d26f..f8924f5 100644
--- a/erpnext/templates/includes/projects/project_issues.html
+++ b/erpnext/templates/includes/projects/project_issues.html
@@ -4,7 +4,7 @@
<div class='issue'>
<div class='row project-item'>
<div class='col-xs-9'>
- <a class="no-decoration" href="/issues-view?name={{ issue.name}}{{ back_link(doc) }}">
+ <a class="no-decoration" href="/issues?name={{ issue.name}}{{ back_link(doc) }}">
<span class="indicator {{ "red" if issue.status=="Open" else "green" }}">
{% if issue.status == "Closed" %}
{{ issue.subject }} resolved {{ frappe.utils.pretty_date(issue.resolution_date) }}
diff --git a/erpnext/templates/includes/project_search_box.html b/erpnext/templates/includes/projects/project_search_box.html
similarity index 70%
rename from erpnext/templates/includes/project_search_box.html
rename to erpnext/templates/includes/projects/project_search_box.html
index 8788fcd..59ebaa4 100644
--- a/erpnext/templates/includes/project_search_box.html
+++ b/erpnext/templates/includes/projects/project_search_box.html
@@ -1,7 +1,8 @@
<div class="project-search">
<input type="text" id="project-search"
- placeholder="Search..."><span style="position:relative;
- left:-19px;"> <a href="/projects?project={{doc.name}}" class="octicon octicon-x text-extra-muted" title="Clear" ></a> </span>
+ placeholder="Search...">
+ <span style="position:relative;
+ left:-19px;"> <a href="/projects?project={{doc.name}}" class="octicon octicon-x text-extra-muted" title="Clear" ></a> </span>
</div>
<script>
diff --git a/erpnext/templates/includes/projects/project_tasks.html b/erpnext/templates/includes/projects/project_tasks.html
index 78cd9b6..3db5a68 100644
--- a/erpnext/templates/includes/projects/project_tasks.html
+++ b/erpnext/templates/includes/projects/project_tasks.html
@@ -4,23 +4,20 @@
<div class='task'>
<div class='row project-item'>
<div class='col-xs-9'>
- <a class="no-decoration" href="/tasks?name={{ task.name }}{{ back_link(doc) }}">
- <span class="indicator {{ "orange" if task.status=="Open" else "green" }}">
- {% if task.status == "Closed" %}
- {{ task.subject }} completed on {{ task.closing_date }}
- {% else %}
- {{ task.subject }}
- {% endif %}
- </span>
- </a>
- </div>
- <div class='col-xs-3'>
- <div class='pull-right'>
- {% if task.todo %} <span class="avatar avatar-small" title="{{ task.todo.owner }}"> <img src="{{ task.todo.user_image }}"></span>
+ {% if task.todo %}
+ <span class="avatar avatar-small" title="{{ task.todo.owner }}">
+ <img src="{{ task.todo.user_image }}">
+ </span>
+ {% else %}
+ <span class="avatar avatar-small avatar-empty"></span>
+ {% endif %}
+ <a class="no-decoration task-link {{ task.css_seen }}" href="/tasks?name={{ task.name }}{{ back_link(doc) }}">
+ {% if task.status == "Closed" %}
+ {{ task.subject }} completed on {{ task.closing_date }}
{% else %}
- <span class="avatar avatar-small avatar-empty"></span>
+ {{ task.subject }}
{% endif %}
- </div>
+ </a>
</div>
</div>
</div>
diff --git a/erpnext/templates/pages/projects.html b/erpnext/templates/pages/projects.html
index e32f562..fef79ce 100644
--- a/erpnext/templates/pages/projects.html
+++ b/erpnext/templates/pages/projects.html
@@ -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>
diff --git a/erpnext/templates/pages/projects.js b/erpnext/templates/pages/projects.js
index 0a296af..a0e0ee0 100644
--- a/erpnext/templates/pages/projects.js
+++ b/erpnext/templates/pages/projects.js
@@ -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 @@
},
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 @@
},
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",
diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py
index 39648e3..c2cb6c7 100644
--- a/erpnext/templates/pages/projects.py
+++ b/erpnext/templates/pages/projects.py
@@ -15,11 +15,14 @@
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 @@
@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 @@
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 @@
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 @@
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)
-