fix: allow options in datepicker via df.options
ability to customize datepicker options via df.options
This commit is contained in:
parent
da4160e2dd
commit
f6379fdf40
1 changed files with 17 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue