StefanMaron / BusinessCentral.LinterCop

Community driven code linter for AL (MS Dynamics 365 Business Central)
https://stefanmaron.com
MIT License
68 stars 27 forks source link

LC0016 with SplitButton and Repeater Scope #587

Closed jwikman closed 2 months ago

jwikman commented 3 months ago

When having the ShowAs property on an Action Group set to SplitButton, the Caption property is not needed on the group. LC0016 handles this in a nice way.

But I just discovered that if an action inside a SplitButton Action Group has the Scope set to Repeater, the Caption is needed for the context menu on the line, otherwise an autogenerated caption i displayed in the context menu (in my example, the actions are promoted, hence the Category_ prefixes):

image

So, to my suggestion: Add a new condition for LC0016, to require Caption on Page Action Group if they have SplitButton specified and the action Scope is set to Repeater. (Note that this should apply both to action groups in the promoted action area, as on regular action groups)

jwikman commented 3 months ago

An update to this: I just noticed that this ONLY applies to Promoted Action Groups.

Repro code:

page 50100 PageName
{
    Caption = 'PageCaption';
    Editable = false;
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Lists;
    SourceTable = Customer;

    layout
    {
        area(Content)
        {
            repeater(GroupName)
            {
                field(Name; Rec.Name)
                {
                }
            }
        }
    }

    actions
    {
        area(Processing)
        {
            group(RegularGroup)
            {
                ShowAs = SplitButton;
                action(ActionName)
                {
                    Caption = 'ActionCaption';
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        Message('Hello World');
                    end;
                }
                action(ActionName2)
                {
                    Caption = 'Action2Caption';
                    ApplicationArea = All;
                    Scope = Repeater;

                    trigger OnAction()
                    begin
                        Message('Hello World');
                    end;
                }
                action(PromotedActionName2)
                {
                    Caption = 'PromotedAction2Caption';
                    ApplicationArea = All;
                    Scope = Repeater;

                    trigger OnAction()
                    begin
                        Message('Hello World');
                    end;
                }
            }
            group(SecondGroup)
            {
                ShowAs = SplitButton;
                action(SecondActionName)
                {
                    Caption = 'SecondActionCaption';
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        Message('Hello World');
                    end;
                }
                action(SecondActionName2)
                {
                    Caption = 'SecondAction2Caption';
                    ApplicationArea = All;
                    Scope = Repeater;

                    trigger OnAction()
                    begin
                        Message('Hello World');
                    end;
                }
            }
        }
        area(Promoted)
        {
            group(Category_DEMO)
            {
                ShowAs = SplitButton;

                actionref(PromotedActionName2_Promoted; PromotedActionName2)
                {
                }
            }
        }
    }
}

The only thing disturbing me here is the auto generated caption for the promoted action group: image

Arthurvdv commented 2 months ago

Thank you @jwikman for the detailed description and example, this was of great help!

This should now be resolved in the (pre)release version of v0.30.20 of the LinterCop.

jwikman commented 2 months ago

Thanks @Arthurvdv!

Arthurvdv commented 2 months ago

Version v0.30.20 of the LinterCop is now released.