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 #629, also add new Callback for custom HTML #643
Conversation
Adds property renderRowFunction, which can be used to pass custom html options to renderView for each option. If not defined, only needed title_field and id_field are used
Some thoughts about this:
|
Codecov Report
@@ Coverage Diff @@
## develop #643 +/- ##
============================================
- Coverage 69.81% 69.8% -0.02%
Complexity 1853 1853
============================================
Files 100 100
Lines 4377 4382 +5
============================================
+ Hits 3056 3059 +3
- Misses 1321 1323 +2
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #643 +/- ##
=============================================
- Coverage 66.05% 66.02% -0.04%
- Complexity 2223 2233 +10
=============================================
Files 118 118
Lines 5235 5262 +27
=============================================
+ Hits 3458 3474 +16
- Misses 1777 1788 +11
Continue to review full report at Codecov.
|
src/FormField/DropDown.php
Outdated
//record to callback | ||
if (is_callable($this->renderRowFunction)) { | ||
foreach ($this->model as $key => $row) { | ||
$options[] = call_user_func($this->renderRowFunction, $row); |
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.
could use
array_merge(
['div', 'class' => 'item', 'data-value' => (string) $key, [$row->getTitle()]],
call_user_func(...)
)
here so you don't have to always set all parameters in callback - just overwrite the ones you need.
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.
Also it would be good to add same callback function support below if model is not set ($this->values is).
In this line https://github.com/atk4/ui/pull/643/files#diff-4b67e9492f67665780c2571ad53ebb68R225
Both things sound very sensible. Just don't get how to change files in my pull request... You gotta show me someday how to sensibly create atk4 pr s |
Missing documentation and examples.. |
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.
need documentation and examples..
otherwise i like the idea.
@PhilippGrashoff if you're mostly Windows guy like me or Mac and don't like to type every single command from command line then you can use free SmartGit program. It works very well. I use it for a few years - makes all git stuff a lot simpler and with nice UI. P.S. I can't add changes in branch in your github account, so you'll have to make them yourself. |
@DarkSide666 maybe have a short Skype conversation sometime. I think my whole approach to creating PRs for atk is crap :) p.s: I'm a Linux guy and using Gitkraken. |
If this is the case, I am also in line. One 30 minutes session can help, a bunch of bad "pull requesters" like me in action ;) |
How about we have a weekly on-line session where we discuss all hot issues and also help contributors? I would certainly attend, but I'd prefer someone else to do the admin stuff (announce, etc) |
Sounds good. I'd just need some push in the right direction for creating prs from git software. At the moment I edit the file on github.com by copy pasting the changes :) didn't get any atk4 pr to work in another way yet |
i'm the king of PR messing :D in the last week i start thinking about start streaming on twitch out of working time while i'm coding/debug things just to do something and see what would happen. I think a project like atk4 need more help to grow and make it better, we started an app for a client 3 weeks ago and we are near releasing alpha and considering time for debugging some atk4 things, it's unreal |
Agreed on that,
A short pull request system explained will help other willing contributors
in action.
[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
02/21/19,
10:24:31 AM
…On Wed, Feb 20, 2019 at 6:19 PM Francesco Danti ***@***.***> wrote:
i'm the king of PR messing :D in the last week i start thinking about
start streaming on twitch out of working time while i'm coding/debug things
just to do something and see what would happen.
I think a project like atk4 need more help to grow and make it better, we
started an app for a client 3 weeks ago and we are near releasing alpha and
considering time for debugging some atk4 things, it's unreal
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#643 (comment)>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AA9hU2yMuihx9Ev4yRc9VAN1bnsMSrryks5vPURQgaJpZM4ad23H>
.
--
-- Regards
*Gowrav Vishwakarma*
Founder & Managing Director
*Xavoc Technocrats Pvt. Ltd.*
http://www.xavoc.com
contact: +91 961-0005-727, 723-0005-787
|
note: inconsistent with https://github.com/atk4/ui/blob/develop/src/Table.php#L504. Then again - i think that dropdown does not implement hook trait. |
Hi,
Best regards |
@PhilippGrashoff if you are willing to improve your PR, - sure by all means, close this one and create a new on! And thanks again for contributing. |
- use Subtemplate for row rendering instead of $app->getTag(). Makes customization easier if needed (e.g. display complex HTML per row) - implement renderRowFunction which can be used to easily customize dropdown row rendering
HI there, I refactored renderView quite a bit and used a subtemplate for row's HTML instead of $app->getTag(). Why?
Now the
I didnt write any tests or documentation yet as I am not sure if what I did is the ATK way. I like it like this. Please give me some feedback and if you think this is fine I will provide documentation. |
Sorry for not mentioning it right away - some examples in demo/ would be also nice. Here is a spot for docs: https://github.com/atk4/ui/blob/develop/docs/field.rst#dropdown (although it's really sparse there) Finally - didn't we switch from "DropDown" to "Lookup" as a default dropdown implementation? |
HI Romans, |
@PhilippGrashoff actually, me and @ibelar made Lookup to be a copy of Dropdown then enhanced it. The idea was to remove DropDown but then we forgot 😢 |
We can probably move one of those two into an add-on. |
After a quick read of Lookup code:
To me it looks more as if Lookup was to replace AutoComplete, not Dropdown. |
+1 for keeping dropdown, as
|
@PhilippGrashoff is right. New Lookup was for replacing Autocomplete. We should keep Dropdown. |
Sorry, i was confused, we're obsoleting AutoComplete, not Dropdown. |
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.
good!
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.
Looks okay, just need documentation and demos
Added Docs, but am too stupid to get the markup right. Will read into it. |
dropdown-plus.php existed, but was not linked in demo menu
Hi, I also added Demos, but didnt test them yet as I am not sure how to do this best. Also, the formatting of the docs aint correct in some places. |
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.
Tests fail:
PHP Fatal error: Cannot use empty array elements in arrays in /home/travis/build/atk4/ui/demos/dropdown-plus.php on line 35
Adds property renderRowFunction, which can be used to pass custom html options to renderView for each option.
If not defined, only needed title_field and id_field are used. (and system fields, they are also loaded when using only_fields()).