-
Notifications
You must be signed in to change notification settings - Fork 106
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
Feature/grid crud improvements #156
Conversation
Docs will go through #154 |
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 not sure about preventDefault. Now it will not be set by default. Is that OK?
src/CRUD.php
Outdated
@@ -87,7 +87,7 @@ public function setModel(\atk4\data\Model $m, $defaultFields = null) | |||
$m = parent::setModel($m, $this->fieldsGrid ?: $this->fieldsDefault); | |||
|
|||
if ($this->can('u')) { | |||
$this->addAction(new Icon('pencil'), new jsModal('Edit', $this->pageEdit, [$this->name=>$this->table->jsRow()->data('id')])); | |||
$this->addAction(['icon'=>'edit'], new jsModal('Edit', $this->pageEdit, [$this->name=>$this->table->jsRow()->data('id')])); |
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.
can use new Grid->jsRow() method here
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.
yes, correct. i'll update.
@@ -21,7 +27,7 @@ public function addAction($button, $callback) | |||
$this->actions[$name] = $button; | |||
$button->addClass('b_'.$name); | |||
$button->addClass('compact'); | |||
$this->table->on('click', '.b_'.$name, $callback); | |||
$this->table->on('click', '.b_'.$name, $callback, [$this->table->jsRow()->data('id'), 'confirm'=>'Are you sure?']); |
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.
Maybe we can use new $grid->jsRow() here ?
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.
agree will fix.
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.
hmm this change no longer there......
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.
nevermind.
src/View.php
Outdated
@@ -886,7 +909,7 @@ public function on($event, $selector = null, $action = null, $defaults = null) | |||
$this->js(true)->on($event, $action); | |||
} | |||
|
|||
return $thisAction; | |||
return new jQuery(); |
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.
really return empty jQuery object?
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.
that's what $thisAction was :) not that i think i might have forgotten to add it into $actions[].
if (is_numeric($key)) { | ||
$key = 'c'.$key; | ||
} | ||
$this->args[$key] = $val; |
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 line should be moved into if
statement above
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.
no it's designed like this. We keep key as-is if it's symbolic.
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.
i probably need some tests for that.
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.
yes you are right, sorry. I thought there is foreach($this->args as ...)
:)
$response = call_user_func($callback, $chain); | ||
|
||
$values = []; | ||
foreach ($this->args as $key=>$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.
to avoid Avoid unused local variables such as '$value'
warning this line should be:
foreach(array_keys($this->args) as $key) {
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.
that's more cpu/memory intensive. I prefer to ignore the warning.
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
if (is_numeric($key)) { | ||
$key = 'c'.$key; | ||
} | ||
$this->args[$key] = $val; |
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.
yes you are right, sorry. I thought there is foreach($this->args as ...)
:)
Grid is now much nicer!!
Known issues: