mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.3' into 4.4
This commit is contained in:
commit
4b44272367
@ -214,6 +214,9 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var GridFieldDataColumns|null $gridFieldColumnsComponent */
|
||||||
|
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
|
|
||||||
/** @var DataObject $item */
|
/** @var DataObject $item */
|
||||||
foreach ($items->limit(null) as $item) {
|
foreach ($items->limit(null) as $item) {
|
||||||
if (!$item->hasMethod('canView') || $item->canView()) {
|
if (!$item->hasMethod('canView') || $item->canView()) {
|
||||||
@ -228,6 +231,10 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
}
|
}
|
||||||
|
|
||||||
$value = $columnHeader($relObj);
|
$value = $columnHeader($relObj);
|
||||||
|
} elseif ($gridFieldColumnsComponent) {
|
||||||
|
$value = strip_tags(
|
||||||
|
$gridFieldColumnsComponent->getColumnContent($gridField, $item, $columnSource)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$value = $gridField->getDataFieldValue($item, $columnSource);
|
$value = $gridField->getDataFieldValue($item, $columnSource);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var GridFieldDataColumns $dataCols */
|
/** @var GridFieldDataColumns $dataCols */
|
||||||
$dataCols = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
$dataCols = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
if ($dataCols) {
|
if ($dataCols) {
|
||||||
return $dataCols->getDisplayFields($gridField);
|
return $dataCols->getDisplayFields($gridField);
|
||||||
}
|
}
|
||||||
@ -223,12 +223,17 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
|||||||
$items = $gridField->getManipulatedList();
|
$items = $gridField->getManipulatedList();
|
||||||
$itemRows = new ArrayList();
|
$itemRows = new ArrayList();
|
||||||
|
|
||||||
|
/** @var GridFieldDataColumns $gridFieldColumnsComponent */
|
||||||
|
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
|
|
||||||
/** @var DataObject $item */
|
/** @var DataObject $item */
|
||||||
foreach ($items->limit(null) as $item) {
|
foreach ($items->limit(null) as $item) {
|
||||||
$itemRow = new ArrayList();
|
$itemRow = new ArrayList();
|
||||||
|
|
||||||
foreach ($printColumns as $field => $label) {
|
foreach ($printColumns as $field => $label) {
|
||||||
$value = $gridField->getDataFieldValue($item, $field);
|
$value = $gridFieldColumnsComponent
|
||||||
|
? strip_tags($gridFieldColumnsComponent->getColumnContent($gridField, $item, $field))
|
||||||
|
: $gridField->getDataFieldValue($item, $field);
|
||||||
|
|
||||||
$itemRow->push(new ArrayData(array(
|
$itemRow->push(new ArrayData(array(
|
||||||
"CellString" => $value,
|
"CellString" => $value,
|
||||||
|
@ -403,7 +403,7 @@ class DataQuery
|
|||||||
// Find the first free "_SortColumnX" slot
|
// Find the first free "_SortColumnX" slot
|
||||||
// and assign it to $key
|
// and assign it to $key
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while (isset($orderby[$key = "\"_SortColumn$i\""])) {
|
while (isset($newOrderby[$key = "\"_SortColumn$i\""]) || isset($orderby[$key = "\"_SortColumn$i\""])) {
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ class DataQueryTest extends SapphireTest
|
|||||||
DataQueryTest\ObjectE::class,
|
DataQueryTest\ObjectE::class,
|
||||||
DataQueryTest\ObjectF::class,
|
DataQueryTest\ObjectF::class,
|
||||||
DataQueryTest\ObjectG::class,
|
DataQueryTest\ObjectG::class,
|
||||||
|
DataQueryTest\ObjectH::class,
|
||||||
|
DataQueryTest\ObjectI::class,
|
||||||
SQLSelectTest\TestObject::class,
|
SQLSelectTest\TestObject::class,
|
||||||
SQLSelectTest\TestBase::class,
|
SQLSelectTest\TestBase::class,
|
||||||
SQLSelectTest\TestChild::class,
|
SQLSelectTest\TestChild::class,
|
||||||
@ -443,4 +445,25 @@ class DataQueryTest extends SapphireTest
|
|||||||
$this->assertContains('Bar', $result);
|
$this->assertContains('Bar', $result);
|
||||||
$this->assertContains('Foo', $result);
|
$this->assertContains('Foo', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that sorting against multiple relationships is working
|
||||||
|
*/
|
||||||
|
public function testMultipleRelationSort()
|
||||||
|
{
|
||||||
|
$query = new DataQuery(DataQueryTest\ObjectH::class);
|
||||||
|
$query->applyRelation('ManyTestEs');
|
||||||
|
$query->applyRelation('ManyTestIs');
|
||||||
|
$query->sort([
|
||||||
|
'"manytestes_DataQueryTest_E"."SortOrder"',
|
||||||
|
'"manytestis_DataQueryTest_I"."SortOrder"',
|
||||||
|
'"SortOrder"',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$titles = $query->column('Name');
|
||||||
|
|
||||||
|
$this->assertEquals('First', $titles[0]);
|
||||||
|
$this->assertEquals('Second', $titles[1]);
|
||||||
|
$this->assertEquals('Last', $titles[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,3 +8,31 @@ SilverStripe\ORM\Tests\DataQueryTest\ObjectE:
|
|||||||
query3:
|
query3:
|
||||||
Title: 'Second'
|
Title: 'Second'
|
||||||
SortOrder: 2
|
SortOrder: 2
|
||||||
|
|
||||||
|
SilverStripe\ORM\Tests\DataQueryTest\ObjectI:
|
||||||
|
query1:
|
||||||
|
Title: 'First'
|
||||||
|
SortOrder: 1
|
||||||
|
query2:
|
||||||
|
Title: 'Second'
|
||||||
|
SortOrder: 2
|
||||||
|
query3:
|
||||||
|
Title: 'Last'
|
||||||
|
SortOrder: 3
|
||||||
|
|
||||||
|
SilverStripe\ORM\Tests\DataQueryTest\ObjectH:
|
||||||
|
query1:
|
||||||
|
Name: 'First'
|
||||||
|
SortOrder: 3
|
||||||
|
ManyTestEs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectE.query2
|
||||||
|
ManyTestIs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectI.query2
|
||||||
|
query2:
|
||||||
|
Name: 'Last'
|
||||||
|
SortOrder: 1
|
||||||
|
ManyTestEs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectE.query1
|
||||||
|
ManyTestIs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectI.query1
|
||||||
|
query3:
|
||||||
|
Name: 'Second'
|
||||||
|
SortOrder: 2
|
||||||
|
ManyTestEs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectE.query2
|
||||||
|
ManyTestIs: =>SilverStripe\ORM\Tests\DataQueryTest\ObjectI.query3
|
||||||
|
21
tests/php/ORM/DataQueryTest/ObjectH.php
Normal file
21
tests/php/ORM/DataQueryTest/ObjectH.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Tests\DataQueryTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class ObjectH extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $table_name = 'DataQueryTest_H';
|
||||||
|
|
||||||
|
private static $db = array(
|
||||||
|
'Name' => 'Varchar',
|
||||||
|
'SortOrder' => 'Int',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $many_many = array(
|
||||||
|
'ManyTestEs' => ObjectE::class,
|
||||||
|
'ManyTestIs' => ObjectI::class,
|
||||||
|
);
|
||||||
|
}
|
16
tests/php/ORM/DataQueryTest/ObjectI.php
Normal file
16
tests/php/ORM/DataQueryTest/ObjectI.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Tests\DataQueryTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class ObjectI extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $table_name = 'DataQueryTest_I';
|
||||||
|
|
||||||
|
private static $db = array(
|
||||||
|
'Name' => 'Varchar',
|
||||||
|
'SortOrder' => 'Int',
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user