.trim() all form params from now.
This commit is contained in:
parent
df61622e3e
commit
b8d65a01fe
5 changed files with 74 additions and 2 deletions
|
@ -450,11 +450,11 @@ class App.ControllerForm extends App.Controller
|
|||
# collect all params, push it to an array if already exists
|
||||
if param[key.name] isnt undefined
|
||||
if typeof param[key.name] is 'string'
|
||||
param[key.name] = [param[key.name], key.value]
|
||||
param[key.name] = [param[key.name], key.value.trim()]
|
||||
else
|
||||
param[key.name].push key.value
|
||||
else
|
||||
param[key.name] = key.value
|
||||
param[key.name] = key.value.trim()
|
||||
|
||||
# data type conversion
|
||||
for key of param
|
||||
|
|
37
app/views/tests/form_trim.html.erb
Normal file
37
app/views/tests/form_trim.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
<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-trim.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
|
||||
<div id="qunit" class="u-dontfold"></div>
|
||||
|
||||
<div>
|
||||
<form class="form-stacked pull-left" id="form1">
|
||||
<input type="text" value="" name="input1">
|
||||
<input type="text" value="
|
||||
" name="input2">
|
||||
<input type="text" value=" a " name="input3">
|
||||
<input type="text" value=" a b " name="input4">
|
||||
<input type="text" value=" äö ü" name="input5">
|
||||
<textarea name="textarea1"></textarea>
|
||||
<textarea name="textarea2"> </textarea>
|
||||
<textarea name="textarea3"> a </textarea>
|
||||
<textarea name="textarea4">test
|
||||
|
||||
123
|
||||
|
||||
</textarea>
|
||||
<div contenteditable="true" data-name="ce1"> lala </div>
|
||||
<div contenteditable="true" data-name="ce2"> la
|
||||
la </div>
|
||||
</form>
|
||||
</div>
|
|
@ -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-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
|
||||
match '/tests-table', to: 'tests#table', via: :get
|
||||
|
|
28
public/assets/tests/form-trim.js
Normal file
28
public/assets/tests/form-trim.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
test( 'form trim checks', function() {
|
||||
|
||||
var el = $('#form1')
|
||||
var test_params = {
|
||||
input1: '',
|
||||
input2: '',
|
||||
input3: 'a',
|
||||
input4: 'a b',
|
||||
input5: 'äö ü',
|
||||
textarea1: '',
|
||||
textarea2: '',
|
||||
textarea3: 'a',
|
||||
textarea4: "test\r\n\r\n 123",
|
||||
ce1: 'lala',
|
||||
ce2: "la\nla",
|
||||
}
|
||||
|
||||
el.find('[contenteditable]').ce({
|
||||
mode: 'richtext'
|
||||
})
|
||||
|
||||
var params = App.ControllerForm.params( el )
|
||||
|
||||
deepEqual( params, test_params, 'form param check' )
|
||||
console.log('22', params)
|
||||
console.log('22', test_params)
|
||||
})
|
|
@ -45,6 +45,12 @@ class AAbUnitTest < TestCase
|
|||
value: '0',
|
||||
)
|
||||
|
||||
location( url: browser_url + '/tests-form-trim' )
|
||||
match(
|
||||
css: '.result .failed',
|
||||
value: '0',
|
||||
)
|
||||
|
||||
location( url: browser_url + '/tests-form-extended' )
|
||||
sleep 8
|
||||
match(
|
||||
|
|
Loading…
Reference in a new issue