Merge pull request #4041 from netchampfaris/datepicker-fixes
[Datepicker] Fix today button, disable keyboardNav
This commit is contained in:
commit
f07a6372dc
3 changed files with 24 additions and 4 deletions
|
|
@ -38,9 +38,10 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({
|
|||
this.datepicker_options = {
|
||||
language: lang,
|
||||
autoClose: true,
|
||||
todayButton: frappe.datetime.now_date(true),
|
||||
todayButton: true,
|
||||
dateFormat: (frappe.boot.sysdefaults.date_format || 'yyyy-mm-dd'),
|
||||
startDate: frappe.datetime.now_date(true),
|
||||
keyboardNav: false,
|
||||
onSelect: () => {
|
||||
this.$input.trigger('change');
|
||||
},
|
||||
|
|
@ -69,6 +70,17 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({
|
|||
set_datepicker: function() {
|
||||
this.$input.datepicker(this.datepicker_options);
|
||||
this.datepicker = this.$input.data('datepicker');
|
||||
|
||||
// today button didn't work as expected,
|
||||
// so explicitly bind the event
|
||||
this.datepicker.$datepicker
|
||||
.find('[data-action="today"]')
|
||||
.click(() => {
|
||||
this.datepicker.selectDate(this.get_now_date());
|
||||
});
|
||||
},
|
||||
get_now_date: function() {
|
||||
return frappe.datetime.now_date(true);
|
||||
},
|
||||
set_t_for_today: function() {
|
||||
var me = this;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ frappe.ui.form.ControlDatetime = frappe.ui.form.ControlDate.extend({
|
|||
this.today_text = __("Now");
|
||||
$.extend(this.datepicker_options, {
|
||||
timepicker: true,
|
||||
timeFormat: "hh:ii:ss",
|
||||
todayButton: frappe.datetime.now_datetime(true)
|
||||
timeFormat: "hh:ii:ss"
|
||||
});
|
||||
},
|
||||
get_now_date: function() {
|
||||
return frappe.datetime.now_datetime(true);
|
||||
},
|
||||
set_description: function() {
|
||||
const { description } = this.df;
|
||||
const { time_zone } = frappe.sys_defaults;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,15 @@ frappe.ui.form.ControlTime = frappe.ui.form.ControlData.extend({
|
|||
onShow: function() {
|
||||
$('.datepicker--button:visible').text(__('Now'));
|
||||
},
|
||||
todayButton: frappe.datetime.now_time(true)
|
||||
keyboardNav: false,
|
||||
todayButton: true
|
||||
});
|
||||
this.datepicker = this.$input.data('datepicker');
|
||||
this.datepicker.$datepicker
|
||||
.find('[data-action="today"]')
|
||||
.click(() => {
|
||||
this.datepicker.selectDate(frappe.datetime.now_time(true));
|
||||
});
|
||||
this.refresh();
|
||||
},
|
||||
set_input: function(value) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue