Skip to content

Commit 3281e93

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 4d71465 + bbea761 commit 3281e93

33 files changed

+2200
-283
lines changed

.codeclimate.yml

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,48 @@ engines:
1212
exclude_fingerprints:
1313
- 908ad3f93985ff14c44615cee6966c72 # View have a lot of public methods. Deal with it.
1414
- 81ca5382dedb709060ec70ffea74e157 # allow exit in a call-back inside app constructor
15+
- 409aa7b6ded69296360c17d5c267c8dc # Grid::renderView iterates method
16+
- a4801fad2cfbf1b485de61cca855955d # Grid calls View::renderView() bypassing Lister.
17+
- 5030329ed016f46a2791c854caacb39c # Grid::getHTMLTags passes $row / $field, but $row is not used by money column
18+
- 113c8195220e554776225802db7021d6 # Persistence_Faker: Allow static access to class Faker\Factory in __construct
1519
checks:
16-
Naming/ShortVariable:
17-
enabled: false # because of on() and js() and $ui
18-
Naming/ShortMethodName:
19-
enabled: false # because of on() and js() and $ui
2020
CleanCode/ElseExpression:
2121
enabled: false # gives many incorrect suggestions
22-
Design/CouplingBetweenObjects:
23-
enabled: false # because we always allow to inject overrides!
2422
Controversial/CamelCaseClassName:
2523
enabled: false # because jQuery.php and similar class names
26-
Controversial/CamelCasePropertyName:
27-
enabled: false # becasue we use _xx for private properties (that must remain public)
2824
Controversial/CamelCaseMethodName:
2925
enabled: false # methods start with _xx for private methods (that must remain public)
30-
Design/WeightedMethodCount:
31-
enabled: false # because we solve complex task, our classes may be complex
32-
Design/NpathComplexity:
26+
Controversial/CamelCaseParameterName:
27+
enabled: false # allow parameter names to not use camelCase notation
28+
Controversial/CamelCasePropertyName:
29+
enabled: false # becasue we use _xx for private properties (that must remain public)
30+
Controversial/CamelCaseVariableName:
31+
enabled: false # because we call variables $f_login, $m_user for better readability.
32+
Controversial/Superglobals:
33+
enabled: false # yes we use superglobals and that's OK
34+
CyclomaticComplexity:
3335
enabled: false # our code is complex so that your code wouldn't be!
36+
CleanCode/BooleanArgumentFlag:
37+
enabled: false # sometimes it is meaningful to pass boolean arguments to methods
38+
Design/CouplingBetweenObjects:
39+
enabled: false # because we always allow to inject overrides!
3440
Design/LongMethod:
3541
enabled: false # our code is long so that your code wouldn't be!
36-
CyclomaticComplexity:
42+
Design/NpathComplexity:
3743
enabled: false # our code is complex so that your code wouldn't be!
38-
Controversial/CamelCaseVariableName:
39-
enabled: false # because we call variables $f_login, $m_user for better readability.
44+
Design/TooManyMethods:
45+
enabled: false # methods never should be to many
46+
Design/TooManyPublicMethods:
47+
enabled: false # it is OK that some classes have more than 12 public methods
48+
Design/WeightedMethodCount:
49+
enabled: false # because we solve complex task, our classes may be complex
50+
Naming/ShortMethodName:
51+
enabled: false # because of on() and js() and $ui
52+
Naming/ShortVariable:
53+
enabled: false # because of on() and js() and $ui
54+
# THERE IS MUCH TO MUCH OF THESE ERRORS - TEMPORARILY DISABLE THIS CHECK
55+
UnusedFormalParameter:
56+
enabled: false
4057
radon:
4158
enabled: true
4259
ratings:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.0.0
2+
3+
* Implement Grid
4+
* Many improvements everywhere
5+
* Simpler execution
6+
* First stable release
7+
18
## 0.4
29

310
* Implemented Layouts (Admin / Centered) #33

README.md

Lines changed: 152 additions & 100 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
],
1515
"require": {
1616
"php": ">=5.6.0",
17-
"atk4/data": "^1.1.8",
18-
"atk4/core": "^1.1.9",
19-
"facebook/webdriver": "^1.1"
17+
"atk4/data": "^1.1.9",
18+
"atk4/core": "^1.1.11"
2019
},
2120
"require-dev": {
2221
"phpunit/phpunit": "4.*",
23-
"facebook/webdriver": "^1.1",
24-
"phpunit/phpunit-selenium": ">=1.2",
2522
"fzaninotto/faker": "*",
26-
"atk4/core": "^1.1.9",
2723
"semantic/ui": "*",
2824
"codeclimate/php-test-reporter": "*"
2925
},

demos/button2.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717

1818
$layout->add(new H2('Basic Button'));
1919

20+
// This button hides on page load
2021
$b = $layout->add(new Button(['id'=>'b1']))->set('Hidden Button');
2122
$b->js(true)->hide();
2223

24+
// This button hides when clicked
2325
$b = $layout->add(new Button(['id'=>'b2']))->set('Hide on click Button');
2426
$b->js('click')->hide();
2527

2628
$layout->add(new H2('Callbacks'));
2729

30+
// On button click reload it and change it's title
2831
$b = $layout->add(new Button(['id'=>'b3']))->set('Callback Test');
2932
$b->on('click', function ($b) {
3033
return $b->text(rand(1, 20));

demos/grid.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
date_default_timezone_set('UTC');
4+
include 'init.php';
5+
6+
$bb = $layout->add('Buttons');
7+
$bb->add(['Button', 'Refresh Grid', 'icon'=>'refresh']);
8+
9+
$g = $layout->add(['Grid', 'celled'=>true]);
10+
11+
$bb->on('click', $g->js()->reload());
12+
13+
$g->setModel(new SomeData());
14+
$g->addColumn('name', new \atk4\ui\Column\Link(['details', 'id'=>'{$id}']));
15+
$g->addColumn('surname', new \atk4\ui\Column\Template('<td class="warning">{$surname}</td>'));
16+
$g->addColumn('title', new \atk4\ui\Column\Status([
17+
'positive'=> ['Prof.'],
18+
'negative'=> ['Dr.'],
19+
]));
20+
21+
$g->addColumn('date');
22+
$g->addColumn('salary', new \atk4\ui\Column\Money()); //->addClass('right aligned single line', 'all'));
23+
24+
$g->addHook('getHTMLTags', function ($grid, $row) {
25+
if ($row->id == 1) {
26+
return [
27+
'name'=> $grid->app->getTag('div', ['class'=>'ui ribbon label'], $row['name']),
28+
];
29+
}
30+
});
31+
32+
$g->addTotals(['name'=>'Totals:', 'salary'=>['sum']]);

demos/init.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require '../vendor/autoload.php';
44

5-
$app = new \atk4\ui\App('Agile UI - Demo Suite', ['icon'=>'user']);
5+
$app = new \atk4\ui\App('Agile UI v0.4 - Demo Suite', ['icon'=>'user']);
66

77
$app->initLayout((isset($_GET['layout']) && $_GET['layout'] === 'centered') ? 'Centered' : 'Admin');
88

@@ -14,11 +14,15 @@
1414

1515
$layout->leftMenu->addItem(['Welcome Page', 'icon'=>'gift'], ['index']);
1616
$layout->leftMenu->addItem(['Layouts', 'icon'=>'object group'], ['layouts']);
17+
1718
$form = $layout->leftMenu->addGroup(['Form', 'icon'=>'edit']);
1819
$form->addItem('Basics and Layouting', ['form']);
1920
$form->addItem('Input Field Decoration', ['field']);
2021
$form->addItem('Data Integration', ['form2']);
2122

23+
$form = $layout->leftMenu->addGroup(['Grid', 'icon'=>'table']);
24+
$form->addItem('Column Formats and Features', ['grid']);
25+
2226
$basic = $layout->leftMenu->addGroup(['Basics', 'icon'=>'cubes']);
2327
$basic->addItem('Button', ['button']);
2428
$basic->addItem('Header', ['header']);
@@ -33,3 +37,5 @@
3337
->setAttr('target', '_blan')->on('click', new \atk4\ui\jsExpression('document.location=[];', ['https://github.com/atk4/ui/blob/develop/demos/'.$f]));
3438

3539
$img = 'https://github.com/atk4/ui/raw/07208a0af84109f0d6e3553e242720d8aeedb784/public/logo.png';
40+
41+
require_once 'somedatadef.php';

demos/layout.php

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,14 @@
33
* Demonstrates how to use layouts.
44
*/
55
require '../vendor/autoload.php';
6+
require 'somedatadef.php';
67
date_default_timezone_set('UTC');
78

89
$layout = new \atk4\ui\Layout\Generic(['defaultTemplate'=>'./templates/layout1.html']);
910

10-
class Persistence_Faker extends \atk4\data\Persistence
11-
{
12-
public $faker = null;
13-
14-
public $count = 50;
15-
16-
public function __construct($opts = [])
17-
{
18-
//parent::__construct($opts);
19-
20-
if (!$this->faker) {
21-
$this->faker = Faker\Factory::create();
22-
}
23-
}
24-
25-
public function prepareIterator($m)
26-
{
27-
foreach ($this->export($m) as $row) {
28-
yield $row;
29-
}
30-
}
31-
32-
public function export($m, $fields = [])
33-
{
34-
if (!$fields) {
35-
foreach ($m->elements as $name=>$e) {
36-
if ($e instanceof \atk4\data\Field) {
37-
$fields[] = $name;
38-
}
39-
}
40-
}
41-
42-
$data = [];
43-
for ($i = 0; $i < $this->count; $i++) {
44-
$row = [];
45-
foreach ($fields as $field) {
46-
$type = $field;
47-
48-
if ($field == $m->id_field) {
49-
$row[$field] = $i + 1;
50-
continue;
51-
}
52-
53-
$actual = $m->getElement($field)->actual;
54-
if ($actual) {
55-
$type = $actual;
56-
}
57-
58-
$row[$field] = $this->faker->$type;
59-
}
60-
$data[] = $row;
61-
}
62-
63-
return array_map(function ($r) use ($m) {
64-
return $this->typecastLoadRow($m, $r);
65-
}, $data);
66-
}
67-
}
68-
6911
try {
70-
$p = new Persistence_Faker();
71-
72-
$m = new \atk4\data\Model($p);
73-
74-
$m->addField('date', ['type'=>'date']);
75-
$m->addField('contact', ['actual'=>'name']);
76-
7712
$layout->add(new \atk4\ui\Lister(), 'Report')
78-
->setModel($m);
13+
->setModel(new Somedata());
7914

8015
echo $layout->render();
8116
} catch (\atk4\core\Exception $e) {

demos/somedatadef.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
if (!class_exists('SomeData')) {
4+
class SomeData extends \atk4\data\Model
5+
{
6+
public function __construct()
7+
{
8+
$p = new Persistence_Faker();
9+
10+
parent::__construct($p);
11+
}
12+
13+
public function init()
14+
{
15+
parent::init();
16+
$m = $this;
17+
18+
$m->addField('title');
19+
$m->addField('name');
20+
$m->addField('surname', ['actual'=>'name']);
21+
$m->addField('date', ['type'=>'date']);
22+
$m->addField('salary', ['type'=>'money', 'actual'=>'randomNumber']);
23+
}
24+
}
25+
26+
class Persistence_Faker extends \atk4\data\Persistence
27+
{
28+
public $faker = null;
29+
30+
public $count = 50;
31+
32+
public function __construct($opts = [])
33+
{
34+
//parent::__construct($opts);
35+
36+
if (!$this->faker) {
37+
$this->faker = Faker\Factory::create();
38+
}
39+
}
40+
41+
public function prepareIterator($m)
42+
{
43+
foreach ($this->export($m) as $row) {
44+
yield $row;
45+
}
46+
}
47+
48+
public function export($m, $fields = [])
49+
{
50+
if (!$fields) {
51+
foreach ($m->elements as $name=>$e) {
52+
if ($e instanceof \atk4\data\Field) {
53+
$fields[] = $name;
54+
}
55+
}
56+
}
57+
58+
$data = [];
59+
for ($i = 0; $i < $this->count; $i++) {
60+
$row = [];
61+
foreach ($fields as $field) {
62+
$type = $field;
63+
64+
if ($field == $m->id_field) {
65+
$row[$field] = $i + 1;
66+
continue;
67+
}
68+
69+
$actual = $m->getElement($field)->actual;
70+
if ($actual) {
71+
$type = $actual;
72+
}
73+
74+
$row[$field] = $this->faker->$type;
75+
}
76+
$data[] = $row;
77+
}
78+
79+
return array_map(function ($r) use ($m) {
80+
return $this->typecastLoadRow($m, $r);
81+
}, $data);
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)