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

Add string completion to field and column type parameter #5341

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

susanu
Copy link
Contributor

@susanu susanu commented Oct 10, 2023

WHY

Make life easier for developers who use Laravel idea plugin for phpstorm.
image

BEFORE - What was wrong? What was happening before this PR?

No autocompletion for type parameter for columns and fields.

AFTER - What is happening after this PR?

A list of possible values for type parameter for fields and columns

HOW

How did you achieve that, in technical terms?

Adding the ide.json file in the root package for Laravel idea to pick it up

Is it a breaking change?

No

How can we test the before & after?

Have Laravel idea installed into Phpstorm.
Type date into the type function for a column or a field with and without the ide.json file.
CRUD::column('column')->type('date')
CRUD::field('column')->type('date')

If this pull will get merged, i will come back with the rest of things that can be completed.
More info: https://laravel-idea.com/docs/ide_json/completion

@susanu
Copy link
Contributor Author

susanu commented Oct 10, 2023

There is an alternative to this that enables the user to go to the column/field blade file with CTRL+B combination
Example with some new things added.

{
    "$schema": "https://laravel-ide.com/schema/laravel-ide-v2.json",
    "completions": [
        {
            "complete": "directoryFiles",
            "options": {
                "directory": "/vendor/backpack/crud/src/resources/views/crud/columns",
                "suffixToClear": ".blade.php"
            },
            "condition": [
                {
                    "methodNames": [
                        "type"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudColumn"
                    ],
                    "parameters": [
                        1
                    ]
                },
                {
                    "place": "arrayValueWithKey",
                    "keys": [
                        "type"
                    ],
                    "methodNames": [
                        "addColumn"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanelFacade"
                    ]
                }
            ]
        },
        {
            "complete": "directoryFiles",
            "options": {
                "directory": "/vendor/backpack/crud/src/resources/views/crud/fields",
                "suffixToClear": ".blade.php"
            },
            "condition": [
                {
                    "methodNames": [
                        "type"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudField"
                    ],
                    "parameters": [
                        1
                    ]
                },
                {
                    "place": "arrayValueWithKey",
                    "keys": [
                        "type"
                    ],
                    "methodNames": [
                        "addField"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanelFacade"
                    ]
                }
            ]
        },
        {
            "complete": "directoryFiles",
            "options": {
                "directory": "/vendor/backpack/crud/src/resources/views/ui/widgets",
                "suffixToClear": ".blade.php"
            },
            "condition": [
                {
                    "methodNames": [
                        "type"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\Widget"
                    ],
                    "parameters": [
                        1
                    ]
                },
                {
                    "place": "arrayValueWithKey",
                    "keys": [
                        "type"
                    ],
                    "methodNames": [
                        "add"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\Widget"
                    ]
                }
            ]
        },
        {
            "complete": "staticStrings",
            "options": {
                "strings": [
                    "fontawesome",
                    "lineawesome",
                    "glyphicon",
                    "ionicon",
                    "weathericon",
                    "mapicon",
                    "octicon",
                    "typicon",
                    "elusiveicon",
                    "materialdesign"
                ]
            },
            "condition": [
                {
                    "methodNames": [
                        "iconset"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudField"
                    ],
                    "parameters": [
                        1
                    ]
                },
                {
                    "place": "arrayValueWithKey",
                    "keys": [
                        "iconset"
                    ],
                    "methodNames": [
                        "addField"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanelFacade"
                    ]
                }
            ]
        },
        {
            "complete": "viewName",
            "condition": [
                {
                    "methodNames": [
                        "view"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudField"
                    ],
                    "parameters": [
                        1
                    ]
                },
                {
                    "place": "arrayValueWithKey",
                    "keys": [
                        "view"
                    ],
                    "methodNames": [
                        "addField"
                    ],
                    "classFqn": [
                        "\\Backpack\\CRUD\\app\\Library\\CrudPanel\\CrudPanelFacade"
                    ]
                }
            ]
        }
    ]
}

@tabacitu
Copy link
Member

I LOVE IT! Yes @susanu , I totally agree to adding this. I've just started using PHPStorm + Laravel Idea too, and I would LOVE IT if it were able to help me like this, yes.

Feel free to polish this PR until you're reasonably happy with it. Then I'll take a look, test and and merge.

Don't go overboard 😀 I think it's better to cover the most useful things, merge it... and then we can add more later if needed.

Thank you!

@susanu
Copy link
Contributor Author

susanu commented Oct 16, 2023

Hi @tabacitu,

Currently i'm waiting for a response from the plugin creator to implement 2 things:

  1. Completion from multiple sources ([Feature Request]: Allow completion from multiple sources laravel-idea/plugin#847)
  2. Control recursive for checking directory files ([Feature Request]: Add recursive to directoryFiles method laravel-idea/plugin#851)

After i get a response, i will update this pull request with the necessary changes.

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

Successfully merging this pull request may close these issues.

None yet

2 participants