Browse Source

[enhancement] added 'assigned by me' in todo list

version-14
Rushabh Mehta 10 years ago
parent
commit
748cac0d99
9 changed files with 79 additions and 5 deletions
  1. +20
    -0
      frappe/desk/doctype/todo/todo_list.js
  2. +12
    -3
      frappe/desk/form/meta.py
  3. +4
    -0
      frappe/public/css/form.css
  4. +2
    -0
      frappe/public/js/frappe/form/footer/assign_to.js
  5. +5
    -0
      frappe/public/js/frappe/list/doclistview.js
  6. +3
    -1
      frappe/public/js/frappe/list/list_sidebar.html
  7. +13
    -1
      frappe/public/js/frappe/list/list_sidebar.js
  8. +15
    -0
      frappe/public/js/frappe/ui/page.js
  9. +5
    -0
      frappe/public/less/form.less

+ 20
- 0
frappe/desk/doctype/todo/todo_list.js View File

@@ -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"],
} }

+ 12
- 3
frappe/desk/form/meta.py View File

@@ -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


+ 4
- 0
frappe/public/css/form.css View File

@@ -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;
}

+ 2
- 0
frappe/public/js/frappe/form/footer/assign_to.js View File

@@ -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);
} }
}); });
}, },


+ 5
- 0
frappe/public/js/frappe/list/doclistview.js View File

@@ -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) {


+ 3
- 1
frappe/public/js/frappe/list/list_sidebar.html View File

@@ -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>
{% } %} {% } %}


+ 13
- 1
frappe/public/js/frappe/list/list_sidebar.js View File

@@ -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({


+ 15
- 0
frappe/public/js/frappe/ui/page.js View File

@@ -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() {


+ 5
- 0
frappe/public/less/form.less View File

@@ -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;
}

Loading…
Cancel
Save