New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issue #10211: Thousands separator - numeric input and multiple numeric input in the same group #412
Conversation
Your sure it fix one Question with thousand and another one without thousand in same group ? I don't find where you test the qid :) PS : with other function we launch the function in HTML
|
OK, never mind : bad look of code for me .... usage of class name :) |
…numeric input in the same group Dev: Fix survey with numerical value and thousand separator Dev: Fix script numerical_input.js : Only use when thousand_separator = 1
1c60550
to
1212140
Compare
Yes, I tried with the .lss file provided on the bugtracker and I create an example with few numerical inputs. It works for this 2 cases. |
Yes, correct my comment in #412 (comment) :) |
Do you know what version will contain this patch ? (Client needs this information) |
if($aAttributes[$qid]['thousands_separator']=='1') { | ||
$value=str_replace($invertRadix['separator'], '', $value); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is to show "thousand seperator" without JS, right ? But thousand don't really work without JS. Really needed ?
-> js : update value after shown (.ready)
-> no js : get the value, and show the real value
I do a quick test with separator dot : user can not enter 1,000 without JS. Then : no js : no thousand_separator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part permit to remove the dots or commats from the value. (2,300,400.10 => 2300300.10 or 2.300.400,10 => 2300300,10).
Without this part, I had SQL crashes :
With dot as decimal mark :
UPDATE lime_survey_499425 SET "lastpage"=0, "499425X8X40"='23,123,131,231.23', "499425X8X41"='1,231,232,131,231' WHERE ID=6
465,465,465,443 is not a decimal value
Or
With commat as decimal mark :
UPDATE lime_survey_499425 SET "lastpage"=0, "499425X8X40"='1.231.231.23', "499425X8X41"='131.231.231.231.232' WHERE ID=5
This is the same with '131.231.231.231.232'
But you are right, with decimal mark as a dot and a numerical input with thousands_separator = 1 and interger_only = 0, the value saved is wrong : 100022 instead of 1000.22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the input value is 1.000.22
May be, should I move this part of code in the same place where the code transforms 1.000,22 into 1.000.22 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I found it ! :D
Line 8523 to 8527 :
if ($radixchange && isset($LEM->knownVars[$sq]['onlynum']) && $LEM->knownVars[$sq]['onlynum']=='1')
{
// convert from comma back to decimal
$value = implode('.',explode(',',$value));
}
I just need to move this part after the "switch".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this one before right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olleharstedt Ok for me, the data saved in database was fixed by your commit c11fe85
I test with a form with :
- 1 multiple numerical with thousand and int only
- 1 numerical with thousand
- 1 numerical with int only
- 1 numerical
I see 2 others errors with javascript :
- 1 numerical with int only : I can write a decimal part
- 1 numerical : I can't write a decimal part
I see two errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olleharstedt If you are agree with it, I can just update the file scripts/numerical_input.js to use the correct javascript part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GuillaumeSmaha This commit is the complete fix: 83beb12
To do this by the book, could you write a bug report and include your test survey? If you've already fixed the bugs, you can link to that PR which fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olleharstedt Ok this is another issue, so I close this pull request.
…numeric input in the same group Dev: Move the part which convert from comma back to decimal
{ | ||
// convert from comma back to decimal | ||
$value = implode('.',explode(',',$value)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You remove it here ;) and remind "text" with ad attribute "only num". And Array number ;)
For fix in core : like whole GPL : it's done when it's done ;). I take a look this week to merge it |
@GuillaumeSmaha OK, seems to work. But i think we don't need some EM update .
EM is really hard to fix and update , then if we can fix without update EM ... Here : i think the base JS is broken : NO JS : accept only real number (just the radix) PS : in fact i really dislike the original system .... no option, no radix thinking, and right : seems we need update EM .... Better is to create a input to show the number and hide the original input. |
@Shnoulle 1. I just move this part on 3.
JS : During my test, the number is sent to the server with the thousand separator and the custom decimal mark. So, I developed the fix in EM.
After all, I think it will be possible to reduce the code with this instead of the part 1 (removing part 2 & 3) :
OR as you say, it will be better to update the input value just before the form validation with an event on submit form. |
Maybe you have right : we must :
@SamMousa : you do the attribute : what did you think EM or just JS ? PS : i think we must check how EM manage it : like date : always send YYYY-MM-DD value (for example for date comare etc) but show d/m/y value (or anything else). |
@Shnoulle
|
I see with sam who made original modification (and other core dev) |
Thurday (if exist) dev meeting |
I am not in favor of adding this type of validation to EM. Instead I recommend using it as a graphical helper only (and thus JS only).
|
For 2 : silently fix 1 000 to 1000 don't "hurt". But probelm is did we fix it in EM (like @GuillaumeSmaha do it in this fix). Or only in JS. For only JS : we can use some $(document).on("submit","#limesurvey", function(){} ; |
For 2: Currently, conversion from comma mark to point mark is also done in EM. That why I added my fix at the same place. |
Another point : With the current implementation and JS, there are 4 kind of inputs :
Should I call priceFormat for this case too ? Also, I think that priceFormat needs to be fix (in another pull request) :
|
Hi Guillaume : think for 2.06 fix : we just need a functionnal system. Maybe for another commit (2.5 or 2.06): need 3 options :
The 2 decimals is only for 3rd solution :) . For . to , : yes ... old behaviour since 1.87 or maybe 1.70 ... BUT : here : i really don't know what user wants. For dev : better to remove it from EM (PHP) and do it only in JS, but user don't see really difference (?) or see the difference ? |
I start a work to find a way to do it only in JS .... but have strange situation with priceFormat : 10000,9999 are updated to 100.099,99 with .priceFormat ( and , for separator). I make a new pull request with WIP monday . |
10000,9999 are updated to 100.099,99 with .priceFormat :
|
Yes, .... starting to do it in JS only are more difficult than i think ....
But after : need exactly 2 decimals .... Thanks for the point . Maybe it's better to move to JS only at the same time than LEMradix .... OK, got something :
Must test with -1, -10, 1, 10, .... 10000.9999999 is set to 10001 ( 10.001,00) only with JS |
If you want to see, I have already done this work on this PR : |
Do a fix : without updating priceFormat and only in JS. But : maybe remove priceFormat and do own is a better solution ..... #423 |
…numeric input in the same group Dev: Avoid twice call of priceFormat Dev: Move the part which convert from comma back to decimal Dev: Fix survey with numerical value and thousand separator Dev: Fix script numerical_input.js : Only use when thousand_separator = 1
…numeric input in the same group Dev: Merge branch 'master' into fix_value_with_thousand_sep
…numeric input in the same group Revert chnage into application/helpers/expressions/em_manager_helper.php
Fix issue when thousands_separator = '1'.