fix: Convert public fields to static fields

This commit is contained in:
Faris Ansari 2021-05-11 20:13:32 +05:30
parent bd4364ab46
commit f7c0561171
15 changed files with 27 additions and 24 deletions

View file

@ -1,7 +1,7 @@
import Awesomplete from 'awesomplete';
frappe.ui.form.ControlAutocomplete = class ControlAutoComplete extends frappe.ui.form.ControlData {
trigger_change_on_input_event = false
static trigger_change_on_input_event = false
make_input() {
super.make_input();
this.setup_awesomplete();

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control {
horizontal = true
static horizontal = true
make() {
// parent element
super.make();
@ -45,7 +45,7 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
}
}
set_max_width() {
if(this.horizontal) {
if(this.constructor.horizontal) {
this.$wrapper.addClass("input-max-width");
}
}

View file

@ -1,5 +1,6 @@
frappe.ui.form.ControlCheck = class ControlCheck extends frappe.ui.form.ControlData {
input_type = "checkbox"
static html_element = "input"
static input_type = "checkbox"
make_wrapper() {
this.$wrapper = $(`<div class="form-group frappe-control">
<div class="checkbox">

View file

@ -1,14 +1,16 @@
frappe.provide('frappe.phone_call');
frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInput {
html_element = "input";
input_type = "text";
trigger_change_on_input_event = true;
static html_element = "input";
static input_type = "text";
static trigger_change_on_input_event = true;
make_input() {
if(this.$input) return;
this.$input = $("<"+ this.html_element +">")
.attr("type", this.input_type)
let { html_element, input_type } = this.constructor;
this.$input = $("<"+ html_element +">")
.attr("type", input_type)
.attr("autocomplete", "off")
.addClass("input-with-feedback form-control")
.prependTo(this.input_area);
@ -120,7 +122,7 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlInp
}
};
this.$input.on("change", change_handler);
if (this.trigger_change_on_input_event) {
if (this.constructor.trigger_change_on_input_event) {
// debounce to avoid repeated validations on value change
this.$input.on("input", frappe.utils.debounce(change_handler, 500));
}

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlDate = class ControlDate extends frappe.ui.form.ControlData {
trigger_change_on_input_event = false
static trigger_change_on_input_event = false
make_input() {
super.make_input();
this.make_picker();

View file

@ -1,7 +1,7 @@
frappe.provide('frappe.utils.utils');
frappe.ui.form.ControlGeolocation = class ControlGeolocation extends frappe.ui.form.ControlData {
horizontal = false
static horizontal = false
make_wrapper() {
// Create the elements for map area

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlHTMLEditor = class ControlHTMLEditor extends frappe.ui.form.ControlMarkdownEditor {
editor_class = 'html';
static editor_class = 'html';
set_language() {
this.df.options = 'HTML';
super.set_language();

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlInt = class ControlInt extends frappe.ui.form.ControlData {
trigger_change_on_input_event = false
static trigger_change_on_input_event = false
make () {
super.make();
// $(this.label_area).addClass('pull-right');

View file

@ -9,7 +9,7 @@ import Awesomplete from 'awesomplete';
frappe.ui.form.recent_link_validations = {};
frappe.ui.form.ControlLink = class ControlLink extends frappe.ui.form.ControlData {
trigger_change_on_input_event = false
static trigger_change_on_input_event = false
make_input() {
var me = this;
$(`<div class="link-field ui-front" style="position: relative;">

View file

@ -1,10 +1,10 @@
frappe.ui.form.ControlMarkdownEditor = class ControlMarkdownEditor extends frappe.ui.form.ControlCode {
editor_class = 'markdown'
static editor_class = 'markdown'
make_ace_editor() {
super.make_ace_editor();
this.ace_editor_target.wrap(`<div class="${this.editor_class}-container">`);
this.markdown_container = this.$input_wrapper.find(`.${this.editor_class}-container`);
this.markdown_container = this.$input_wrapper.find(`.${this.constructor.editor_class}-container`);
this.editor.getSession().setUseWrapMode(true);

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlMultiSelectList = class ControlMultiSelectList extends frappe.ui.form.ControlData {
trigger_change_on_input_event = false
static trigger_change_on_input_event = false
make_input() {
let template = `
<div class="multiselect-list dropdown">

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlPassword = class ControlPassword extends frappe.ui.form.ControlData {
input_type = "password"
static input_type = "password"
make() {
super.make();
}

View file

@ -1,5 +1,5 @@
frappe.ui.form.ControlSelect = class ControlSelect extends frappe.ui.form.ControlData {
html_element = 'select';
static html_element = 'select';
make_input() {
super.make_input();

View file

@ -1,8 +1,8 @@
frappe.ui.form.ControlSignature = class ControlSignature extends frappe.ui.form.ControlData {
saving = false
loading = false
make() {
var me = this;
this.saving = false;
this.loading = false;
super.make();
this.load_lib().then(() => {

View file

@ -1,6 +1,6 @@
frappe.ui.form.ControlText = class ControlText extends frappe.ui.form.ControlData {
html_element = "textarea"
horizontal = false
static html_element = "textarea"
static horizontal = false
make_wrapper() {
super.make_wrapper();
this.$wrapper.find(".like-disabled-input").addClass("for-description");