From c1bd405afc2cc6a0bb8e00bdd087815f95e4d9b1 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 11 Dec 2018 10:14:21 +0530 Subject: [PATCH 1/4] Fix: Query Report (#6603) * fix: Update frappe-datatable to 1.7.0 - Fix filtering with sorting - Equals keyword for numeric columns * fix: Show tip for inline filtering --- frappe/public/js/frappe/views/reports/query_report.js | 10 ++++++++++ package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index 2bc12f14a0..2fc0c25a21 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -937,6 +937,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { this.$status = $(`
`) .hide().insertAfter(page_form); + this.show_tip(); this.$chart = $('
').hide().appendTo(this.page.main); this.$report = $('
').appendTo(this.page.main); this.$message = $(this.message_div('')).hide().appendTo(this.page.main); @@ -950,6 +951,15 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { this.$status.hide(); } + show_tip() { + const part1 = __('For comparative filters, start with ">" or "<" or "=", e.g. >5 or =324'); + const part2 = __('For ranges use ":", e.g. "5:10" (to filter values between 5 & 10'); + this.page.footer.removeClass('hide').addClass('text-muted text-center').html(` +

${part1}

+

${part2}

+ `); + } + message_div(message) { return `
${message}
diff --git a/package.json b/package.json index f48d6ad2ec..73a33157c6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "awesomplete": "^1.1.2", "cookie": "^0.3.1", "express": "^4.16.2", - "frappe-datatable": "^1.6.2", + "frappe-datatable": "^1.7.0", "frappe-gantt": "^0.1.0", "fuse.js": "^3.2.0", "highlight.js": "^9.12.0", diff --git a/yarn.lock b/yarn.lock index 9d2ea9ea60..d1a0f9ab14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1219,10 +1219,10 @@ forwarded@~0.1.2: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= -frappe-datatable@^1.6.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.6.2.tgz#4144e2e15740a8b90dfd133410384214ee882ff9" - integrity sha512-ES0wJnSa9LGCWpCDg7WKYeuHobWKsQJQn0t8rXvuscypg87BmW6EZAJRa1bL6E0HXrjyr7p5yNXH2LyUyiULkQ== +frappe-datatable@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.7.0.tgz#6cc950a69bdfd514fb61ab25b85fa68c3b33aee0" + integrity sha512-CcCIf36eJMqzobc4rMT75zCCFKjfghJAR9rXiAP6h2uWdDKhb0U+rDjiFPweS54lv19tpTYF7Q/1SSx0Ih+Mfg== dependencies: hyperlist "^1.0.0-beta" lodash "^4.17.5" From dad0b84847800fd3af1689d3c33515d9261f2186 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 11 Dec 2018 11:08:50 +0530 Subject: [PATCH 2/4] fix(patch): check if table exists for old prepared reports (#6605) * debug(test): test_scheduler_events * fix(patch): check if table exists for old prepared reports * debug(tests): add comments for debug --- frappe/patches/v11_0/delete_all_prepared_reports.py | 7 ++++--- frappe/tests/test_scheduler.py | 3 +++ frappe/utils/scheduler.py | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frappe/patches/v11_0/delete_all_prepared_reports.py b/frappe/patches/v11_0/delete_all_prepared_reports.py index ee4b1dbd08..2204f90a8d 100644 --- a/frappe/patches/v11_0/delete_all_prepared_reports.py +++ b/frappe/patches/v11_0/delete_all_prepared_reports.py @@ -1,6 +1,7 @@ import frappe def execute(): - prepared_reports = frappe.get_all("Prepared Report") - for report in prepared_reports: - frappe.delete_doc("Prepared Report", report.name) + if frappe.db.table_exists('Prepared Report'): + prepared_reports = frappe.get_all("Prepared Report") + for report in prepared_reports: + frappe.delete_doc("Prepared Report", report.name) diff --git a/frappe/tests/test_scheduler.py b/frappe/tests/test_scheduler.py index abf51c48ff..6c72a49d61 100644 --- a/frappe/tests/test_scheduler.py +++ b/frappe/tests/test_scheduler.py @@ -53,6 +53,9 @@ class TestScheduler(TestCase): "monthly", "monthly_long"]) frappe.db.set_global('enabled_scheduler_events', val) + # TEMP for debug: this test fails randomly + print('Setting enabled_scheduler_events {0}'.format(val)) + # maintain last_event and next_event on different days next_event = now_datetime().replace(hour=0, minute=0, second=0, microsecond=0) last_event = next_event - relativedelta(hours=2) diff --git a/frappe/utils/scheduler.py b/frappe/utils/scheduler.py index 8e7a834512..e438bfdb78 100755 --- a/frappe/utils/scheduler.py +++ b/frappe/utils/scheduler.py @@ -218,10 +218,13 @@ def get_enabled_scheduler_events(): return frappe.flags.enabled_events enabled_events = frappe.db.get_global("enabled_scheduler_events") + if frappe.flags.in_test: + # TEMP for debug: this test fails randomly + print('found enabled_scheduler_events {0}'.format(enabled_events)) + if enabled_events: if isinstance(enabled_events, string_types): enabled_events = json.loads(enabled_events) - return enabled_events return ["all", "hourly", "hourly_long", "daily", "daily_long", From 41b7267e4e58d06ad2e0bc8e19fffcd39989d51b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 11 Dec 2018 13:40:25 +0530 Subject: [PATCH 3/4] fix: Email Reply Behaviour (#6578) * fix: Email Reply Behaviour - Now email will be appended to the next reply but it would be clipped at 20k characters. - The reply part of the email would not be shown in the timeline. - If the email is composed using the "New Email", the last email is not appended to the email * fix: Convert into multiline string * fix: var to let * fix: var to let --- .../js/frappe/form/controls/text_editor.js | 2 +- .../public/js/frappe/form/footer/timeline.js | 14 +++-- .../public/js/frappe/views/communication.js | 52 +++++++++++++++++-- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/text_editor.js b/frappe/public/js/frappe/form/controls/text_editor.js index 9e27dcf0f8..5203c57e7f 100644 --- a/frappe/public/js/frappe/form/controls/text_editor.js +++ b/frappe/public/js/frappe/form/controls/text_editor.js @@ -34,7 +34,7 @@ class HiddenBlock extends Block { } } HiddenBlock.blotName = 'hiddenblot'; -HiddenBlock.tagName = 'DIV'; +HiddenBlock.tagName = 'SPAN'; Quill.register(HiddenBlock, true); // image uploader diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js index 83b0f386c3..0782f57b91 100644 --- a/frappe/public/js/frappe/form/footer/timeline.js +++ b/frappe/public/js/frappe/form/footer/timeline.js @@ -78,10 +78,17 @@ frappe.ui.form.Timeline = class Timeline { var selector = this.frm.doctype === "Communication"? ".btn-reply-email": ".btn-new-email"; this.email_button = this.wrapper.find(selector) .on("click", function() { + const $btn = $(this); + let is_a_reply = true; + if ($btn.is('.btn-new-email')) { + is_a_reply = false; + } + var args = { doc: me.frm.doc, frm: me.frm, - recipients: me.get_recipient() + recipients: me.get_recipient(), + is_a_reply } if(me.frm.doctype === "Communication") { @@ -286,7 +293,8 @@ frappe.ui.form.Timeline = class Timeline { txt: "", title: __('Reply'), frm: me.frm, - last_email: last_email + last_email: last_email, + is_a_reply: true }); }); } @@ -336,7 +344,7 @@ frappe.ui.form.Timeline = class Timeline { }); } else { if(c.communication_type=="Communication" && c.communication_medium=="Email") { - c.content = c.content.split('
')[0]; + c.content = c.content.split('')[0]; c.content = frappe.utils.strip_original_content(c.content); c.original_content = c.content; diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index ec7db29b9d..46f25bc23b 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -498,7 +498,9 @@ frappe.views.CommunicationComposer = Class.extend({ save_as_draft: function() { if (this.dialog) { try { - localStorage.setItem(this.frm.doctype + this.frm.docname, this.dialog.get_value('content')); + let message = this.dialog.get_value('content'); + message = message.split('')[0]; + localStorage.setItem(this.frm.doctype + this.frm.docname, message); } catch (e) { // silently fail console.log(e); @@ -621,7 +623,7 @@ frappe.views.CommunicationComposer = Class.extend({ signature = signature.replace(/\n/g, "
"); } - if (this.txt) { + if(this.txt) { this.message = this.txt + (this.message ? ("

" + this.message) : ""); } else { // saved draft in localStorage @@ -636,8 +638,50 @@ frappe.views.CommunicationComposer = Class.extend({ + this.real_name + ",


" + (this.message || ""); } - var reply = (this.message || "") + (signature ? ("
" + signature) : ""); + let reply = (this.message || "") + (signature ? ("
" + signature) : ""); + let content = ''; - fields.content.set_value(reply); + if (this.is_a_reply === 'undefined') { + this.is_a_reply = true; + } + + if (this.is_a_reply) { + let last_email = this.last_email; + + if (!last_email) { + last_email = this.frm && this.frm.timeline.get_last_email(true); + } + + if (!last_email) return; + + let last_email_content = last_email.original_comment || last_email.content; + + last_email_content = last_email_content + .replace(/<meta[\s\S]*meta>/g, '') // remove tags + .replace(/<style[\s\S]*<\/style>/g, ''); // // remove