mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-15 07:54:36 -04:00
Drop the logic for the ordering items
This commit is contained in:
parent
7f21696cca
commit
b15012b984
@ -62,32 +62,11 @@ trait PdfMakerUtilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($element['elements'])) {
|
if (isset($element['elements'])) {
|
||||||
$sorted = $this->processChildrenOrder($element['elements']);
|
$this->createElementContent($node, $element['elements']);
|
||||||
|
|
||||||
$this->createElementContent($node, $sorted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processChildrenOrder(array $children)
|
|
||||||
{
|
|
||||||
$processed = [];
|
|
||||||
|
|
||||||
foreach ($children as $child) {
|
|
||||||
if (!isset($child['order'])) {
|
|
||||||
$child['order'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$processed[] = $child;
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($processed, function ($a, $b) {
|
|
||||||
return $a['order'] <=> $b['order'];
|
|
||||||
});
|
|
||||||
|
|
||||||
return $processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateElementProperty($element, string $attribute, ?string $value)
|
public function updateElementProperty($element, string $attribute, ?string $value)
|
||||||
{
|
{
|
||||||
// We have exception for "hidden" property.
|
// We have exception for "hidden" property.
|
||||||
@ -154,9 +133,7 @@ trait PdfMakerUtilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($child['elements'])) {
|
if (isset($child['elements'])) {
|
||||||
$sorted = $this->processChildrenOrder($child['elements']);
|
$this->createElementContent($_child, $child['elements']);
|
||||||
|
|
||||||
$this->createElementContent($_child, $sorted);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,65 +209,6 @@ class PdfMakerTest extends TestCase
|
|||||||
$this->assertNotSame($output1, $output2);
|
$this->assertNotSame($output1, $output2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOrderingElements()
|
|
||||||
{
|
|
||||||
$design = new Design('example', ['custom_path' => base_path('tests/Feature/PdfMaker/')]);
|
|
||||||
|
|
||||||
$maker = new PdfMaker([
|
|
||||||
'template' => [
|
|
||||||
'header' => [
|
|
||||||
'id' => 'header',
|
|
||||||
'properties' => [],
|
|
||||||
'elements' => [
|
|
||||||
['element' => 'h1', 'content' => 'h1-element'],
|
|
||||||
['element' => 'span', 'content' => 'span-element'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$maker
|
|
||||||
->design($design)
|
|
||||||
->build();
|
|
||||||
|
|
||||||
$node = $maker->getSectionNode('header');
|
|
||||||
|
|
||||||
$before = [];
|
|
||||||
|
|
||||||
foreach ($node->childNodes as $child) {
|
|
||||||
$before[] = $child->nodeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals('h1', $before[1]);
|
|
||||||
|
|
||||||
$maker = new PdfMaker([
|
|
||||||
'template' => [
|
|
||||||
'header' => [
|
|
||||||
'id' => 'header',
|
|
||||||
'properties' => [],
|
|
||||||
'elements' => [
|
|
||||||
['element' => 'h1', 'content' => 'h1-element', 'order' => 1],
|
|
||||||
['element' => 'span', 'content' => 'span-element', 'order' => 0],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$maker
|
|
||||||
->design($design)
|
|
||||||
->build();
|
|
||||||
|
|
||||||
$node = $maker->getSectionNode('header');
|
|
||||||
|
|
||||||
$after = [];
|
|
||||||
|
|
||||||
foreach ($node->childNodes as $child) {
|
|
||||||
$after[] = $child->nodeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals('span', $after[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGeneratingPdf()
|
public function testGeneratingPdf()
|
||||||
{
|
{
|
||||||
$state = [
|
$state = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user