From 68b9ae808bf9e1eeed29b7f5eba8f074a6e53014 Mon Sep 17 00:00:00 2001 From: hasnain2808 Date: Wed, 18 Aug 2021 12:35:05 +0530 Subject: [PATCH 1/7] feat: maxLines in ace editor --- frappe/public/js/frappe/form/controls/code.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 5af7cf2863..29749a8a27 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -9,12 +9,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex this.ace_editor_target = $('
') .appendTo(this.input_area); - this.expanded = false; - this.$expand_button = $(``).click(() => { - this.expanded = !this.expanded; - this.refresh_height(); - this.toggle_label(); - }).appendTo(this.$input_wrapper); + // styling this.ace_editor_target.addClass('border rounded'); this.ace_editor_target.css('height', 300); @@ -22,6 +17,18 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex // initialize const ace = window.ace; this.editor = ace.edit(this.ace_editor_target.get(0)); + + if (this.df.maxLines) + this.editor.setOption("maxLines", this.df.maxLines); + else{ + this.expanded = false; + this.$expand_button = $(``).click(() => { + this.expanded = !this.expanded; + this.refresh_height(); + this.toggle_label(); + }).appendTo(this.$input_wrapper); + } + this.editor.setTheme('ace/theme/tomorrow'); this.editor.setOption("showPrintMargin", false); this.editor.setOption("wrap", this.df.wrap); From f3e0a30ec78bd7a3cfbe2690e137597a61c3f6ec Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Wed, 18 Aug 2021 13:55:33 +0530 Subject: [PATCH 2/7] style: add space after else keyword --- frappe/public/js/frappe/form/controls/code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 29749a8a27..b5653a68a7 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -20,7 +20,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex if (this.df.maxLines) this.editor.setOption("maxLines", this.df.maxLines); - else{ + else { this.expanded = false; this.$expand_button = $(``).click(() => { this.expanded = !this.expanded; From 03c975a1f1ea59eeb38818427954c90240d8b886 Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Wed, 18 Aug 2021 14:03:22 +0530 Subject: [PATCH 3/7] fix: use snake case Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> --- frappe/public/js/frappe/form/controls/code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index b5653a68a7..0f0565cf3e 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -19,7 +19,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex this.editor = ace.edit(this.ace_editor_target.get(0)); if (this.df.maxLines) - this.editor.setOption("maxLines", this.df.maxLines); + this.editor.setOption("maxLines", this.df.max_lines); else { this.expanded = false; this.$expand_button = $(``).click(() => { From 6da11e7a2640f1b42bb540530a5be05c872085cb Mon Sep 17 00:00:00 2001 From: hasnain2808 Date: Wed, 18 Aug 2021 14:06:11 +0530 Subject: [PATCH 4/7] fix: use snake case --- frappe/public/js/frappe/form/controls/code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 0f0565cf3e..210bf57839 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -18,7 +18,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex const ace = window.ace; this.editor = ace.edit(this.ace_editor_target.get(0)); - if (this.df.maxLines) + if (this.df.max_lines) this.editor.setOption("maxLines", this.df.max_lines); else { this.expanded = false; From eb37566ac0fb6434c752f7dabc93cf2113a8195e Mon Sep 17 00:00:00 2001 From: hasnain2808 Date: Wed, 18 Aug 2021 20:34:58 +0530 Subject: [PATCH 5/7] feat: min lines for ace editor --- frappe/public/js/frappe/form/controls/code.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 210bf57839..421af1cbb3 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -18,8 +18,12 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex const ace = window.ace; this.editor = ace.edit(this.ace_editor_target.get(0)); - if (this.df.max_lines) - this.editor.setOption("maxLines", this.df.max_lines); + if (this.df.max_lines || this.df.min_lines) { + if (this.df.max_lines) + this.editor.setOption("maxLines", this.df.max_lines); + if (this.df.min_lines) + this.editor.setOption("minLines", this.df.min_lines); + } else { this.expanded = false; this.$expand_button = $(``).click(() => { From 12c106719d6b24fc058eb4a83983edb14563542e Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Wed, 18 Aug 2021 20:44:36 +0530 Subject: [PATCH 6/7] style: close curly brace on the same line --- frappe/public/js/frappe/form/controls/code.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 421af1cbb3..27888fd49b 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -23,8 +23,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex this.editor.setOption("maxLines", this.df.max_lines); if (this.df.min_lines) this.editor.setOption("minLines", this.df.min_lines); - } - else { + } else { this.expanded = false; this.$expand_button = $(``).click(() => { this.expanded = !this.expanded; From e134570d2647f092530b95bc5cdb18dc9cf3d69d Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Fri, 27 Aug 2021 10:24:57 +0530 Subject: [PATCH 7/7] style: Remove extra space --- frappe/public/js/frappe/form/controls/code.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/form/controls/code.js b/frappe/public/js/frappe/form/controls/code.js index 27888fd49b..5fbfa28073 100644 --- a/frappe/public/js/frappe/form/controls/code.js +++ b/frappe/public/js/frappe/form/controls/code.js @@ -18,7 +18,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex const ace = window.ace; this.editor = ace.edit(this.ace_editor_target.get(0)); - if (this.df.max_lines || this.df.min_lines) { + if (this.df.max_lines || this.df.min_lines) { if (this.df.max_lines) this.editor.setOption("maxLines", this.df.max_lines); if (this.df.min_lines)