fix(editable_champ): can enter negative integer number
This commit is contained in:
parent
4750e4a4bf
commit
e17d694b30
3 changed files with 7 additions and 2 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 }))
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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'
|
||||||
|
|
Loading…
Reference in a new issue