fix: allow options in datepicker via df.options

ability to customize datepicker options via df.options
This commit is contained in:
Faris Ansari 2021-12-03 18:23:28 +05:30
parent da4160e2dd
commit f6379fdf40

View file

@ -73,7 +73,8 @@ frappe.ui.form.ControlDate = class ControlDate extends frappe.ui.form.ControlDat
.text(this.today_text);
this.update_datepicker_position();
}
},
...(this.get_df_options())
};
}
set_datepicker() {
@ -150,4 +151,19 @@ frappe.ui.form.ControlDate = class ControlDate extends frappe.ui.form.ControlDat
}
return value;
}
get_df_options() {
let options = {};
let df_options = this.df.options || '';
if (typeof df_options === 'string') {
try {
options = JSON.parse(df_options);
} catch (error) {
console.warn(`Invalid JSON in options of "${this.df.fieldname}"`);
}
}
else if (typeof df_options === 'object') {
options = df_options;
}
return options;
}
};