mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '3.3' into 3.4
This commit is contained in:
commit
cf247534d5
@ -172,7 +172,8 @@ We call `setDisplayFields()` directly on the component responsible for their ren
|
|||||||
Adding a `GridField` to a page type is a popular way to manage data,
|
Adding a `GridField` to a page type is a popular way to manage data,
|
||||||
but not the only one. If your data requires a dedicated interface
|
but not the only one. If your data requires a dedicated interface
|
||||||
with more sophisticated search and management logic, consider
|
with more sophisticated search and management logic, consider
|
||||||
using the `[ModelAdmin](reference/modeladmin)` interface instead.
|
using the [ModelAdmin](/developer_guides/customising_the_admin_interface/modeladmin)
|
||||||
|
interface instead.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
![tutorial:tutorial5_project_creation.jpg](../_images/tutorial5_project_creation.jpg)
|
![tutorial:tutorial5_project_creation.jpg](../_images/tutorial5_project_creation.jpg)
|
||||||
|
@ -289,7 +289,8 @@ class Hierarchy extends DataExtension {
|
|||||||
foreach($children as $child) {
|
foreach($children as $child) {
|
||||||
$markingMatches = $this->markingFilterMatches($child);
|
$markingMatches = $this->markingFilterMatches($child);
|
||||||
if($markingMatches) {
|
if($markingMatches) {
|
||||||
if($child->$numChildrenMethod()) {
|
// Mark a child node as unexpanded if it has children and has not already been expanded
|
||||||
|
if($child->$numChildrenMethod() && !$child->isExpanded()) {
|
||||||
$child->markUnexpanded();
|
$child->markUnexpanded();
|
||||||
} else {
|
} else {
|
||||||
$child->markExpanded();
|
$child->markExpanded();
|
||||||
|
@ -59,12 +59,12 @@ class HierarchyTest extends SapphireTest {
|
|||||||
// Obj 3 has been deleted; let's bring it back from the grave
|
// Obj 3 has been deleted; let's bring it back from the grave
|
||||||
$obj3 = Versioned::get_including_deleted("HierarchyTest_Object", "\"Title\" = 'Obj 3'")->First();
|
$obj3 = Versioned::get_including_deleted("HierarchyTest_Object", "\"Title\" = 'Obj 3'")->First();
|
||||||
|
|
||||||
// Check that both obj 3 children are returned
|
// Check that all obj 3 children are returned
|
||||||
$this->assertEquals(array("Obj 3a", "Obj 3b", "Obj 3c"),
|
$this->assertEquals(array("Obj 3a", "Obj 3b", "Obj 3c", "Obj 3d"),
|
||||||
$obj3->AllHistoricalChildren()->column('Title'));
|
$obj3->AllHistoricalChildren()->column('Title'));
|
||||||
|
|
||||||
// Check numHistoricalChildren
|
// Check numHistoricalChildren
|
||||||
$this->assertEquals(3, $obj3->numHistoricalChildren());
|
$this->assertEquals(4, $obj3->numHistoricalChildren());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,11 +94,11 @@ class HierarchyTest extends SapphireTest {
|
|||||||
public function testNumChildren() {
|
public function testNumChildren() {
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj1')->numChildren(), 0);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj1')->numChildren(), 0);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2')->numChildren(), 2);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2')->numChildren(), 2);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3')->numChildren(), 3);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3')->numChildren(), 4);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2a')->numChildren(), 2);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2a')->numChildren(), 2);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2b')->numChildren(), 0);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj2b')->numChildren(), 0);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3a')->numChildren(), 2);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3a')->numChildren(), 2);
|
||||||
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3b')->numChildren(), 0);
|
$this->assertEquals($this->objFromFixture('HierarchyTest_Object', 'obj3d')->numChildren(), 0);
|
||||||
|
|
||||||
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
|
||||||
$this->assertEquals($obj1->numChildren(), 0);
|
$this->assertEquals($obj1->numChildren(), 0);
|
||||||
@ -180,6 +180,53 @@ class HierarchyTest extends SapphireTest {
|
|||||||
$this->assertEquals('Obj 2 » Obj 2a » Obj 2aa', $obj2aa->getBreadcrumbs());
|
$this->assertEquals('Obj 2 » Obj 2a » Obj 2aa', $obj2aa->getBreadcrumbs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Hierarchy::markChildren()
|
||||||
|
*/
|
||||||
|
public function testMarkChildrenDoesntUnmarkPreviouslyMarked() {
|
||||||
|
$obj3 = $this->objFromFixture('HierarchyTest_Object', 'obj3');
|
||||||
|
$obj3aa = $this->objFromFixture('HierarchyTest_Object', 'obj3aa');
|
||||||
|
$obj3ba = $this->objFromFixture('HierarchyTest_Object', 'obj3ba');
|
||||||
|
$obj3ca = $this->objFromFixture('HierarchyTest_Object', 'obj3ca');
|
||||||
|
|
||||||
|
$obj3->markPartialTree();
|
||||||
|
$obj3->markToExpose($obj3aa);
|
||||||
|
$obj3->markToExpose($obj3ba);
|
||||||
|
$obj3->markToExpose($obj3ca);
|
||||||
|
|
||||||
|
$expected = <<<EOT
|
||||||
|
<ul>
|
||||||
|
<li>Obj 3a
|
||||||
|
<ul>
|
||||||
|
<li>Obj 3aa
|
||||||
|
</li>
|
||||||
|
<li>Obj 3ab
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>Obj 3b
|
||||||
|
<ul>
|
||||||
|
<li>Obj 3ba
|
||||||
|
</li>
|
||||||
|
<li>Obj 3bb
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>Obj 3c
|
||||||
|
<ul>
|
||||||
|
<li>Obj 3c
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>Obj 3d
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$this->assertSame($expected, $obj3->getChildrenAsUL());
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetChildrenAsUL() {
|
public function testGetChildrenAsUL() {
|
||||||
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
|
||||||
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
|
||||||
@ -539,6 +586,8 @@ class HierarchyTest_Object extends DataObject implements TestOnly {
|
|||||||
"Versioned('Stage', 'Live')",
|
"Versioned('Stage', 'Live')",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $default_sort = 'Title ASC';
|
||||||
|
|
||||||
public function cmstreeclasses() {
|
public function cmstreeclasses() {
|
||||||
return $this->markingClasses();
|
return $this->markingClasses();
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,46 @@
|
|||||||
HierarchyTest_Object:
|
HierarchyTest_Object:
|
||||||
obj1:
|
obj1:
|
||||||
Title: Obj 1
|
Title: Obj 1
|
||||||
obj2:
|
obj2:
|
||||||
Title: Obj 2
|
Title: Obj 2
|
||||||
obj3:
|
obj3:
|
||||||
Title: Obj 3
|
Title: Obj 3
|
||||||
obj2a:
|
obj2a:
|
||||||
Parent: =>HierarchyTest_Object.obj2
|
Parent: =>HierarchyTest_Object.obj2
|
||||||
Title: Obj 2a
|
Title: Obj 2a
|
||||||
obj2b:
|
obj2b:
|
||||||
Parent: =>HierarchyTest_Object.obj2
|
Parent: =>HierarchyTest_Object.obj2
|
||||||
Title: Obj 2b
|
Title: Obj 2b
|
||||||
obj3a:
|
obj3a:
|
||||||
Parent: =>HierarchyTest_Object.obj3
|
Parent: =>HierarchyTest_Object.obj3
|
||||||
Title: Obj 3a
|
Title: Obj 3a
|
||||||
obj3b:
|
obj3b:
|
||||||
Parent: =>HierarchyTest_Object.obj3
|
Parent: =>HierarchyTest_Object.obj3
|
||||||
Title: Obj 3b
|
Title: Obj 3b
|
||||||
obj3c:
|
obj3c:
|
||||||
Parent: =>HierarchyTest_Object.obj3
|
Parent: =>HierarchyTest_Object.obj3
|
||||||
Title: Obj 3c
|
Title: Obj 3c
|
||||||
obj2aa:
|
obj3d:
|
||||||
Parent: =>HierarchyTest_Object.obj2a
|
Parent: =>HierarchyTest_Object.obj3
|
||||||
Title: Obj 2aa
|
Title: Obj 3d
|
||||||
obj2ab:
|
obj2aa:
|
||||||
Parent: =>HierarchyTest_Object.obj2a
|
Parent: =>HierarchyTest_Object.obj2a
|
||||||
Title: Obj 2ab
|
Title: Obj 2aa
|
||||||
obj3aa:
|
obj2ab:
|
||||||
Parent: =>HierarchyTest_Object.obj3a
|
Parent: =>HierarchyTest_Object.obj2a
|
||||||
Title: Obj 3aa
|
Title: Obj 2ab
|
||||||
obj3ab:
|
obj3aa:
|
||||||
Parent: =>HierarchyTest_Object.obj3a
|
Parent: =>HierarchyTest_Object.obj3a
|
||||||
Title: Obj 3ab
|
Title: Obj 3aa
|
||||||
|
obj3ab:
|
||||||
|
Parent: =>HierarchyTest_Object.obj3a
|
||||||
|
Title: Obj 3ab
|
||||||
|
obj3ba:
|
||||||
|
Parent: =>HierarchyTest_Object.obj3b
|
||||||
|
Title: Obj 3ba
|
||||||
|
obj3bb:
|
||||||
|
Parent: =>HierarchyTest_Object.obj3b
|
||||||
|
Title: Obj 3bb
|
||||||
|
obj3ca:
|
||||||
|
Parent: =>HierarchyTest_Object.obj3c
|
||||||
|
Title: Obj 3c
|
Loading…
Reference in New Issue
Block a user