symfony2admingenerator / GeneratorBundle

Admingenerator for Symfony. Parse YAML files to build customized backend.
MIT License
67 stars 29 forks source link

FIX: allow to use array as field values in scope filters #283

Closed ksn135 closed 8 years ago

ksn135 commented 8 years ago

In my case I need to use several states (array) in filter to achieve required functionality (as it always works for me before in previous versions). Without this fix cache:clear throws exception >> Skip warmup An exception has been thrown during the rendering of a template ("Notice: Array to string conversion") in "../CommonAdmin/ListAction/scopes.php.twig". Example:


            scopes:
                group_1: 
                    "Все": 
                        default: true
                        filters: 
                            -      notArchive
                    "Ждут согласования": 
                        filters: 
                            state: [draft, declined, checked]
                    "У Куратора": 
                        filters: 
                            state: reviewed
                    "В Бухгалтерии": 
                        filters: 
                            state: accounted
                    "В ФинСлужбе": 
                        filters: 
                            state: appointed
                    "В Казначействе": 
                        filters: 
                            state: treasured
                    "Ожидают оплаты": 
                        filters: 
                            state: suspended
                            1:     notToday
                    "Оплаты на сегодня": 
                        filters: 
                            state: suspended
                            1:     today
                    "В Реестре на сегодня": 
                        filters: 
                            state: approved
                    "В 1С": 
                        filters: 
                            state: [assigned, uploaded, sended, cashed]
                    "Оплата не возможна": 
                        filters: 
                            state: canceled
                    "Оплачено": 
                        filters: 
                            state: payed
                    "Архив": 
                        filters: 
                            state: archive

                group_2: 
                    "Не важно": 
                        default: true
                        filters: ~
                    "Без договора": 
                        filters: 
                            bargainSendTo1CState:  none
                    "На создании": 
                        filters: 
                            bargainSendTo1CState:  draft
                    "На согласовании": 
                        filters: 
                            bargainSendTo1CState:  concordance
                    "Согласован": 
                        filters: 
                            bargainSendTo1CState:  done
ksn135 commented 8 years ago

Any chances to apply this fix on this weekend ?

sescandell commented 8 years ago

@ksn135 is this fix working on your project?

ksn135 commented 8 years ago

It's allow me use array as value. Also you need to modify filter function:

    protected function filterState($queryFilter, $value)
    {
        $queryFilter->addDefaultFilter('state', $value);
    }

WBR, KSN.

On Mon, May 16, 2016 at 10:34 AM, Stéphane notifications@github.com wrote:

@ksn135 https://github.com/ksn135 is this fix working on your project?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/symfony2admingenerator/GeneratorBundle/pull/283#issuecomment-219366520

calvera commented 8 years ago

hi,

i had a similar problem: https://github.com/calvera/GeneratorBundle/blob/fixes/Resources/templates/CommonAdmin/ListAction/scopes.php.twig#L109

                           $filters['{{ filter }}'] = {%- if filterParams is not iterable -%}'{{ filterParams }}'{%- else -%}array({% for param in filterParams %}'{{ param }}'{% if not loop.last %},{% endif %}{% endfor %}){%- endif -%};