From 7ec4b717edb534e6975c638b7e7b83cb60de21a4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 31 Jan 2017 11:42:44 +0530 Subject: [PATCH] [feature] added team updates page --- erpnext/config/hr.py | 9 ++- erpnext/hr/page/team_updates/__init__.py | 0 .../hr/page/team_updates/team_update_row.html | 15 ++++ erpnext/hr/page/team_updates/team_updates.css | 41 ++++++++++ erpnext/hr/page/team_updates/team_updates.js | 79 +++++++++++++++++++ .../hr/page/team_updates/team_updates.json | 25 ++++++ erpnext/hr/page/team_updates/team_updates.py | 21 +++++ erpnext/stock/doctype/item/item.json | 11 +-- 8 files changed, 190 insertions(+), 11 deletions(-) create mode 100644 erpnext/hr/page/team_updates/__init__.py create mode 100644 erpnext/hr/page/team_updates/team_update_row.html create mode 100644 erpnext/hr/page/team_updates/team_updates.css create mode 100644 erpnext/hr/page/team_updates/team_updates.js create mode 100644 erpnext/hr/page/team_updates/team_updates.json create mode 100644 erpnext/hr/page/team_updates/team_updates.py diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py index 366d771bb0..0a969ed263 100644 --- a/erpnext/config/hr.py +++ b/erpnext/config/hr.py @@ -146,6 +146,11 @@ def get_data(): "name": "Appraisal Template", "description": _("Template for performance appraisals.") }, + { + "type": "page", + "name": "team-updates", + "label": _("Team Updates") + }, ] }, @@ -166,7 +171,7 @@ def get_data(): }, ] }, - + { "label": _("Fleet Management"), "items": [ @@ -180,7 +185,7 @@ def get_data(): }, ] }, - + { "label": _("Setup"), diff --git a/erpnext/hr/page/team_updates/__init__.py b/erpnext/hr/page/team_updates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/hr/page/team_updates/team_update_row.html b/erpnext/hr/page/team_updates/team_update_row.html new file mode 100644 index 0000000000..c81a4cb95f --- /dev/null +++ b/erpnext/hr/page/team_updates/team_update_row.html @@ -0,0 +1,15 @@ +
+
+ {%= date_sep || "" %}
+
+
+
+ {{ avatar }} +
+
+ {{ content }} +
+
+
+
diff --git a/erpnext/hr/page/team_updates/team_updates.css b/erpnext/hr/page/team_updates/team_updates.css new file mode 100644 index 0000000000..7f6a40a05b --- /dev/null +++ b/erpnext/hr/page/team_updates/team_updates.css @@ -0,0 +1,41 @@ +.date-indicator { + background:none; + font-size:12px; + vertical-align:middle; + font-weight:bold; + color:#6c7680; +} +.date-indicator::after { + margin:0 -4px 0 12px; + content:''; + display:inline-block; + height:8px; + width:8px; + border-radius:8px; + background: #d1d8dd; +} + +.date-indicator.blue { + color: #5e64ff; +} + +.date-indicator.blue::after { + background: #5e64ff; +} + +.activity-message { + border-left: 1px solid #d1d8dd; + padding: 15px; + padding-right: 30px; +} + +.activity-date { + padding: 15px; + padding-right: 0px; + z-index: 1; +} + +.for-more { + border-top: 1px solid #d1d8dd; + padding: 10px; +} diff --git a/erpnext/hr/page/team_updates/team_updates.js b/erpnext/hr/page/team_updates/team_updates.js new file mode 100644 index 0000000000..e701b5fb9c --- /dev/null +++ b/erpnext/hr/page/team_updates/team_updates.js @@ -0,0 +1,79 @@ +frappe.pages['team-updates'].on_page_load = function(wrapper) { + var page = frappe.ui.make_app_page({ + parent: wrapper, + title: __('Team Updates'), + single_column: true + }); + + frappe.team_updates.make(page); + frappe.team_updates.run(); + + if(frappe.model.can_read('Daily Work Summary Settings')) { + page.add_menu_item(__('Daily Work Summary Settings'), function() { + frappe.set_route('Form', 'Daily Work Summary Settings'); + }); + } +} + +frappe.team_updates = { + start: 0, + make: function(page) { + var me = frappe.team_updates; + me.page = page; + me.body = $('
').appendTo(me.page.main); + me.more = $('
').appendTo(me.page.main) + .find('.btn-more').on('click', function() { + me.start += 40; + me.run(); + }); + }, + run: function() { + var me = frappe.team_updates; + frappe.call({ + method: 'erpnext.hr.page.team_updates.team_updates.get_data', + args: { + start: me.start + }, + callback: function(r) { + if(r.message) { + r.message.forEach(function(d) { + me.add_row(d); + }); + } else { + frappe.show_alert({message:__('No more updates'), indicator:'darkgrey'}); + me.more.parent().addClass('hidden'); + } + } + }); + }, + add_row: function(data) { + var me = frappe.team_updates; + + data.by = frappe.user.full_name(data.sender); + data.avatar = frappe.avatar(data.sender); + data.when = comment_when(data.creation); + + var date = dateutil.str_to_obj(data.creation); + var last = me.last_feed_date; + + if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) { + var diff = dateutil.get_day_diff(dateutil.get_today(), dateutil.obj_to_str(date)); + if(diff < 1) { + pdate = 'Today'; + } else if(diff < 2) { + pdate = 'Yesterday'; + } else { + pdate = dateutil.global_date_format(date); + } + data.date_sep = pdate; + data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator"; + } else { + data.date_sep = null; + data.date_class = ""; + } + me.last_feed_date = date; + + $(frappe.render_template('team_update_row', data)).appendTo(me.body) + } +} \ No newline at end of file diff --git a/erpnext/hr/page/team_updates/team_updates.json b/erpnext/hr/page/team_updates/team_updates.json new file mode 100644 index 0000000000..167c67fb4e --- /dev/null +++ b/erpnext/hr/page/team_updates/team_updates.json @@ -0,0 +1,25 @@ +{ + "content": null, + "creation": "2017-01-31 11:02:31.614045", + "docstatus": 0, + "doctype": "Page", + "idx": 0, + "modified": "2017-01-31 11:25:01.983200", + "modified_by": "Administrator", + "module": "HR", + "name": "team-updates", + "owner": "Administrator", + "page_name": "team-updates", + "roles": [ + { + "role": "Employee" + }, + { + "role": "System Manager" + } + ], + "script": null, + "standard": "Yes", + "style": null, + "title": "Team Updates" +} \ No newline at end of file diff --git a/erpnext/hr/page/team_updates/team_updates.py b/erpnext/hr/page/team_updates/team_updates.py new file mode 100644 index 0000000000..5b90f6ff2d --- /dev/null +++ b/erpnext/hr/page/team_updates/team_updates.py @@ -0,0 +1,21 @@ +from __future__ import unicode_literals + +import frappe +from email_reply_parser import EmailReplyParser +from markdown2 import markdown + +@frappe.whitelist() +def get_data(start=0): + #frappe.only_for('Employee', 'System Manager') + data = frappe.get_all('Communication', + fields=('content', 'text_content', 'sender', 'creation'), + filters=dict(reference_doctype='Daily Work Summary'), + order_by='creation desc', limit=40, start=start) + + for d in data: + d.sender_name = frappe.db.get_value("Employee", {"user_id": d.sender}, + "employee_name") or d.sender + if d.text_content: + d.content = markdown(EmailReplyParser.parse_reply(d.text_content)) + + return data \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 316d35bc07..5748a93d2d 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -2713,7 +2713,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2017-01-18 17:43:20.262925", + "modified": "2017-01-30 17:25:46.211995", "modified_by": "Administrator", "module": "Stock", "name": "Item", @@ -2729,7 +2729,6 @@ "export": 0, "if_owner": 0, "import": 1, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -2750,7 +2749,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -2771,7 +2769,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 1, "read": 1, @@ -2792,7 +2789,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -2813,7 +2809,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -2834,7 +2829,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -2855,7 +2849,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -2876,7 +2869,6 @@ "export": 0, "if_owner": 0, "import": 0, - "is_custom": 0, "permlevel": 0, "print": 0, "read": 1, @@ -2895,5 +2887,6 @@ "sort_field": "idx desc, modified desc", "sort_order": "DESC", "title_field": "item_name", + "track_changes": 1, "track_seen": 0 } \ No newline at end of file