[feature] added team updates page
This commit is contained in:
parent
d9a265fab1
commit
7ec4b717ed
@ -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"),
|
||||
|
0
erpnext/hr/page/team_updates/__init__.py
Normal file
0
erpnext/hr/page/team_updates/__init__.py
Normal file
15
erpnext/hr/page/team_updates/team_update_row.html
Normal file
15
erpnext/hr/page/team_updates/team_update_row.html
Normal file
@ -0,0 +1,15 @@
|
||||
<div class="row activity-row" data-creation="{%= creation.split(" ")[0] + " 00:00:00" %}">
|
||||
<div class="col-xs-3 text-right activity-date"><span class="{%= date_class %}">
|
||||
{%= date_sep || "" %}</span></div>
|
||||
<div class="col-xs-9 activity-message"
|
||||
title="{%= by %} / {%= dateutil.str_to_user(creation) %}">
|
||||
<div class="row">
|
||||
<div class="col-xs-2 col-sm-1">
|
||||
{{ avatar }}
|
||||
</div>
|
||||
<div class="col-xs-10 col-sm-11 small" style="padding-top: 5px;">
|
||||
{{ content }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
41
erpnext/hr/page/team_updates/team_updates.css
Normal file
41
erpnext/hr/page/team_updates/team_updates.css
Normal file
@ -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;
|
||||
}
|
79
erpnext/hr/page/team_updates/team_updates.js
Normal file
79
erpnext/hr/page/team_updates/team_updates.js
Normal file
@ -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 = $('<div></div>').appendTo(me.page.main);
|
||||
me.more = $('<div class="for-more"><button class="btn btn-sm btn-default btn-more">'
|
||||
+ __("More") + '</button></div>').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)
|
||||
}
|
||||
}
|
25
erpnext/hr/page/team_updates/team_updates.json
Normal file
25
erpnext/hr/page/team_updates/team_updates.json
Normal file
@ -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"
|
||||
}
|
21
erpnext/hr/page/team_updates/team_updates.py
Normal file
21
erpnext/hr/page/team_updates/team_updates.py
Normal file
@ -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
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user