Merge pull request #9570 from demarches-simplifiees/etq-usager-je-peux-saisir-des-nombres-negatifs
Correction : ETQ usager je peux saisir des nombres négatifs
This commit is contained in:
commit
de71cb32d0
4 changed files with 14 additions and 4 deletions
|
@ -1 +1 @@
|
||||||
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, pattern: "[0-9]*", inputmode: :numeric, required: @champ.required?, data: { controller: 'format', format: :integer }))
|
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, pattern: "-?[0-9]*", inputmode: :numeric, required: @champ.required?, data: { controller: 'format', format: :integer }))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: @champ.libelle, required: @champ.required?, pattern: "[0-9]*", inputmode: :decimal))
|
= @form.text_field(:value, input_opts(id: @champ.input_id, aria: { describedby: @champ.describedby_id }, placeholder: @champ.libelle, required: @champ.required?, pattern: "-?[0-9]*", inputmode: :decimal))
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class FormatController extends ApplicationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private formatInteger(value: string) {
|
private formatInteger(value: string) {
|
||||||
return value.replace(/[^\d]/g, '');
|
return value.replace(/[^-?\d]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
private formatDecimal(value: string) {
|
private formatDecimal(value: string) {
|
||||||
|
@ -54,6 +54,6 @@ export class FormatController extends ApplicationController {
|
||||||
const decimalSeparator =
|
const decimalSeparator =
|
||||||
value.lastIndexOf(',') > value.lastIndexOf('.') ? ',' : '.';
|
value.lastIndexOf(',') > value.lastIndexOf('.') ? ',' : '.';
|
||||||
|
|
||||||
return value.replace(new RegExp(`[^\\d${decimalSeparator}]`, 'g'), '');
|
return value.replace(new RegExp(`[^-?\\d${decimalSeparator}]`, 'g'), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,11 @@ describe 'The user' do
|
||||||
champ_value_for('nombre entier') == '300'
|
champ_value_for('nombre entier') == '300'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fill_in('nombre entier', with: '-256')
|
||||||
|
wait_until {
|
||||||
|
champ_value_for('nombre entier') == '-256'
|
||||||
|
}
|
||||||
|
|
||||||
fill_in('nombre décimal', with: '123 456,78')
|
fill_in('nombre décimal', with: '123 456,78')
|
||||||
wait_until {
|
wait_until {
|
||||||
champ_value_for('nombre décimal') == '123456.78'
|
champ_value_for('nombre décimal') == '123456.78'
|
||||||
|
@ -194,6 +199,11 @@ describe 'The user' do
|
||||||
wait_until {
|
wait_until {
|
||||||
champ_value_for('nombre décimal') == '1234.56'
|
champ_value_for('nombre décimal') == '1234.56'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fill_in('nombre décimal', with: '-1,234.56')
|
||||||
|
wait_until {
|
||||||
|
champ_value_for('nombre décimal') == '-1234.56'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'extends dossier experation date more than one time, ', js: true, retry: 3 do
|
scenario 'extends dossier experation date more than one time, ', js: true, retry: 3 do
|
||||||
|
|
Loading…
Reference in a new issue