mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	improve money type rendering + DQL "jsonbexistsInArray"
This commit is contained in:
		| @@ -29,6 +29,7 @@ use Chill\MainBundle\DependencyInjection\Configuration; | ||||
| use Chill\MainBundle\Doctrine\DQL\GetJsonFieldByKey; | ||||
| use Chill\MainBundle\Doctrine\DQL\Unaccent; | ||||
| use Chill\MainBundle\Doctrine\DQL\JsonAggregate; | ||||
| use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray; | ||||
|  | ||||
| /** | ||||
|  * This class load config for chillMainExtension. | ||||
| @@ -141,7 +142,10 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, | ||||
|                     'unaccent' => Unaccent::class, | ||||
|                     'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class, | ||||
|                     'AGGREGATE' => JsonAggregate::class | ||||
|                  ) | ||||
|                  ), | ||||
|                  'numeric_functions' => [ | ||||
|                     'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class | ||||
|                 ] | ||||
|               ) | ||||
|            ) | ||||
|         )); | ||||
|   | ||||
							
								
								
									
										41
									
								
								Doctrine/DQL/JsonbExistsInArray.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								Doctrine/DQL/JsonbExistsInArray.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| <?php | ||||
| /* | ||||
|  *  | ||||
|  *  | ||||
|  */ | ||||
| namespace Chill\MainBundle\Doctrine\DQL; | ||||
|  | ||||
| use Doctrine\ORM\Query\AST\Functions\FunctionNode; | ||||
| use Doctrine\ORM\Query\Lexer; | ||||
| use Doctrine\ORM\Query\Parser; | ||||
| use Doctrine\ORM\Query\SqlWalker; | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * | ||||
|  * @author Julien Fastré <julien.fastre@champs-libres.coop> | ||||
|  */ | ||||
| class JsonbExistsInArray extends FunctionNode | ||||
| { | ||||
|     private $expr1; | ||||
|     private $expr2; | ||||
|      | ||||
|     public function getSql(SqlWalker $sqlWalker): string | ||||
|     { | ||||
|         return sprintf( | ||||
|             'jsonb_exists(%s, %s)', | ||||
|             $this->expr1->dispatch($sqlWalker), | ||||
|             $sqlWalker->walkInputParameter($this->expr2) | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     public function parse(Parser $parser): void | ||||
|     { | ||||
|         $parser->match(Lexer::T_IDENTIFIER); | ||||
|         $parser->match(Lexer::T_OPEN_PARENTHESIS); | ||||
|         $this->expr1 = $parser->StringPrimary(); | ||||
|         $parser->match(Lexer::T_COMMA); | ||||
|         $this->expr2 = $parser->InputParameter(); | ||||
|         $parser->match(Lexer::T_CLOSE_PARENTHESIS); | ||||
|     } | ||||
| } | ||||
| @@ -6,4 +6,16 @@ textarea { | ||||
|  | ||||
| span.force-inline-label label { | ||||
|     display: inline; | ||||
| } | ||||
|  | ||||
|     | ||||
| .chill-form-money { | ||||
|     display: flex; | ||||
|     flex-direction: row; | ||||
|     justify-content: flex-end; | ||||
|      | ||||
|     span.chill-form-money__money { | ||||
|         align-self: center; | ||||
|         margin-left: 1em; | ||||
|     } | ||||
| } | ||||
| @@ -101,6 +101,13 @@ | ||||
| {% endspaceless %} | ||||
| {% endblock  choice_with_other_widget %} | ||||
|  | ||||
| {% block money_widget %} | ||||
|     <div class="chill-form-money"> | ||||
|         {{ block('form_widget_simple') }} | ||||
|         <span class="chill-form-money__money">{{ money_pattern|form_encode_currency }}</span> | ||||
|     </div> | ||||
| {% endblock money_widget %} | ||||
|  | ||||
|  | ||||
| {% block date_widget %} | ||||
| {% spaceless %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user