Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectRelationActiveQuery plugin is not working properly in a model with pool #703

Open
jettero777 opened this issue Jan 9, 2022 · 2 comments
Assignees

Comments

@jettero777
Copy link
Contributor

jettero777 commented Jan 9, 2022

What steps will reproduce the problem?

plugin SelectRelationActiveQuery used in a model with pool api

What is the expected result?

should be shown a button to select related records

What do you get instead? (A Screenshot can help us a lot!)

there is no button to choose records
if plugin used in a model without pool, then the button is visible and works as expected

Untitled-1

Additional infos

Q A
LUYA Version luya-module-admin 4.2.0
PHP Version 8.1
Platform NGINX
Operating system Linux
@jettero777 jettero777 changed the title SelectRelationActiveQuery is not working in a model with pool SelectRelationActiveQuery plugin is not working properly in a model with pool Jan 9, 2022
@nadar
Copy link
Contributor

nadar commented Jan 9, 2022

Thanks for the report, i'll check that. Could you please post me your ngRestConfig parts, so we can easy reproduce?

@nadar nadar self-assigned this Jan 9, 2022
@jettero777
Copy link
Contributor Author

jettero777 commented Jan 9, 2022

Hi @nadar
sure, here simplified config for testing

<?php
namespace app\modules\test\models;

use luya\admin\ngrest\base\NgRestModel;

class Test extends NgRestModel
{
    public static function tableName()
    {
        return 'test';
    }

    public static function ngRestApiEndpoint()
    {
        return 'api-test';
    }

    public function ngRestAttributeTypes()
    {
        return [
            'is_active' => [
                'toggleStatus',
                'initValue' => 0,
            ],
            'user_id' => [
                'SelectRelationActiveQuery',
                'query' => $this->getUser(),
                'labelField' => 'id',
            ],
        ];
    }

    public function rules()
    {
        return [
            [['is_active', 'user_id'], 'safe'],
        ];
    }

    public function ngRestScopes()
    {
        return [
            [['list', 'create', 'update'], ['is_active', 'user_id']],
        ];
    }

    public function ngRestPools()
    {
        return [
            'inactive' => ['is_active' => 0],
            'active' => ['is_active' => 1],
        ];
    }

    public function getUser()
    {
        return $this->hasOne(
            User::class, ['id' => 'user_id']
        );
    }
}
    public function getMenu()
    {
        return (new AdminMenuBuilder($this))
            ->node('Test', 'person')
                ->group('test')
                    ->itemApi('Test1', 'test/test/index', 'person', 'api-test')
                    ->itemPoolApi('Test2', 'test/test/index', 'person', 'api-test', 'inactive')
                    ->itemPoolApi('Test3', 'test/test/index', 'person', 'api-test', 'active');
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants