mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #5729 from beganovich/v5-1705-sorting-line-items
(v5) Drop the logic for the ordering items
This commit is contained in:
commit
23c8a0e819
@ -62,32 +62,11 @@ trait PdfMakerUtilities
|
||||
}
|
||||
|
||||
if (isset($element['elements'])) {
|
||||
$sorted = $this->processChildrenOrder($element['elements']);
|
||||
|
||||
$this->createElementContent($node, $sorted);
|
||||
$this->createElementContent($node, $element['elements']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// We have exception for "hidden" property.
|
||||
@ -154,9 +133,7 @@ trait PdfMakerUtilities
|
||||
}
|
||||
|
||||
if (isset($child['elements'])) {
|
||||
$sorted = $this->processChildrenOrder($child['elements']);
|
||||
|
||||
$this->createElementContent($_child, $sorted);
|
||||
$this->createElementContent($_child, $child['elements']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,65 +209,6 @@ class PdfMakerTest extends TestCase
|
||||
$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()
|
||||
{
|
||||
$state = [
|
||||
|
Loading…
Reference in New Issue
Block a user