Skip to content

Commit 3874a90

Browse files
committed
TreeView added
1 parent 11477b5 commit 3874a90

File tree

10 files changed

+176
-11
lines changed

10 files changed

+176
-11
lines changed

Examples/twbtreeview.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* EasePHPbricks - TwitterBootstrap Switch example
4+
*
5+
*
6+
* @author Vítězslav Dvořák <vitex@arachne.cz>
7+
* @copyright 2016 Vitex Software
8+
*/
9+
10+
namespace Ease;
11+
12+
include '../vendor/autoload.php';
13+
14+
15+
16+
$oPage = new TWB\WebPage('TWB TreeView - EasePHP Bricks ');
17+
18+
$oPage->addJavaScript('
19+
function getTree() {
20+
21+
var tree = [
22+
{
23+
text: "Parent 1",
24+
nodes: [
25+
{
26+
text: "Child 1",
27+
nodes: [
28+
{
29+
text: "Grandchild 1"
30+
},
31+
{
32+
text: "Grandchild 2"
33+
}
34+
]
35+
},
36+
{
37+
text: "Child 2"
38+
}
39+
]
40+
},
41+
{
42+
text: "Parent 2"
43+
},
44+
{
45+
text: "Parent 3"
46+
},
47+
{
48+
text: "Parent 4"
49+
},
50+
{
51+
text: "Parent 5"
52+
}
53+
];
54+
return tree;
55+
}
56+
');
57+
58+
$oPage->addItem(new ui\TWBTreeView('trname', 'data: getTree()'));
59+
60+
$oPage->draw();

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ Show light or dark circle in given color.
5757
new \Ease\ui\BooleanLED(false, 'green');
5858
```
5959

60+
Tree View
61+
---------
62+
63+
Ease Support for http://jonmiles.github.io/bootstrap-treeview/ A simple and elegant solution to displaying hierarchical tree structures (i.e. a Tree View)
64+
65+
![TreeView](https://raw.githubusercontent.com/VitexSoftware/Ease-PHP-Bricks/master/TreeView.png "TreeView Widget")
66+
67+
```php
68+
new \Ease\ui\TBWTreeView('tree', 'data: getTree()');
69+
```
6070

6171

6272
Installation

TreeView.png

48.8 KB
Loading

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
},
1616
"autoload-dev": {
1717
"psr-4": {
18-
"Test\\Ease\\ui\\": "tests/src/Ease/ui"
18+
"Test\\Ease\\ui\\": "tests/src/Ease/ui",
19+
"Test\\Ease\\": "vendor/vitexsoftware/ease-framework/tests/src/Ease",
20+
"Test\\Ease\\TWB\\": "vendor/vitexsoftware/ease-framework/tests/src/Ease/TWB"
1921
}
2022
},
2123
"minimum-stability": "dev",

debian/changelog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
ease-framework-bricks (0.2) UNRELEASED; urgency=low
1+
ease-framework-bricks (0.3) UNRELEASED; urgency=low
2+
3+
* TreeView added
4+
* Release v0.3
25

3-
* Release v0.1
46

57
-- Vítězslav Dvořák <info@vitexsoftware.cz> Sun, 30 Apr 2017 11:32:37 +0200

debian/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ease-bricks",
33
"description": "Addons for PHP Framework (debianized)",
4-
"version": "0.1",
4+
"version": "0.3",
55
"authors": [
66
{
77
"name": "Vítězslav Dvořák",

debian/files

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
ease-framework-bricks-doc_0.1_all.deb doc optional
2-
ease-framework-bricks_0.1_all.deb web optional
3-
ease-framework-bricks_0.1_amd64.buildinfo - optional
1+
ease-framework-bricks-doc_0.2_all.deb doc optional
2+
ease-framework-bricks_0.2_all.deb web optional
3+
ease-framework-bricks_0.2_amd64.buildinfo - optional

src/Ease/ui/TWBTreeView.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* EasePHPbricks - TwitterBootstrap TreeView
4+
*
5+
* @link https://github.com/jonmiles/bootstrap-treeview
6+
* @author Vítězslav Dvořák <vitex@arachne.cz>
7+
* @copyright 2018 Vitex Software
8+
*/
9+
10+
namespace Ease\ui;
11+
12+
class TWBTreeView extends \Ease\Html\DivTag
13+
{
14+
/**
15+
* Properties holder
16+
* @var array
17+
*/
18+
public $properties = [];
19+
20+
/**
21+
* Twitter Bootstrap switch
22+
*
23+
* @param string $name tag name
24+
* @param array $properties tag parameters
25+
*/
26+
public function __construct($name, $properties = null)
27+
{
28+
parent::__construct(null, ['id' => $name]);
29+
$this->properties = $properties;
30+
}
31+
32+
/**
33+
* Include requied assets in page
34+
*/
35+
public function finalize()
36+
{
37+
\Ease\TWB\Part::twBootstrapize();
38+
$this->includeJavascript('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js');
39+
$this->includeCss('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css');
40+
$this->addJavascript('$(\'#'.$this->getTagID().'\').treeview({'.\Ease\TWB\Part::partPropertiesToString($this->properties).'})',
41+
null, true);
42+
}
43+
}

tests/src/Ease/ui/TWBSwitchTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3-
namespace Ease\ui;
3+
namespace Test\Ease\ui;
4+
5+
use Ease\ui\TWBSwitch;
46

57
/**
68
* Generated by PHPUnit_SkeletonGenerator on 2017-11-11 at 19:37:36.
79
*/
8-
class TWBSwitchTest extends \PHPUnit_Framework_TestCase
10+
class TWBSwitchTest extends \PHPUnit_Framework_TestCase // \Test\Ease\Html\CheckboxTagTest
911
{
1012
/**
1113
* @var TWBSwitch
@@ -27,7 +29,7 @@ protected function setUp()
2729
*/
2830
protected function tearDown()
2931
{
30-
32+
3133
}
3234

3335
/**
@@ -45,4 +47,4 @@ public function testFinalize()
4547
{
4648
$this->object->finalize();
4749
}
48-
}
50+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Test\Ease\ui;
4+
5+
use Ease\ui\TWBTreeView;
6+
7+
/**
8+
* Generated by PHPUnit_SkeletonGenerator on 2018-06-20 at 15:41:12.
9+
*/
10+
class TWBTreeViewTest extends\PHPUnit_Framework_TestCase // \Test\Ease\Html\TagTest
11+
{
12+
/**
13+
* @var TWBTreeView
14+
*/
15+
protected $object;
16+
17+
/**
18+
* Sets up the fixture, for example, opens a network connection.
19+
* This method is called before a test is executed.
20+
*/
21+
protected function setUp()
22+
{
23+
$this->object = new TWBTreeView('test', []);
24+
}
25+
26+
/**
27+
* Tears down the fixture, for example, closes a network connection.
28+
* This method is called after a test is executed.
29+
*/
30+
protected function tearDown()
31+
{
32+
33+
}
34+
35+
/**
36+
* @covers Ease\ui\TWBTreeView::finalize
37+
* @todo Implement testFinalize().
38+
*/
39+
public function testFinalize()
40+
{
41+
// Remove the following lines when you implement this test.
42+
$this->markTestIncomplete(
43+
'This test has not been implemented yet.'
44+
);
45+
}
46+
}

0 commit comments

Comments
 (0)