@@ -5,6 +5,26 @@ frappe.listview_settings['ToDo'] = { | |||||
"status": "Open" | "status": "Open" | ||||
}; | }; | ||||
me.page.set_title(__("To Do")); | me.page.set_title(__("To Do")); | ||||
}, | |||||
refresh: function(me) { | |||||
// override assigned to me by owner | |||||
me.page.sidebar.find(".assigned-to-me a").off("click").on("click", function() { | |||||
var assign_filter = me.filter_list.get_filter("assigned_by"); | |||||
assign_filter && assign_filter.remove(true); | |||||
me.filter_list.add_filter(me.doctype, "owner", '=', user); | |||||
me.run(); | |||||
}); | |||||
// add assigned by me | |||||
me.page.add_sidebar_item(__("Assigned By Me"), function() { | |||||
var assign_filter = me.filter_list.get_filter("owner"); | |||||
assign_filter && assign_filter.remove(true); | |||||
me.filter_list.add_filter(me.doctype, "assigned_by", '=', user); | |||||
me.run(); | |||||
}, ".assigned-to-me"); | |||||
}, | }, | ||||
add_fields: ["reference_type", "reference_name"], | add_fields: ["reference_type", "reference_name"], | ||||
} | } |
@@ -121,7 +121,14 @@ class FormMeta(Meta): | |||||
df.search_fields = map(lambda sf: sf.strip(), search_fields.split(",")) | df.search_fields = map(lambda sf: sf.strip(), search_fields.split(",")) | ||||
def add_linked_with(self): | def add_linked_with(self): | ||||
"""add list of doctypes this doctype is 'linked' with""" | |||||
"""add list of doctypes this doctype is 'linked' with. | |||||
Example, for Customer: | |||||
{"Address": {"fieldname": "customer"}..} | |||||
""" | |||||
# find fields where this doctype is linked | |||||
links = frappe.db.sql("""select parent, fieldname from tabDocField | links = frappe.db.sql("""select parent, fieldname from tabDocField | ||||
where (fieldtype="Link" and options=%s) | where (fieldtype="Link" and options=%s) | ||||
or (fieldtype="Select" and options=%s)""", (self.name, "link:"+ self.name)) | or (fieldtype="Select" and options=%s)""", (self.name, "link:"+ self.name)) | ||||
@@ -137,15 +144,17 @@ class FormMeta(Meta): | |||||
ret[dt] = { "fieldname": links[dt] } | ret[dt] = { "fieldname": links[dt] } | ||||
if links: | if links: | ||||
for grand_parent, options in frappe.db.sql("""select parent, options from tabDocField | |||||
# find out if linked in a child table | |||||
for parent, options in frappe.db.sql("""select parent, options from tabDocField | |||||
where fieldtype="Table" | where fieldtype="Table" | ||||
and options in (select name from tabDocType | and options in (select name from tabDocType | ||||
where istable=1 and name in (%s))""" % ", ".join(["%s"] * len(links)) ,tuple(links)): | where istable=1 and name in (%s))""" % ", ".join(["%s"] * len(links)) ,tuple(links)): | ||||
ret[grand_parent] = {"child_doctype": options, "fieldname": links[options] } | |||||
ret[parent] = {"child_doctype": options, "fieldname": links[options] } | |||||
if options in ret: | if options in ret: | ||||
del ret[options] | del ret[options] | ||||
# find links of parents | |||||
links = frappe.db.sql("""select dt from `tabCustom Field` | links = frappe.db.sql("""select dt from `tabCustom Field` | ||||
where (fieldtype="Table" and options=%s)""", (self.name)) | where (fieldtype="Table" and options=%s)""", (self.name)) | ||||
links += frappe.db.sql("""select parent from tabDocField | links += frappe.db.sql("""select parent from tabDocField | ||||
@@ -157,3 +157,7 @@ select.form-control { | |||||
-moz-appearance: none; | -moz-appearance: none; | ||||
appearance: none; | appearance: none; | ||||
} | } | ||||
.form-control.bold { | |||||
font-weight: bold; | |||||
background-color: #fffce7; | |||||
} |
@@ -120,8 +120,10 @@ frappe.ui.form.AssignTo = Class.extend({ | |||||
me.dialog.get_input("myself").on("click", function() { | me.dialog.get_input("myself").on("click", function() { | ||||
if($(this).prop("checked")) { | if($(this).prop("checked")) { | ||||
me.dialog.set_value("assign_to", user); | me.dialog.set_value("assign_to", user); | ||||
me.dialog.set_value("notify", 0); | |||||
} else { | } else { | ||||
me.dialog.set_value("assign_to", ""); | me.dialog.set_value("assign_to", ""); | ||||
me.dialog.set_value("notify", 1); | |||||
} | } | ||||
}); | }); | ||||
}, | }, | ||||
@@ -216,6 +216,11 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ | |||||
refresh: function() { | refresh: function() { | ||||
var me = this; | var me = this; | ||||
this.init_stats(); | this.init_stats(); | ||||
if(this.listview.settings.refresh) { | |||||
this.listview.settings.refresh(this); | |||||
} | |||||
if(frappe.route_options) { | if(frappe.route_options) { | ||||
me.set_route_options(); | me.set_route_options(); | ||||
} else if(me.dirty) { | } else if(me.dirty) { | ||||
@@ -6,7 +6,9 @@ | |||||
<li><a href="#Report/{%= doctype %}">{%= __("Report") %}</a></li> | <li><a href="#Report/{%= doctype %}">{%= __("Report") %}</a></li> | ||||
<li class="hide calendar-link"><a href="#Calendar/{%= doctype %}">{%= __("Calendar") %}</a></li> | <li class="hide calendar-link"><a href="#Calendar/{%= doctype %}">{%= __("Calendar") %}</a></li> | ||||
<li class="hide gantt-link"><a href="#Gantt/{%= doctype %}">{%= __("Gantt") %}</a></li> | <li class="hide gantt-link"><a href="#Gantt/{%= doctype %}">{%= __("Gantt") %}</a></li> | ||||
<li><a onclick="cur_list.assigned_to_me()">{%= __("Assigned To Me") %}</a></li> | |||||
<li class="assigned-to-me"> | |||||
<a>{%= __("Assigned To Me") %}</a> | |||||
</li> | |||||
{% if(frappe.help.has_help(doctype)) { %} | {% if(frappe.help.has_help(doctype)) { %} | ||||
<li><a class="help-link" data-doctype="{{ doctype }}">{{ __("Help") }}</a></li> | <li><a class="help-link" data-doctype="{{ doctype }}">{{ __("Help") }}</a></li> | ||||
{% } %} | {% } %} | ||||
@@ -12,8 +12,8 @@ frappe.provide('frappe.views'); | |||||
frappe.views.ListSidebar = Class.extend({ | frappe.views.ListSidebar = Class.extend({ | ||||
init: function(opts) { | init: function(opts) { | ||||
$.extend(this, opts); | $.extend(this, opts); | ||||
this.get_stats(); | |||||
this.make(); | this.make(); | ||||
this.get_stats(); | |||||
}, | }, | ||||
make: function() { | make: function() { | ||||
var sidebar_content = frappe.render_template("list_sidebar", {doctype: this.doclistview.doctype}); | var sidebar_content = frappe.render_template("list_sidebar", {doctype: this.doclistview.doctype}); | ||||
@@ -25,10 +25,22 @@ frappe.views.ListSidebar = Class.extend({ | |||||
this.sidebar = this.page_sidebar.add(this.offcanvas_list_sidebar); | this.sidebar = this.page_sidebar.add(this.offcanvas_list_sidebar); | ||||
this.setup_assigned_to_me(); | |||||
if(frappe.views.calendar[this.doctype]) { | if(frappe.views.calendar[this.doctype]) { | ||||
this.sidebar.find(".calendar-link, .gantt-link").removeClass("hide"); | this.sidebar.find(".calendar-link, .gantt-link").removeClass("hide"); | ||||
} | } | ||||
}, | }, | ||||
setup_assigned_to_me: function() { | |||||
var me = this; | |||||
this.page.sidebar.find(".assigned-to-me a").on("click", function() { | |||||
me.doclistview.assigned_to_me(); | |||||
}); | |||||
this.offcanvas_list_sidebar.find(".assigned-to-me a").on("click", function() { | |||||
me.doclistview.assigned_to_me(); | |||||
}); | |||||
}, | |||||
get_stats: function() { | get_stats: function() { | ||||
var me = this | var me = this | ||||
return frappe.call({ | return frappe.call({ | ||||
@@ -232,6 +232,21 @@ frappe.ui.Page = Class.extend({ | |||||
.on("click", action).appendTo(this.inner_toolbar.removeClass("hide")) | .on("click", action).appendTo(this.inner_toolbar.removeClass("hide")) | ||||
}, | }, | ||||
//-- Sidebar --// | |||||
add_sidebar_item: function(label, action, insert_after) { | |||||
var parent = this.sidebar.find(".sidebar-menu.standard-actions"); | |||||
var li = $('<li>'); | |||||
var link = $('<a>').html(label).on("click", action).appendTo(li); | |||||
if(insert_after) { | |||||
li.insertAfter(parent.find(insert_after)); | |||||
} else { | |||||
li.appendTo(parent); | |||||
} | |||||
return link; | |||||
}, | |||||
//---// | //---// | ||||
clear_user_actions: function() { | clear_user_actions: function() { | ||||
@@ -204,3 +204,8 @@ select.form-control { | |||||
-moz-appearance: none; | -moz-appearance: none; | ||||
appearance: none; | appearance: none; | ||||
} | } | ||||
.form-control.bold { | |||||
font-weight: bold; | |||||
background-color: @light-yellow; | |||||
} |