DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

[Suggestion] Convert option table field to enum #122

Closed fvet closed 2 years ago

fvet commented 3 years ago

It would be nice if we could have a code action that allows (on a table field of datatype 'option') the creation of a new enum (new enum name to be asked via commandpalette) based on the OptionMembers / OptionCaption and replace the datatype of the table field by the new enum (+ remove OptionCaption / OptionMembers)

Before

image

After

image

image

DavidFeldhoff commented 3 years ago

Sounds good. I'll add it. But what about the location of the new file? The "CRS: Reorganize - Current file" could be an option, but if some people use it differently.. Maybe it's also an option to place it at the same directory as the current file?

DavidFeldhoff commented 3 years ago

Hi Frédéric, I've released a new version v1.0.7 which has this feature included. See the demo in the demo section of my readme. https://github.com/DavidFeldhoff/al-codeactions#refactor-option-to-enum I'm looking forward to your feedback!

fvet commented 3 years ago

Hi @DavidFeldhoff, thanks for this new feature, it works super!

One small remark:

I tend to add ', Locked = true' for blank options (' '), since those require no translations.

So instead of ...

value(0; " ")
    {
        Caption = ' ';
    }

... I normally add

value(0; " ")
    {
        Caption = ' ', Locked = true;
    }
DavidFeldhoff commented 3 years ago

That makes much sense indeed. I'll add it definitely.

fvet commented 2 years ago

The 'Locked = true' update seems not yet to be included in the v1.0.8 version.

Locked

DavidFeldhoff commented 2 years ago

Yes, you're totally right, I have gotten over it. I noticed it after the release, that's why I've removed the released label. Nevertheless, thanks for the reminder.

DavidFeldhoff commented 2 years ago

In v1.0.9 it's added 😉