improve money type rendering + DQL "jsonbexistsInArray"

This commit is contained in:
Julien Fastré 2018-06-22 10:09:04 +02:00
parent c059fe8a95
commit 8624b3f941
4 changed files with 65 additions and 1 deletions

View File

@ -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
]
)
)
));

View 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);
}
}

View File

@ -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;
}
}

View File

@ -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 %}