Skip to content
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

Fix typecasting for TreeView #2022

Closed
wants to merge 5 commits into from
Closed

Fix typecasting for TreeView #2022

wants to merge 5 commits into from

Conversation

mkrecek234
Copy link
Contributor

Solves issue #2021

@mkrecek234 mkrecek234 requested a review from mvorisek March 16, 2023 14:03
@mkrecek234
Copy link
Contributor Author

mkrecek234 commented Mar 16, 2023

Fix above works for single value treeItem correctly, however for multiple-value item the typecastLoadField does not support json yet. @mvorisek Can you check please? The sample with multiple-value is not working anymore:

$control->set([201, 301, 503]);

Copy link
Member

@mvorisek mvorisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be right. You cannot mix load/save typecasting direction.

And as posted originally, I would like to have this tested by Behat. Not only to prevent it into the future, but as not tested, it was not fixed yet nor with #1991.

@mkrecek234
Copy link
Contributor Author

This cannot be right. You cannot mix load/save typecasting direction.

And as posted originally, I would like to have this tested by Behat. Not only to prevent it into the future, but as not tested, it was not fixed yet nor with #1991.

Has to be typecastLoadField and not save which was wrong in the original code. However, the jsonarray data type is not supported, may be you can have a look at it. For integer it is properly working with the initial fix

@mvorisek
Copy link
Member

mvorisek commented Mar 16, 2023

"load" direction is almost surely wrong, as "load" direction implies a value to be loaded from an input, which is probably not the case here

@mkrecek234
Copy link
Contributor Author

Valid point - the key solution has to be that scalar values shall not be typecasted (see latest commit), as the Vue component cannot handle ids with thousandSeparator. Still typecasting for non-scalars.

Working and tested now in live setup and demos, sorry behat test has to be provided by another contributor

@mvorisek
Copy link
Member

Still the fix is wrong, the ID can be internally stored as any type - see #1991 prooving this case - ID wrapped in an object.

@mkrecek234
Copy link
Contributor Author

Would appreciate to see your improved code proposal - the current implementation in develop branch is definitely wrong, and also not working in a defined setup

@mvorisek
Copy link
Member

The main question is why is the typecast an issue. Any fix of getValue method will introduce inconsistency with Form\Control\Input::getValue() method. I am currently out of the time to look into this as the proper fix incl. test might take MD easily.

@mkrecek234
Copy link
Contributor Author

The main question is why is the typecast an issue. Any fix of getValue method will introduce inconsistency with Form\Control\Input::getValue() method. I am currently out of the time to look into this as the proper fix incl. test might take MD easily.

The Vue TreeItemSelector does not support an Input field value which has thousandSeparator, so ID = 1.750 will not work, even though Atk4 saves and loads it properly. The input field thus has to have a non-typecasted ID inside, otherwise TreeViewItemSelector will not mark the correct item as active.

@mkrecek234
Copy link
Contributor Author

mkrecek234 commented Mar 17, 2023

The main reason for the above issue is simply that treeItems id values are not typecasted, whereas the currently selected value(s) are typecasted. The Vue component simply then cannot match the correct items.
So either we typecast the treeItems node id values or we do not typecast the input current value. In the light of the discussion, as those values are all "hidden" system value, typecasting of integers does not add any value here in my opinion.

Copy link
Member

@mvorisek mvorisek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please understand the solution you provided cannot work with #1991, ie. the fix is still not correct, there is no reason to handle scalars differently as long as there are not handled differently on reverse typecasting - they are not and never will be.

The correct way to fix this problem is to:
a) provide minimalistic test cases - basic, and if not needed, for edge cases too
b) verify the visible data/integers/datatimes (objects) are typecasted correctly
c) verify all cases/save etc. are fixed properly
d) verify the TreeView coverage has increased (open CodeCov and check uncovered lines, regular scenarios must be covered)

@mvorisek
Copy link
Member

mvorisek commented Sep 6, 2023

Let's start with a failing test.

@mvorisek mvorisek marked this pull request as draft October 14, 2023 23:33
@mvorisek mvorisek closed this Oct 14, 2023
@mvorisek mvorisek deleted the bug_tree_view branch October 14, 2023 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants