anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

Add multiple fields for API pages does not respect API field properties #228

Closed fvet closed 3 years ago

fvet commented 3 years ago

When I create a page of type APIvia the New AL File wizard, the fields inserted on the new page receive the following settings:

Resulting file

page 2059394 "API Shipment"
{

    APIGroup = 'apiGroup';
    APIPublisher = 'publisherName';
    APIVersion = 'v1.0';
    Caption = 'aPIShipment';
    DelayedInsert = true;
    EntityName = 'entityName';
    EntitySetName = 'entitySetName';
    PageType = API;
    SourceTable = "NVT Shipment";

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field(addresseeAddress; Rec."Addressee Address")
                {
                    ApplicationArea = All;
                    Caption = 'addresseeAddress', Locked = true;
                }
                field(addresseeAddress2; Rec."Addressee Address 2")
                {
                    ApplicationArea = All;
                    Caption = 'addresseeAddress2', Locked = true;
                }
                field(addresseeCity; Rec."Addressee City")
                {
                    ApplicationArea = All;
                    Caption = 'addresseeCity', Locked = true;
                }

If I add fields via the code action Add Multiple Fields, I get the following result

                field("Addressee City"; Rec."Addressee City")
                {
                    ToolTip = 'Specifies the value of the Addressee Location field';
                    ApplicationArea = All;
                }
                field("Addressee bill-to customer"; Rec."Addressee bill-to customer")
                {
                    ToolTip = 'Specifies the value of the Addressee bill-to customer field';
                    ApplicationArea = All;
                }
                field("Addressee Address"; Rec."Addressee Address")
                {
                    ToolTip = 'Specifies the value of the Addressee Address field';
                    ApplicationArea = All;
                }
anzwdev commented 3 years ago

Thank you for reporting your issue. I've fixed it and released a new version of the extension.

fvet commented 3 years ago

Thanks for the fix!

I wanted to add one more remark. I'm currently using the change-case extension for camelcasing.

Name: change-case
Id: wmaurer.change-case
Description: Quickly change the case (camelCase, CONSTANT_CASE, snake_case, etc) of the current selection or current word
Version: 1.0.0
Publisher: wmaurer
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=wmaurer.change-case

With this extension, I get better names - in my opinion - than currently proposed by al-code-outline.

Same examples:

field(allowlowerclassonputaway; Rec."Allow lower class on put-away") > should be allowLowerClassOnPutAway field(billOfMaterialsexists; Rec."Bill Of Materials exists") > should be billOfMaterialsExists

field(eDICode; Rec."EDI Code") > should be ediCode field(eORINumber; Rec."EORI Number") > should be eoriNumber field(aDRClassiffCode; Rec."ADR-Classiff.Code") > should be adrClassiffCode

fvet commented 3 years ago

And what would be the community guideline towards including field captions on custom API pages? Not sure how the API consumer would use the captions anyway...

Maybe worth adding a setting to define how API field captions should be inserted?

anzwdev commented 3 years ago

Hi

I've modified this area and released new version of the extension. The page api fields will contain now table field captions instead of api field names to work the same way as Microsoft API v2.0 pages. There is a still posibility to use old Microsoft API v1.0 approach with api field names as captions with Locked property. To do this, you have to switch alOutline.useTableFieldCaptionsInApiFields vs code setting to false.

I've also changed the way in which api field names are generated from table field names.

You can compare original Microsoft APIs here: