From adc5e877d5d5ac4635c5a5ae86ebb170f9e32c53 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 13 Jun 2016 17:46:01 +0530 Subject: [PATCH] [cleanups] fixes to v7 changes --- frappe/desk/doctype/note/note.json | 19 +++++++++++++++---- frappe/desk/page/activity/activity.js | 15 +++++++++------ frappe/public/js/frappe/list/listview.js | 2 +- frappe/public/js/frappe/model/meta.js | 3 ++- frappe/public/js/frappe/ui/listing.js | 15 +++++++-------- frappe/public/js/frappe/ui/sort_selector.js | 12 +++++++++++- .../public/js/frappe/views/communication.js | 2 +- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/frappe/desk/doctype/note/note.json b/frappe/desk/doctype/note/note.json index daf5ab8c99..e9c688d2e2 100644 --- a/frappe/desk/doctype/note/note.json +++ b/frappe/desk/doctype/note/note.json @@ -2,6 +2,7 @@ "allow_copy": 0, "allow_import": 0, "allow_rename": 1, + "beta": 0, "creation": "2013-05-24 13:41:00", "custom": 0, "description": "Note is a free page where users can share documents / notes", @@ -17,6 +18,7 @@ "fieldtype": "Data", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Title", @@ -24,6 +26,7 @@ "no_copy": 1, "permlevel": 0, "print_hide": 1, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 1, @@ -33,13 +36,14 @@ }, { "allow_on_submit": 0, - "bold": 0, + "bold": 1, "collapsible": 0, "description": "Everyone can read", "fieldname": "public", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Public", @@ -47,6 +51,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 1, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -56,13 +61,14 @@ }, { "allow_on_submit": 0, - "bold": 0, + "bold": 1, "collapsible": 0, "description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")", "fieldname": "content", "fieldtype": "Text Editor", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Content", @@ -70,6 +76,7 @@ "no_copy": 0, "permlevel": 0, "print_hide": 0, + "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, "reqd": 0, @@ -82,13 +89,14 @@ "hide_toolbar": 0, "icon": "icon-file-text", "idx": 1, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2015-11-16 06:29:50.709322", + "modified": "2016-06-13 16:55:17.639957", "modified_by": "Administrator", "module": "Desk", "name": "Note", @@ -115,6 +123,9 @@ "write": 1 } ], + "quick_entry": 0, "read_only": 0, - "read_only_onload": 1 + "read_only_onload": 1, + "sort_order": "ASC", + "track_seen": 0 } \ No newline at end of file diff --git a/frappe/desk/page/activity/activity.js b/frappe/desk/page/activity/activity.js index 8fb0c1c9ea..c3cf422013 100644 --- a/frappe/desk/page/activity/activity.js +++ b/frappe/desk/page/activity/activity.js @@ -157,12 +157,15 @@ frappe.activity.Feed = Class.extend({ frappe.activity.render_heatmap = function(page) { var me = this; - $('

').prependTo(page.main); - + $('

').prependTo(page.main); + frappe.call({ method: "frappe.desk.page.activity.activity.get_heatmap_data", callback: function(r) { if(r.message) { + var legend = []; + var max = Math.max.apply(this, $.map(r.message, function(v) { return v })); + var legend = [cint(max/5), cint(max*2/5), cint(max*3/5), cint(max*4/5)]; heatmap = new CalHeatMap(); heatmap.init({ itemSelector: ".heatmap", @@ -177,17 +180,17 @@ frappe.activity.render_heatmap = function(page) { return moment(date).format("MMM").toUpperCase(); }, displayLegend: false, - legend: [5, 10, 15, 20], + legend: legend, tooltip: true, subDomainTitleFormat: { empty: "{date}", - filled: "{count} Communications on {date}" + filled: "{count} actions on {date}" }, subDomainDateFormat: "%d-%b" }); - + heatmap.update(r.message); } } - }) + }) } \ No newline at end of file diff --git a/frappe/public/js/frappe/list/listview.js b/frappe/public/js/frappe/list/listview.js index 2ca06dbb4d..2b1a307685 100644 --- a/frappe/public/js/frappe/list/listview.js +++ b/frappe/public/js/frappe/list/listview.js @@ -202,7 +202,7 @@ frappe.views.ListView = Class.extend({ this.id_list.push(data.name); } - if(this.meta.image_view == 0){ + if(this.meta && this.meta.image_view == 0){ this.render_list_row(row, data); } else{ diff --git a/frappe/public/js/frappe/model/meta.js b/frappe/public/js/frappe/model/meta.js index a7500a0b7a..798381f86d 100644 --- a/frappe/public/js/frappe/model/meta.js +++ b/frappe/public/js/frappe/model/meta.js @@ -57,7 +57,8 @@ $.extend(frappe.meta, { }, get_docfield: function(doctype, fieldname, name) { - return frappe.meta.get_docfield_copy(doctype, name)[fieldname]; + var fields_dict = frappe.meta.get_docfield_copy(doctype, name); + return fields_dict ? fields_dict[fieldname] : null; }, set_formatter: function(doctype, fieldname, name, formatter) { diff --git a/frappe/public/js/frappe/ui/listing.js b/frappe/public/js/frappe/ui/listing.js index 0615a7f127..702f866fc8 100644 --- a/frappe/public/js/frappe/ui/listing.js +++ b/frappe/public/js/frappe/ui/listing.js @@ -315,13 +315,7 @@ frappe.ui.Listing = Class.extend({ }, render_rows: function(values) { // render the rows - if(this.meta.image_view == 0){ - var m = Math.min(values.length, this.page_length); - for(var i=0; i < m; i++) { - this.render_row(this.add_row(values[i]), values[i], this, i); - } - } - else { + if(this.meta && this.meta.image_view){ var cols = values.slice(); while (cols.length) { row = this.add_row(cols[0]); @@ -330,6 +324,11 @@ frappe.ui.Listing = Class.extend({ } this.render_image_gallery(); + } else { + var m = Math.min(values.length, this.page_length); + for(var i=0; i < m; i++) { + this.render_row(this.add_row(values[i]), values[i], this, i); + } } }, render_image_gallery: function(){ @@ -367,7 +366,7 @@ frappe.ui.Listing = Class.extend({ }, add_row: function(row) { return $('
') - .data("data", this.meta.image_view == 0?row:null) + .data("data", (this.meta && this.meta.image_view) == 0 ? row : null) .appendTo(this.$w.find('.result-list')) .get(0); }, diff --git a/frappe/public/js/frappe/ui/sort_selector.js b/frappe/public/js/frappe/ui/sort_selector.js index 765c5c3c05..e83105af1f 100644 --- a/frappe/public/js/frappe/ui/sort_selector.js +++ b/frappe/public/js/frappe/ui/sort_selector.js @@ -9,6 +9,7 @@ frappe.ui.SortSelector = Class.extend({ // doctype: (optional) init: function(opts) { $.extend(this, opts); + this.labels = {}; this.make(); }, make: function() { @@ -45,6 +46,11 @@ frappe.ui.SortSelector = Class.extend({ if(!this.args) { this.args = {}; } + if(this.args.options) { + this.args.options.forEach(function(o) { + me.labels[o.fieldname] = o.label; + }); + } this.setup_from_doctype(); @@ -53,9 +59,12 @@ frappe.ui.SortSelector = Class.extend({ this.args.options.every(function(o) { if(o.fieldname===me.args.sort_by) { me.args.sort_by_label = o.label; + return false; } + return true; }); } + }, setup_from_doctype: function() { var me = this; @@ -130,7 +139,8 @@ frappe.ui.SortSelector = Class.extend({ if(fieldname==='idx') { return __("Most Used"); } else { - return frappe.meta.get_label(this.doctype, fieldname); + return this.labels[fieldname] + || frappe.meta.get_label(this.doctype, fieldname); } } }) \ No newline at end of file diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index 654de7ef20..8fb2e72ca8 100644 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -12,7 +12,7 @@ frappe.views.CommunicationComposer = Class.extend({ make: function() { var me = this; this.dialog = new frappe.ui.Dialog({ - title: __("Add Reply") + ": " + (this.subject || ""), + title: (this.subject || ""), no_submit_on_enter: true, fields: this.get_fields(), primary_action_label: "Send",