From f0fa4a6f9b967704837a61d5e5242947d8d4475c Mon Sep 17 00:00:00 2001 From: Mantas Date: Wed, 18 Nov 2020 17:48:45 +0200 Subject: [PATCH] Fixes #3291 - Date and Datetime widgets can not be disabled --- .../javascripts/app/views/generic/date.jst.eco | 4 ++-- .../app/views/generic/datetime.jst.eco | 6 +++--- public/assets/tests/form_datetime.js | 15 +++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/views/generic/date.jst.eco b/app/assets/javascripts/app/views/generic/date.jst.eco index b12a620ea..44332bb7e 100644 --- a/app/assets/javascripts/app/views/generic/date.jst.eco +++ b/app/assets/javascripts/app/views/generic/date.jst.eco @@ -1,4 +1,4 @@
- -
\ No newline at end of file + disabled<% end %>> + diff --git a/app/assets/javascripts/app/views/generic/datetime.jst.eco b/app/assets/javascripts/app/views/generic/datetime.jst.eco index ac195d58d..59331795d 100644 --- a/app/assets/javascripts/app/views/generic/datetime.jst.eco +++ b/app/assets/javascripts/app/views/generic/datetime.jst.eco @@ -1,6 +1,6 @@
- + disabled<% end %>>
<%- @T('at') %>
- -
\ No newline at end of file + disabled<% end %>> + diff --git a/public/assets/tests/form_datetime.js b/public/assets/tests/form_datetime.js index 4cdc3d62a..1ce0e7817 100644 --- a/public/assets/tests/form_datetime.js +++ b/public/assets/tests/form_datetime.js @@ -11,18 +11,25 @@ test("DateTime timepicker focuses hours", function(assert) { model: { configure_attributes: [ { name: 'datetime1', display: 'Datetime1', tag: 'datetime', null: true }, + { name: 'datetime2', display: 'Datetime2', tag: 'datetime', null: true, disabled: true }, + { name: 'date3', display: 'Date3', tag: 'date', null: true, disabled: true }, ] }, autofocus: true }); - let timepicker = el.find('[data-item=time]') + let timepicker1 = el.find('[data-name=datetime1] [data-item=time]') + //debugger - timepicker.focus() + timepicker1.focus() setTimeout(function(){ // give it time to apply focus - equal(timepicker[0].selectionStart, 0) - equal(timepicker[0].selectionEnd, 2) + equal(timepicker1[0].selectionStart, 0) + equal(timepicker1[0].selectionEnd, 2) + + equal(el.find('[data-name=datetime2] [data-item=date]')[0].disabled, true) + equal(el.find('[data-name=datetime2] [data-item=time]')[0].disabled, true) + equal(el.find('[data-name=date3] [data-item=date]')[0].disabled, true) done() }, 100)