-
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
Finally implementing Grid #93
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
982cbb2
fixes #86
DarkSide666 b7aa1ab
comment unused variables
DarkSide666 0a11fe0
fix codeclimate
DarkSide666 c6a5258
Initial implementation of Label class
romaninsh 1955f05
Apply fixes from StyleCI
romaninsh 02fcb4b
Merge branch 'develop' into feature/implement-label
romaninsh 15899b4
prevent multi-render, resolve #85
romaninsh 0580f8f
prevent multi-render, resolve #85
romaninsh 2008f38
rename .jade to .pug
romaninsh 812310c
Merge branch 'feature/fix-86' into feature/grid-part3
romaninsh 38afc03
Merge branch 'feature/implement-label' into feature/grid-part3
romaninsh be9f270
Merge branch 'feature/rename-jade-to-pug' into feature/grid-part3
romaninsh 93ac5cf
Implement Grid - added bar, actions, checkboxes
romaninsh 02129bc
Apply fixes from StyleCI
romaninsh 2f87594
Merge branch 'develop' into feature/grid-part3
romaninsh 0f89853
various improvements
romaninsh 239a284
finally a good logic
romaninsh bcb9c2e
Fixed bugs with variable names
romaninsh 2995007
Merge branch 'develop' into feature/grid-part3
romaninsh bbd3892
better use $g because $m is "reserved" for model :)
DarkSide666 bb9033b
fixed this once
DarkSide666 7fd74d0
add comments
DarkSide666 332c0e8
correct comment
DarkSide666 f432f2c
add comment
DarkSide666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require 'init.php'; | ||
require 'database.php'; | ||
|
||
$g = $layout->add(['Grid']); | ||
$g->setModel(new Country($db)); | ||
$g->addQuickSearch(); | ||
|
||
$g->menu->addItem(['Add Country', 'icon'=>'add square'], new \atk4\ui\jsExpression('alert(123)')); | ||
$g->menu->addItem(['Re-Import', 'icon'=>'power']); | ||
$g->menu->addItem(['Delete All', 'icon'=>'trash', 'red active']); | ||
|
||
$g->addAction('Say HI', new \atk4\ui\jsExpression('alert("hi")')); | ||
$g->addAction(['icon'=>'pencil'], new \atk4\ui\jsExpression('alert($(this).closest("tr").data("id"))')); | ||
|
||
$sel = $g->addSelection(); | ||
$g->menu->addItem('show selection')->on('click', new \atk4\ui\jsExpression( | ||
'alert("Selected: "+[].join(", "))', [$sel->jsChecked()] | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
// vim:ts=4:sw=4:et:fdm=marker:fdl=0 | ||
|
||
namespace atk4\ui; | ||
|
||
/** | ||
* Implements a more sophisticated and interractive Data-Table component. | ||
*/ | ||
class Grid extends View | ||
{ | ||
public $menu = null; | ||
|
||
public $quickSearch = null; | ||
|
||
public $table = null; | ||
|
||
public $buttons = null; | ||
|
||
public $actions = null; | ||
|
||
public $defaultTemplate = 'grid.html'; | ||
|
||
public $ipp = 20; | ||
|
||
public $paginator = null; | ||
|
||
public $selection = null; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
if (!$this->menu) { | ||
$this->menu = $this->add(['Menu', 'activate_on_click'=>false], 'Menu'); | ||
} | ||
|
||
if (!$this->table) { | ||
$this->table = $this->add(['Table', 'very compact'], 'Table'); | ||
} | ||
} | ||
|
||
public function addButton($text) | ||
{ | ||
return $this->menu->addItem()->add(new Button($text)); | ||
} | ||
|
||
public function addQuickSearch($fields = []) | ||
{ | ||
if (!$fields) { | ||
$fields = [$this->model->title_field]; | ||
} | ||
|
||
$x = $this->menu->addMenuRight(); | ||
$this->quickSearch = $x->addItem()->setElement('div')->add(new \atk4\ui\FormField\Input(['placeholder'=>'Search', 'icon'=>'search']))->addClass('transparent'); | ||
} | ||
|
||
public function addAction($label, $action) | ||
{ | ||
if (!$this->actions) { | ||
$this->actions = $this->table->addColumn('TableColumn/Actions'); | ||
} | ||
|
||
$this->actions->addAction($label, $action); | ||
} | ||
|
||
public function setModel(\atk4\data\Model $model, $columns = null) | ||
{ | ||
return $this->model = $this->table->setModel($model, $columns)->setLimit($this->ipp); | ||
} | ||
|
||
public function addSelection() | ||
{ | ||
$this->selection = $this->table->addColumn('TableColumn/Checkbox'); | ||
|
||
// Move element to the beginning | ||
$k = array_search($this->selection, $this->table->columns); | ||
$this->table->columns = [$k => $this->table->columns[$k]] + $this->table->columns; | ||
|
||
return $this->selection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
moved to View