mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 13:12:56 -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'])) { | ||||
|                 $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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user