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

Typecasting not advisable for Links #2015

Closed
mkrecek234 opened this issue Mar 2, 2023 · 10 comments · Fixed by #1991
Closed

Typecasting not advisable for Links #2015

mkrecek234 opened this issue Mar 2, 2023 · 10 comments · Fixed by #1991
Assignees

Comments

@mkrecek234
Copy link
Contributor

mkrecek234 commented Mar 2, 2023

Steps to reproduce:

  1. You have a table and add a Link decorator that uses the integer id and you have thousandSeparator set to . and an id like 123.456.
  2. Click that link.

The id is typecasted in the link, but it should not, $this is a grid:

        $this->addDecorator('order_doc_no', [\Atk4\Ui\Table\Column\Link::class,
            'url' => 'salesorderdoc.php?odaction=edit&odid={$id}']);

Expected result: Open http://salesorderdoc.php?odaction=edit&odid=123456`
Current Result: Open http://salesorderdoc.php?odaction=edit&odid=123.456`

Otherwise $app->stickyGet('odid') will return a string which it should.

@mkrecek234
Copy link
Contributor Author

mkrecek234 commented Mar 2, 2023

@mvorisek Just an idea - wouldn't it be helpful if we could pass a parameter to HtmlTemplate to optionally make it render all variables with non-typecasted field values? For Links this would be highly recommended, as you rarely pass a typecasted field value in a URL parameter.

@mvorisek
Copy link
Member

mvorisek commented Mar 2, 2023

HtmlTemplate does not do any typecasting except data are passed as Model which is probably the case here

also are special characters in URL (values) like & escaped properly?

@mkrecek234
Copy link
Contributor Author

@mvorisek Do you have any approach to solve this issue? Still I don't think we should render integers typecasted into URLs...

@mvorisek
Copy link
Member

mvorisek commented Mar 2, 2023

if the above is true, the problem I described is more problematic but not so hard to fix :), and your issue should be (in theory, if it does not target other system) irrelevant, as the input should be typecasted with back correctly

#1991 is draft PR to address bidirectional typecasting

@mkrecek234
Copy link
Contributor Author

mkrecek234 commented Mar 4, 2023

@mvorisek The more I think about it, the more I am convinced that the developer should still have a way to decide if an integer should be formatted or not. Suggestion: We introduce field type atk4_formatted_integer which will get thousandSeparator, wheres standard integer type not.

It is too strict to format all integers, even if you just want money type to have thousandSeparator.

@mvorisek
Copy link
Member

mvorisek commented Mar 4, 2023

Can you please share examples where unformatted integers should be used? I do not say they do not exist, but I am not fully convinced they are stronger. The machine readable data are not a good usecase, as they represent a different domain and different persistence must be used instead.

URL - I agree machine readable format should be used.

@mkrecek234
Copy link
Contributor Author

A product EAN barcode for example, a ticket number, a customer no., a serial number;

@mvorisek
Copy link
Member

mvorisek commented Mar 4, 2023

To be able to search them using a barcode reader (which acts as keyboard)? Otherwise SN should have spaces for better UX.

@mkrecek234
Copy link
Contributor Author

@mvorisek Any progress on the problematic handling of integer type being typecasted with thousandSeparator, even though the might be used for internal/system purposes? The current solution really is far from ideal in my opinion.

@mvorisek
Copy link
Member

mvorisek commented Apr 17, 2023

I belive the problem (for links) comes from

$rowValues = $this->getApp()->uiPersistence->typecastSaveRow($row, $row->get());

HtmlTemplate uses ui persistence only when data are passed in Model - perfect.

So we need some machine persistence stored in App. Also review the Link::getHtmlTags, it should not ignore args even if the URL template is passed, but instead of append them.

Unit test must be added into https://github.com/atk4/ui/blob/develop/tests/TableColumnLinkTest.php.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants