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/Generic Input onChange event #725

Merged
merged 8 commits into from
Jun 3, 2019
Merged

Conversation

ibelar
Copy link
Contributor

@ibelar ibelar commented Jun 2, 2019

  • Allow to pass extra argument to onChange event handler.

ex: When you need to set values of the second Dropdown according to user selected value of the first Dropdown.

$dropdown->onChange(function($j) use ($other_dropdown) {
     return $other_dropdown->js()->dropdown('change values', $this->getValues($_POST['selected_id']?? null));
}, ['args' => ['selected_id' => $dropdown->jsInput()->val()]]);

function getValues($id)
{
   // get values
  // return this format
  return [['value' => 'value', 'text' => 'text', 'name' => 'name']];
}

This will make $_POST['selected_id'] available in server request callback. Then you can setup other Dropdown values accordingly.

ibelar and others added 4 commits June 2, 2019 12:25
- Allow to pass extra argument to onChange event hander.
Calendar onChange input call
@codecov
Copy link

codecov bot commented Jun 2, 2019

Codecov Report

Merging #725 into develop will decrease coverage by 25.49%.
The diff coverage is 0%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #725      +/-   ##
=============================================
- Coverage      68.65%   43.16%   -25.5%     
- Complexity      2055     2059       +4     
=============================================
  Files            106      106              
  Lines           4837     4993     +156     
=============================================
- Hits            3321     2155    -1166     
- Misses          1516     2838    +1322
Impacted Files Coverage Δ Complexity Δ
src/FormField/Generic.php 45.83% <0%> (-50.01%) 11 <2> (ø)
src/AccordionSection.php 0% <0%> (-100%) 3% <0%> (ø)
src/HelloWorld.php 0% <0%> (-100%) 1% <0%> (ø)
src/Layout/Centered.php 0% <0%> (-100%) 1% <0%> (ø)
src/FormField/Radio.php 0% <0%> (-100%) 16% <0%> (ø)
src/FormField/Money.php 0% <0%> (-100%) 6% <0%> (ø)
src/Columns.php 0% <0%> (-100%) 10% <0%> (ø)
src/TableColumn/Password.php 0% <0%> (-100%) 1% <0%> (ø)
src/FormLayout/Section/Generic.php 0% <0%> (-100%) 1% <0%> (ø)
src/FormField/TextArea.php 0% <0%> (-100%) 5% <0%> (ø)
... and 72 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18ce128...cf13679. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 2, 2019

Codecov Report

Merging #725 into develop will decrease coverage by 0.04%.
The diff coverage is 50%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #725      +/-   ##
=============================================
- Coverage      68.65%   68.61%   -0.05%     
- Complexity      2055     2058       +3     
=============================================
  Files            106      106              
  Lines           4837     4840       +3     
=============================================
  Hits            3321     3321              
- Misses          1516     1519       +3
Impacted Files Coverage Δ Complexity Δ
src/FormField/Radio.php 92.59% <50%> (-7.41%) 17 <3> (+1)
src/FormField/Generic.php 88% <50%> (-7.84%) 12 <3> (+1)
src/FormField/Calendar.php 77.77% <50%> (-6.84%) 11 <4> (+1)
src/TableColumn/Status.php 82.35% <0%> (+8.82%) 12% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18ce128...e2a2f0e. Read the comment docs.

Radio::onChange
// 'paymentRelations' => ['invoice_id' => 'id', 'client_id' => 'client_id'],
// 'paymentEditFields' => ['method', 'paid_on', 'amount', 'details'],
// 'paymentDisplayFields' => ['client','balance', 'paid_total','total'],
// ]));
Copy link
Member

Choose a reason for hiding this comment

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

is that a functional demo? everything is commented apart from a table.

@@ -134,10 +134,11 @@ public function renderView()
*
* @param string|jsExpression|array|callable $expr
* @param bool $useDefault
Copy link
Member

Choose a reason for hiding this comment

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

remove this line.

*
* @throws \atk4\ui\Exception
*/
public function onChange($expr, $useDefault = true)
public function onChange($expr, $useDefault = true, $default = [])
Copy link
Member

Choose a reason for hiding this comment

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

get rid of 2nd arg

*
* @throws \atk4\ui\Exception
*/
public function onChange($expr, $useDefault = true)
public function onChange($expr, $useDefault = true, $default = [])
{
if (is_string($expr)) {
$expr = new \atk4\ui\jsExpression($expr);
Copy link
Member

Choose a reason for hiding this comment

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

if is_bool($default) {

ibelar and others added 2 commits June 3, 2019 11:56
- remove extra argument
  - test for boolean for backward compatibility
- remove unecessary demo file
@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #725 into develop will decrease coverage by 0.04%.
The diff coverage is 50%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #725      +/-   ##
=============================================
- Coverage      68.65%   68.61%   -0.05%     
- Complexity      2055     2058       +3     
=============================================
  Files            106      106              
  Lines           4837     4840       +3     
=============================================
  Hits            3321     3321              
- Misses          1516     1519       +3
Impacted Files Coverage Δ Complexity Δ
src/FormField/Radio.php 92.59% <50%> (-7.41%) 17 <3> (+1)
src/FormField/Generic.php 88% <50%> (-7.84%) 12 <3> (+1)
src/FormField/Calendar.php 77.77% <50%> (-6.84%) 11 <4> (+1)
src/TableColumn/Status.php 82.35% <0%> (+8.82%) 12% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18ce128...e2a2f0e. Read the comment docs.

Copy link
Member

@romaninsh romaninsh left a comment

Choose a reason for hiding this comment

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

LGTM

@romaninsh romaninsh merged commit 696f79c into develop Jun 3, 2019
@romaninsh romaninsh deleted the fix/generic-input-onchange branch June 3, 2019 17:02
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 this pull request may close these issues.

2 participants