From 5173e74a041d33d87d4ab3172a4bfc4b64d66381 Mon Sep 17 00:00:00 2001
From: Jannat Patel <31363128+pateljannat@users.noreply.github.com>
Date: Fri, 2 Jul 2021 11:48:46 +0530
Subject: [PATCH] fix: Project Portal Enhancements (#26290)
* fix: project portal enhancements
* fix: condition for pills
---
erpnext/hooks.py | 1 +
.../includes/projects/project_row.html | 80 ++++---
.../includes/projects/project_tasks.html | 33 +--
.../includes/projects/project_timesheets.html | 54 +++--
erpnext/templates/pages/projects.html | 215 ++++++++++++------
erpnext/templates/pages/projects.py | 41 +---
6 files changed, 250 insertions(+), 174 deletions(-)
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 8ad77a1524d..52daec91805 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -157,6 +157,7 @@ website_route_rules = [
"parents": [{"label": _("Material Request"), "route": "material-requests"}]
}
},
+ {"from_route": "/project", "to_route": "Project"}
]
standard_portal_menu_items = [
diff --git a/erpnext/templates/includes/projects/project_row.html b/erpnext/templates/includes/projects/project_row.html
index 4c8c40db003..bfd63494c32 100644
--- a/erpnext/templates/includes/projects/project_row.html
+++ b/erpnext/templates/includes/projects/project_row.html
@@ -1,28 +1,54 @@
-{% if doc.status=="Open" %}
-
+{% if doc.status == "Open" %}
+
+
+
+
Link
+ {{ doc.name }}
+
+
+ {{ doc.project_name }}
+
+
+ {% if doc.percent_complete %}
+ {% set pill_class = "green" if doc.percent_complete | round == 100 else
+ "orange" %}
+
+
+ {{ frappe.utils.cint(doc.percent_complete) }}
+ %
+
+
+ {% else %}
+
+ {{ doc.status }}
+ {% endif %}
+
+ {% if doc["_assign"] %}
+ {% set assigned_users = json.loads(doc["_assign"])%}
+
+ {% for user in assigned_users %}
+ {% set user_details = frappe
+ .db
+ .get_value("User", user, [
+ "full_name", "user_image"
+ ], as_dict = True) %}
+ {% if user_details.user_image %}
+
+
+
+ {% else %}
+
+
+ {{ frappe.utils.get_abbr(user_details.full_name) }}
+
+
+ {% endif %}
+ {% endfor %}
+
+ {% endif %}
+
+ {{ frappe.utils.pretty_date(doc.modified) }}
+
+
+
{% endif %}
diff --git a/erpnext/templates/includes/projects/project_tasks.html b/erpnext/templates/includes/projects/project_tasks.html
index 50b9f4b2597..2b07a5f0d07 100644
--- a/erpnext/templates/includes/projects/project_tasks.html
+++ b/erpnext/templates/includes/projects/project_tasks.html
@@ -1,32 +1,5 @@
{% for task in doc.tasks %}
-
+
+ {{ task_row(task, 0) }}
+
{% endfor %}
diff --git a/erpnext/templates/includes/projects/project_timesheets.html b/erpnext/templates/includes/projects/project_timesheets.html
index 05a07c12e8b..850c5e98631 100644
--- a/erpnext/templates/includes/projects/project_timesheets.html
+++ b/erpnext/templates/includes/projects/project_timesheets.html
@@ -1,23 +1,33 @@
{% for timesheet in doc.timesheets %}
-
-{% endfor %}
\ No newline at end of file
+
+
+
{{ timesheet.name }}
+
Link
+
{{ timesheet.status }}
+
{{ frappe.utils.format_date(timesheet.from_time, "medium") }}
+
{{ frappe.utils.format_date(timesheet.to_time, "medium") }}
+
+ {% set user_details = frappe
+ .db
+ .get_value("User", timesheet.modified_by, [
+ "full_name", "user_image"
+ ], as_dict = True)
+ %}
+ {% if user_details.user_image %}
+
+
+
+ {% else %}
+
+
+ {{ frappe.utils.get_abbr(user_details.full_name) }}
+
+
+ {% endif %}
+
+
+ {{ frappe.utils.pretty_date(timesheet.modified) }}
+
+
+
+{% endfor %}
diff --git a/erpnext/templates/pages/projects.html b/erpnext/templates/pages/projects.html
index 7e294e076b3..76eaf75cf30 100644
--- a/erpnext/templates/pages/projects.html
+++ b/erpnext/templates/pages/projects.html
@@ -1,90 +1,173 @@
{% extends "templates/web.html" %}
-{% block title %}{{ doc.project_name }}{% endblock %}
+{% block title %}
+ {{ doc.project_name }}
+{% endblock %}
+
+{% block head_include %}
+
+{% endblock %}
{% block header %}
- {{ doc.project_name }}
+ {{ doc.project_name }}
{% endblock %}
{% block style %}
-
+
{% endblock %}
-
{% block page_content %}
-{% if doc.percent_complete %}
-
-{% endif %}
-
+ {{ progress_bar(doc.percent_complete) }}
-
-
-
+
+
Status:
+ Progress:
+ {{ doc.percent_complete }}
+ %
+
+ Hours Spent:
+ {{ doc.actual_time }}
+
+
-{% if doc.tasks %}
-
-
- {% include "erpnext/templates/includes/projects/project_tasks.html" %}
-
-
{{ _("More") }}
-
-{% else %}
- {{ _("No tasks") }}
-{% endif %}
+ {{ progress_bar(doc.percent_complete) }}
+ {% if doc.tasks %}
+
+
+
+
+
Tasks
+
Status
+
End Date
+
Assigned To
+
+
+
+ {% include "erpnext/templates/includes/projects/project_tasks.html" %}
+
+
+ {% else %}
+ {{ _("No Tasks") }}
+ {% endif %}
-
+ {% if doc.timesheets %}
+
+
+
+
+
Timesheets
+ Status
+ From
+ To
+ Modified By
+ Modified On
+
+
+ {% include "erpnext/templates/includes/projects/project_timesheets.html" %}
+
+
+ {% else %}
+ {{ _("No Timesheets") }}
+ {% endif %}
-{{ _("Timesheets") }}
+ {% if doc.attachments %}
+
-{% if doc.timesheets %}
-
- {% include "erpnext/templates/includes/projects/project_timesheets.html" %}
-
- {% if doc.timesheets|length > 9 %}
- {{ _("More") }}
- {% endif %}
-{% else %}
-
{{ _("No time sheets") }}
-{% endif %}
-
-{% if doc.attachments %}
-
-
-{{ _("Attachments") }}
-
- {% for attachment in doc.attachments %}
-
- {% endfor %}
-
-{% endif %}
+ {{ _("Attachments") }}
+
+ {% for attachment in doc.attachments %}
+
+ {% endfor %}
+
+ {% endif %}
{% endblock %}
+
+{% macro progress_bar(percent_complete) %}
+{% if percent_complete %}
+
+{% else %}
+
+{% endif %}
+{% endmacro %}
+
+{% macro task_row(task, indent) %}
+
+
+
{{ task.status }}
+
+ {% if task.exp_end_date %}
+ {{ task.exp_end_date }}
+ {% else %}
+ --
+ {% endif %}
+
+
+ {% if task["_assign"] %}
+ {% set assigned_users = json.loads(task["_assign"])%}
+ {% for user in assigned_users %}
+ {% set user_details = frappe.db.get_value("User", user,
+ ["full_name", "user_image"],
+ as_dict = True)%}
+ {% if user_details.user_image %}
+
+
+
+ {% else %}
+
+
+ {{ frappe.utils.get_abbr(user_details.full_name) }}
+
+
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+
+
+ {{ frappe.utils.pretty_date(task.modified) }}
+
+
+{% if task.children %}
+ {% for child in task.children %}
+ {{ task_row(child, indent + 30) }}
+ {% endfor %}
+{% endif %}
+{% endmacro %}
diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py
index d23fed9e7d1..b369cb6a991 100644
--- a/erpnext/templates/pages/projects.py
+++ b/erpnext/templates/pages/projects.py
@@ -35,26 +35,16 @@ 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", "_seen", "_comments", "modified", "description"],
+ fields=["name", "subject", "status", "modified", "_assign", "exp_end_date", "is_group", "parent_task"],
limit_start=start, limit_page_length=10)
-
+ task_nest = []
for task in tasks:
- 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')
-
-
- 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
+ if task.is_group:
+ child_tasks = list(filter(lambda x: x.parent_task == task.name, tasks))
+ if len(child_tasks):
+ task.children = child_tasks
+ task_nest.append(task)
+ return list(filter(lambda x: not x.parent_task, tasks))
@frappe.whitelist()
def get_task_html(project, start=0, item_status=None):
@@ -74,19 +64,12 @@ def get_timesheets(project, start=0, search=None):
fields=['project','activity_type','from_time','to_time','parent'],
limit_start=start, limit_page_length=10)
for timesheet in timesheets:
- timesheet.infos = frappe.get_all('Timesheet', filters={"name": timesheet.parent},
- fields=['name','_comments','_seen','status','modified','modified_by'],
+ info = frappe.get_all('Timesheet', filters={"name": timesheet.parent},
+ fields=['name','status','modified','modified_by'],
limit_start=start, limit_page_length=10)
- for timesheet.info in timesheet.infos:
- timesheet.info.user_image = frappe.db.get_value('User', timesheet.info.modified_by, 'user_image')
-
- timesheet.info.comment_count = len(json.loads(timesheet.info._comments or "[]"))
-
- timesheet.info.css_seen = ''
- if timesheet.info._seen:
- if frappe.session.user in json.loads(timesheet.info._seen):
- timesheet.info.css_seen = 'seen'
+ if len(info):
+ timesheet.update(info[0])
return timesheets
@frappe.whitelist()