-
Notifications
You must be signed in to change notification settings - Fork 107
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
Big addColumn, addField and Seed refactor (PART1) #179
Big addColumn, addField and Seed refactor (PART1) #179
Conversation
…into feature/refactor-columns-fields
Updating to version 1.3 of Agile Core.. |
Given a huge scope of this commit, I propose that it would be split up into 3 stages:
It would be easier to review all PRs individually then merge them all simultaneously. Also - the current 'develop' branch is broken because it's not compatible with core/develop. |
…into feature/refactor-columns-fields
…into feature/refactor-columns-fields
With the recent addition of documentation the Form should now be a first rate citizen of Agile UI. I have used approach similar to basic elements where I start explaining it from the very basics and then gradually look at various use-cases while laying documentation against the classes, methods and properties. |
} | ||
|
||
return $this->_add($field, ['name'=>$field->short_name]); | ||
if (is_string($decorator)) { | ||
$decorator = $this->form->decoratorFactory($field, ['caption'=>$decorator]); |
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 am myself unsure about this code. IIRC, Decorator should indicate type and third argument may contain caption.
$sub->setAttr('data-tab', $item->name); | ||
|
||
//# TODO: refactor this ugly hack | ||
$item->setPath(str_replace('.php.', '.', $this->app->url($url)).'#'); |
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.
@ibelar this is a nasty hack, can you see if that can be improved?
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.
there are some comments, but also some changes required.
@@ -0,0 +1,75 @@ | |||
<?php |
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 link to this demo page in menu.
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.
should be OK for now, i suppose we will be re-making the demo suite anyways.
$f->addField('five', new \atk4\ui\FormField\Checkbox()); | ||
|
||
// can add field that does not exist in a model | ||
$f->addField('nine', new \atk4\ui\FormField\Checkbox(['caption'=>'Caption3'])); |
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 is really good option. Previously in toolkit I have had issues with this.
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.
and i think it will change again, now it's new Checkbox('Caption 4')
docs/tablecolumn.rst
Outdated
will include "sorting" icons or any other controls that go in the header of the table. | ||
|
||
The output of this field will automatically encode any values (such as caption), shorten them | ||
if necessary and localize them. |
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??
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.
confused by that text, so i deleted.
docs/tablecolumn.rst
Outdated
|
||
.. php:method:: getTotalsCellHTML(\atk4\data\Field $f, $value) | ||
|
||
Provided with the field and the value, format the cell for the footer "totals" column. Table |
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.
... footer "totals" row not column.
show it without masking just for the admin? Change type in-line for the model field:: | ||
|
||
$m = new User($app->db); | ||
$m->getElement('password')->type = 'string'; |
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.
will password save normally in this case? will it still use encoding?
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 don't think there is password encoding anywhere yet, but in this case, no , it won't use encodyngi.
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.
added note.
return $this->success('Form data has been saved'); | ||
} else { | ||
return new jsExpression('console.log([])', ['Form submission is not handled']); | ||
try { |
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.
Do we really need 3 inherited try blocks?
We can use
try {
...
} catch (\atk4\data\ValidationException $val) {
...
} catch (\Error $e) {
...
} catch (\Exception $e) {
...
}
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 leave this to you to refactor later, can you do it? I am not sure if php 5.6 supports multiple catch blocks, but 7.1 certainly good by adding https://wiki.php.net/rfc/multiple-catch.
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 didn't mean multiple-catch like catch (\Error $1 || \Exception $e2) syntax. I mean not nesting try/catch blocks.
src/FormField/Input.php
Outdated
@@ -40,6 +40,8 @@ class Input extends Generic | |||
|
|||
public $actionLeft = null; | |||
|
|||
public $width = null; |
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.
description of possible options and data type ?
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.
added.
} elseif (is_array($args) && isset($args[0])) { | ||
$args['caption'] = $args[0]; | ||
unset($args[0]); | ||
if (!is_string($name)) { |
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.
it's already defined in function definition addField(string $name, ... so isit really necessary to check that here too?
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, since user can call $layout->addField too.
$existingField->setDefaults($field); | ||
$field = $existingField; | ||
} elseif (is_object($field)) { | ||
throw new Exception(['Duplicate field', 'name'=>$name]); |
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.
in what case $field can be 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.
i feel this code still needs cleanup after latest changes to seed.
src/Grid.php
Outdated
* an. | ||
* | ||
* @param string $name New or existing column name | ||
* @param [type] $columnDef [description] |
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.
incorrect @param
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.
actually must be refactored to match Table
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.
done.
Refactor to have a consistent addField / addColumn mechanics implementing #188 and #187 as well as incorporating atk4/core#50.
Things to do: