show assigned to others list in todo

This commit is contained in:
Anand Doshi 2012-06-12 19:24:12 +05:30
parent 4f4f58293f
commit 64ddb9f069
4 changed files with 69 additions and 25 deletions

View File

@ -1,8 +1,6 @@
.todoitem { .todoitem {
padding-bottom: 11px; padding-bottom: 3px;
border-bottom: 1px solid #DEB85F; min-height: 45px;
margin-bottom: 5px;
height: 14px;
clear: both; clear: both;
} }
@ -10,23 +8,42 @@
width: 50px; width: 50px;
display: inline-block; display: inline-block;
text-align: center; text-align: center;
margin-right: 7px; margin-right: 11px;
margin-top: 3px;
float: left;
} }
.todoitem .close { .todoitem .close {
margin-left: 14px; margin-left: 14px;
font-size: 14px; font-size: 17px;
float: left; }
.todoitem .close-span {
display: inline-block;
float: right;
} }
.todoitem .ref_link { .todoitem .ref_link {
float: left;
margin-left: 10px;
display: inline-block;
line-height: 18px; line-height: 18px;
} }
.todoitem .description { .todoitem .description {
cursor: pointer; cursor: pointer;
float: left; padding: 3px 0px;
display: inline-block;
} }
#todo-list, #assigned-todo-list {
float: left;
width: 50%;
}
.todo-separator {
border-bottom: 1px solid #DEB85F;
margin-bottom: 5px;
clear: both;
}
.todo-content {
padding-right: 15px;
}

View File

@ -2,7 +2,15 @@
<a class="close" onclick="window.history.back();">&times;</a> <a class="close" onclick="window.history.back();">&times;</a>
<h1>To Do</h1> <h1>To Do</h1>
<br> <br>
<div id="todo-list"> <div>
<div id="todo-list">
<h4>My List</h4><br>
<div class="todo-content"></div>
</div>
<div id="assigned-todo-list">
<h4>Assigned to others</h4><br>
<div class="todo-content"></div>
</div>
</div> </div>
<div style="margin-top: 21px; clear: both"> <div style="margin-top: 21px; clear: both">
<button id="add-todo" class="btn btn-small"><i class="icon-plus"></i> Add</button> <button id="add-todo" class="btn btn-small"><i class="icon-plus"></i> Add</button>

View File

@ -20,7 +20,8 @@ erpnext.todo.refresh = function() {
wn.call({ wn.call({
method: 'utilities.page.todo.todo.get', method: 'utilities.page.todo.todo.get',
callback: function(r,rt) { callback: function(r,rt) {
$('#todo-list').empty(); $('#todo-list div.todo-content').empty();
$('#assigned-todo-list div.todo-content').empty();
if(r.message) { if(r.message) {
for(var i in r.message) { for(var i in r.message) {
new erpnext.todo.ToDoItem(r.message[i]); new erpnext.todo.ToDoItem(r.message[i]);
@ -46,11 +47,23 @@ erpnext.todo.ToDoItem = Class.extend({
} }
todo.labelclass = label_map[todo.priority]; todo.labelclass = label_map[todo.priority];
todo.userdate = dateutil.str_to_user(todo.date) || ''; todo.userdate = dateutil.str_to_user(todo.date) || '';
todo.fullname = '';
if(todo.assigned_by) { if(todo.assigned_by) {
todo.fullname = repl("[By %(fullname)s] ", { todo.fullname = repl("[By %(fullname)s] ", {
fullname: wn.boot.user_info[todo.assigned_by].fullname fullname: wn.boot.user_info[todo.assigned_by].fullname
}) });
} else { todo.fullname = ''; } }
var parent_list = "#todo-list";
if(todo.owner !== user) {
parent_list = "#assigned-todo-list";
todo.fullname = repl("[To %(fullname)s] ", {
fullname: wn.boot.user_info[todo.owner].fullname
});
}
parent_list += " div.todo-content";
if(todo.reference_name && todo.reference_type) { if(todo.reference_name && todo.reference_type) {
todo.link = repl('<a href="#!Form/%(reference_type)s/%(reference_name)s">\ todo.link = repl('<a href="#!Form/%(reference_type)s/%(reference_name)s">\
%(reference_type)s: %(reference_name)s</a>', todo); %(reference_type)s: %(reference_name)s</a>', todo);
@ -61,16 +74,22 @@ erpnext.todo.ToDoItem = Class.extend({
todo.link = ''; todo.link = '';
} }
if(!todo.description) todo.description = ''; if(!todo.description) todo.description = '';
$('#todo-list').append(repl('<div class="todoitem">\
todo.desc = todo.description.replace(/\n/g, "<br>");
$(parent_list).append(repl('\
<div class="todoitem">\
<span class="label %(labelclass)s">%(priority)s</span>\
<span class="description">\ <span class="description">\
<span class="label %(labelclass)s">%(priority)s</span>\
<span class="help" style="margin-right: 7px">%(userdate)s</span>\ <span class="help" style="margin-right: 7px">%(userdate)s</span>\
%(fullname)s%(description)s</span>\ %(fullname)s%(desc)s\
<span class="ref_link">&rarr; &nbsp;\ <span class="ref_link"><br>\
%(link)s</span>\ %(link)s</span>\
<a href="#" class="close">&times;</a>\ </span>\
</div>', todo)); <span class="close-span"><a href="#" class="close">&times;</a></span>\
$todo = $('div.todoitem:last'); </div>\
<div class="todo-separator"></div>', todo));
$todo = $(parent_list + ' div.todoitem:last');
if(todo.checked) { if(todo.checked) {
$todo.find('.description').css('text-decoration', 'line-through'); $todo.find('.description').css('text-decoration', 'line-through');

View File

@ -22,9 +22,9 @@ def get(arg=None):
"""get todo list""" """get todo list"""
return webnotes.conn.sql("""select name, owner, description, date, return webnotes.conn.sql("""select name, owner, description, date,
priority, checked, reference_type, reference_name, assigned_by priority, checked, reference_type, reference_name, assigned_by
from `tabToDo` where owner=%s from `tabToDo` where (owner=%s or assigned_by=%s)
order by field(priority, 'High', 'Medium', 'Low') asc, date asc""", order by field(priority, 'High', 'Medium', 'Low') asc, date asc""",
webnotes.session['user'], as_dict=1) (webnotes.session['user'], webnotes.session['user']), as_dict=1)
@webnotes.whitelist() @webnotes.whitelist()
def edit(arg=None): def edit(arg=None):
@ -35,7 +35,7 @@ def edit(arg=None):
d.date = args['date'] d.date = args['date']
d.priority = args['priority'] d.priority = args['priority']
d.checked = args.get('checked', 0) d.checked = args.get('checked', 0)
d.owner = webnotes.session['user'] if not d.owner: d.owner = webnotes.session['user']
d.save(not args.get('name') and 1 or 0) d.save(not args.get('name') and 1 or 0)
if args.get('name') and d.checked: if args.get('name') and d.checked: