Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2016-02-15 16:43:14 +01:00
commit e3fd680c46
5 changed files with 81 additions and 5 deletions

View file

@ -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)

View file

@ -0,0 +1,19 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.10.0.css">
<script src="/assets/tests/qunit-1.10.0.js"></script>
<script src="/assets/tests/form_find.js"></script>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<script type="text/javascript">
</script>
<div id="qunit" class="u-dontfold"></div>
<div>
<div id="forms"></div>
</div>

View file

@ -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

View file

@ -0,0 +1,39 @@
// form
test( "find form check", function() {
$('#forms').append('<hr><h1>find form check</h1><form id="form1"></form>')
var form1 = App.ControllerForm.findForm($('#form1'))
equal(form1.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form2"><input class="js-input" value="test 123"></form>')
var form2 = App.ControllerForm.findForm($('#form2 .js-input'))
equal(form2.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form3"><input class="js-input" value="test 123"><button class="js-button">text</button></form>')
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('<hr><h1>find form check</h1><div id="form4"><input class="js-input" value="test 123"><button class="js-button">text</button></div>')
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)
});

View file

@ -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',