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 2 commits 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.

@tabacitu
Copy link
Member

tabacitu commented Jun 4, 2024

Hey @susanu ,

I see the two issues in the laravel-idea plugin have been closed. Any idea how to change this to benefit from the new features?

Cheers!

@susanu
Copy link
Contributor Author

susanu commented Jun 19, 2024

Hi @tabacitu,

I will update the pull request this week.

Thank you!

@susanu
Copy link
Contributor Author

susanu commented Jul 9, 2024

Hi @tabacitu,

I updated the file, it has the following completions:

  • type for columns, fields and widgets (it also supports the user created one).
  • to, section and group for widgets (after_section and before_section)
  • iconset for columns and fields (fontawesome, lineawesome, glyphicon, ionicon, weathericon, mapicon, octicon, typicon, elusiveicon, materialdesign)
  • view for columns and fields with the view name
  • linkTo for columns with the route name

Let me know if that works for you.
Thank you!

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