diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.coffee index c9814a085..e33e18f45 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.coffee @@ -511,7 +511,6 @@ class App.ControllerForm extends App.Controller else form = $(form) - #console.log('FF', form) # get form if form.is('form') is true #console.log('direct from') @@ -534,15 +533,20 @@ class App.ControllerForm extends App.Controller lookupForm = @findForm(form) if lookupForm + if lookupForm.is('button, input, select, textarea, div, span') + App.Log.debug 'ControllerForm', 'disable item...', lookupForm + lookupForm.attr('readonly', true) + lookupForm.attr('disabled', true) + return App.Log.debug 'ControllerForm', 'disable form...', lookupForm # set forms to read only during communication with backend lookupForm.find('button, input, select, textarea').attr('readonly', true) # disable additionals submits - lookupForm.find('button.btn').attr('disabled', true) + lookupForm.find('button').attr('disabled', true) else - App.Log.notice 'ControllerForm', 'disable item...', form + App.Log.debug 'ControllerForm', 'disable item...', form form.attr('readonly', true) form.attr('disabled', true) @@ -551,15 +555,20 @@ class App.ControllerForm extends App.Controller lookupForm = @findForm(form) if lookupForm + if lookupForm.is('button, input, select, textarea, div, span') + App.Log.debug 'ControllerForm', 'disable item...', lookupForm + lookupForm.attr('readonly', false) + lookupForm.attr('disabled', false) + return App.Log.debug 'ControllerForm', 'enable form...', lookupForm # enable fields again lookupForm.find('button, input, select, textarea').attr('readonly', false) # enable submits again - lookupForm.find('button.btn').attr('disabled', false) + lookupForm.find('button').attr('disabled', false) else - App.Log.notice 'ControllerForm', 'enable item...', form + App.Log.debug 'ControllerForm', 'enable item...', form form.attr('readonly', false) form.attr('disabled', false) diff --git a/app/views/tests/form_find.html.erb b/app/views/tests/form_find.html.erb new file mode 100644 index 000000000..3f8b84f93 --- /dev/null +++ b/app/views/tests/form_find.html.erb @@ -0,0 +1,19 @@ + + + + + + + + + +
+ +
+
+
diff --git a/config/routes/test.rb b/config/routes/test.rb index 986d311c7..9e2a315ec 100644 --- a/config/routes/test.rb +++ b/config/routes/test.rb @@ -5,6 +5,7 @@ Zammad::Application.routes.draw do match '/tests_model', to: 'tests#model', via: :get match '/tests_model_ui', to: 'tests#model_ui', via: :get match '/tests_form', to: 'tests#form', via: :get + match '/tests_form_find', to: 'tests#form_find', via: :get match '/tests_form_trim', to: 'tests#form_trim', via: :get match '/tests_form_extended', to: 'tests#form_extended', via: :get match '/tests_form_validation', to: 'tests#form_validation', via: :get diff --git a/public/assets/tests/form_find.js b/public/assets/tests/form_find.js new file mode 100644 index 000000000..8474dc541 --- /dev/null +++ b/public/assets/tests/form_find.js @@ -0,0 +1,39 @@ + +// form +test( "find form check", function() { + + $('#forms').append('

find form check

') + var form1 = App.ControllerForm.findForm($('#form1')) + equal(form1.is('form'), true) + + $('#forms').append('

find form check

') + var form2 = App.ControllerForm.findForm($('#form2 .js-input')) + equal(form2.is('form'), true) + + $('#forms').append('

find form check

') + var form3 = App.ControllerForm.findForm($('#form3 .js-button')) + equal(form3.is('form'), true) + App.ControllerForm.disable($('#form3 .js-button')) + equal($('#form3 .js-button').attr('readonly'), 'readonly') + equal($('#form3 .js-button').attr('disabled'), 'disabled') + equal($('#form3 .js-input').attr('readonly'), 'readonly') + equal($('#form3 .js-input').attr('disabled'), undefined) + + App.ControllerForm.enable($('#form3 .js-button')) + equal($('#form3 .js-button').attr('readonly'), undefined) + equal($('#form3 .js-button').attr('disabled'), undefined) + equal($('#form3 .js-input').attr('readonly'), undefined) + equal($('#form3 .js-input').attr('disabled'), undefined) + + $('#forms').append('

find form check

') + var form4 = App.ControllerForm.findForm($('#form4 .js-button')) + equal(form4.is('form'), false) + App.ControllerForm.disable($('#form4 .js-button')) + equal($('#form4 .js-button').attr('readonly'), 'readonly') + equal($('#form4 .js-button').attr('disabled'), 'disabled') + + App.ControllerForm.enable($('#form4 .js-button')) + equal($('#form4 .js-input').attr('readonly'), undefined) + equal($('#form4 .js-input').attr('disabled'), undefined) + +}); diff --git a/test/browser/aab_unit_test.rb b/test/browser/aab_unit_test.rb index 4d082d235..1cc92f5cf 100644 --- a/test/browser/aab_unit_test.rb +++ b/test/browser/aab_unit_test.rb @@ -46,6 +46,14 @@ class AAbUnitTest < TestCase ) location( url: browser_url + '/tests_form_trim' ) + sleep 4 + match( + css: '.result .failed', + value: '0', + ) + + location( url: browser_url + '/tests_form_find' ) + sleep 4 match( css: '.result .failed', value: '0',