mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 17:07:33 -04: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'])) { |             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