Page 9670 Layout Theme and Header/Footer

Base Application, Microsoft.Foundation.Reporting

src/Layers/W1/BaseApp/Foundation/Reporting/LayoutThemeandHeaderFooter.Page.al153 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Foundation.Reporting;using System.Reflection;/// <summary>/// Lists every layout of a single report with the theme and header/footer that effectively apply to it, including the/// level each resolves from (this layout, report default, company, or global). Opened filtered to one report from the/// Report Layouts page. The theme/header-footer of a layout is changed in place via the Manage action, which writes a/// layout-level Tenant Report Layout Cfg entry; unset layouts keep showing the inherited company/global default./// </summary>page 9670 "Layout Theme and Header/Footer"{    ApplicationArea = Basic, Suite;    Caption = 'Theme and header-footer per layout';    PageType = List;    SourceTable = "Report Layout List";    SourceTableView = sorting("Report ID", "Layout Format");    UsageCategory = None;    Editable = false;    InsertAllowed = false;    DeleteAllowed = false;    ModifyAllowed = false;    Extensible = true;    AboutTitle = 'Theme and header-footer per layout';    AboutText = 'Compare the body layouts of this report side by side, with the theme and header/footer that apply to each one. Only a body layout is listed, because only a body layout carries them. The **source** columns tell you where each comes from: the layout itself, the report, your company, or the global default. Select a layout and choose **Set theme and header-footer** to change it without affecting the others.';    layout    {        area(content)        {            repeater(Group)            {                field("Report ID"; Rec."Report ID")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Report No.';                    ToolTip = 'Specifies the report the layout belongs to.';                }                field(LayoutCaption; Rec."Caption")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Layout Name';                    ToolTip = 'Specifies the body layout.';                }                field(ThemeField; ThemeDisplay)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Theme';                    ToolTip = 'Specifies the theme applied to the layout. None = no theme applies at any level; otherwise the resolved theme name.';                }                field(ThemeSourceField; ThemeSource)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Theme source';                    ToolTip = 'Specifies where the theme resolves from: This layout, Report default, Company (Company Information), or Global default.';                }                field(HeaderFooterField; HeaderDisplay)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Header/Footer';                    ToolTip = 'Specifies the header/footer applied to the layout. None = none applies at any level; otherwise the resolved part name.';                }                field(HeaderSourceField; HeaderSource)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Header/Footer source';                    ToolTip = 'Specifies where the header/footer resolves from: This layout, Report default, Company (Company Information), or Global default.';                }            }        }    }    actions    {        area(Processing)        {            action(ManageThemeHeaderFooter)            {                ApplicationArea = Basic, Suite;                Caption = 'Set theme and header-footer';                Image = Setup;                Enabled = BodyLayoutSelected;                ToolTip = 'Set the theme and header/footer applied to the selected layout. Available for body layouts only. The setting is stored for this layout (per company/tenant), overriding any company or global default.';                trigger OnAction()                begin                    ManageRow();                end;            }        }        area(Promoted)        {            actionref(ManageThemeHeaderFooter_Promoted; ManageThemeHeaderFooter)            {            }        }    }    trigger OnAfterGetRecord()    var        HeaderResolved: Boolean;        ThemeResolved: Boolean;    begin        // This page is filtered to a single report, so the layout-independent report/global defaults are identical for        // every row. Resolve them once and only do the per-layout lookups for each rendered row.        if not ReportLevelResolved then begin            LookupHelper.GetReportLevelPartDisplays(Rec."Report ID", ReportHeaderDisplay, ReportHeaderSource, ReportThemeDisplay, ReportThemeSource);            ReportLevelResolved := true;        end;        LookupHelper.GetLayoutLevelPartDisplays(Rec."Report ID", LookupHelper.CompositeLayoutKey(Rec), HeaderDisplay, HeaderSource, ThemeDisplay, ThemeSource, HeaderResolved, ThemeResolved);        if not HeaderResolved then begin            HeaderDisplay := ReportHeaderDisplay;            HeaderSource := ReportHeaderSource;        end;        if not ThemeResolved then begin            ThemeDisplay := ReportThemeDisplay;            ThemeSource := ReportThemeSource;        end;    end;    trigger OnAfterGetCurrRecord()    begin        BodyLayoutSelected := Rec."Layout Subtype" = Rec."Layout Subtype"::Body;    end;    local procedure ManageRow()    var        HeaderFooterThemeAssignment: Page "Header/Footer Theme Assignment";    begin        HeaderFooterThemeAssignment.SetLayout(Rec."Report ID", LookupHelper.CompositeLayoutKey(Rec));        HeaderFooterThemeAssignment.RunModal();        CurrPage.Update(false);    end;    var        LookupHelper: Codeunit "Composite Layout Lookup Helper";        BodyLayoutSelected: Boolean;        ReportLevelResolved: Boolean;        ThemeDisplay: Text;        ThemeSource: Text;        HeaderDisplay: Text;        HeaderSource: Text;        ReportHeaderDisplay: Text;        ReportHeaderSource: Text;        ReportThemeDisplay: Text;        ReportThemeSource: Text;}