diff --git a/DependencyInjection/ChillMainExtension.php b/DependencyInjection/ChillMainExtension.php index 613fe048e..5de39b272 100644 --- a/DependencyInjection/ChillMainExtension.php +++ b/DependencyInjection/ChillMainExtension.php @@ -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 + ] ) ) )); diff --git a/Doctrine/DQL/JsonbExistsInArray.php b/Doctrine/DQL/JsonbExistsInArray.php new file mode 100644 index 000000000..6c4eaa5c3 --- /dev/null +++ b/Doctrine/DQL/JsonbExistsInArray.php @@ -0,0 +1,41 @@ + + */ +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); + } +} diff --git a/Resources/public/sass/custom/modules/_forms.scss b/Resources/public/sass/custom/modules/_forms.scss index 75b0e46a3..6676680cc 100644 --- a/Resources/public/sass/custom/modules/_forms.scss +++ b/Resources/public/sass/custom/modules/_forms.scss @@ -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; + } } \ No newline at end of file diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig index 441519bc7..33b42c6e8 100644 --- a/Resources/views/Form/fields.html.twig +++ b/Resources/views/Form/fields.html.twig @@ -101,6 +101,13 @@ {% endspaceless %} {% endblock choice_with_other_widget %} +{% block money_widget %} +
+ {{ block('form_widget_simple') }} + {{ money_pattern|form_encode_currency }} +
+{% endblock money_widget %} + {% block date_widget %} {% spaceless %}