formatted nav patterns

This commit is contained in:
christianbraeunlich 2022-02-05 18:19:26 +01:00
parent 38a19d75d8
commit 2fad891a77
59 changed files with 1403 additions and 1970 deletions

View file

@ -4,9 +4,7 @@ weight = 560
+++
_By David Bastide at Microsoft Development Center Copenhagen_
_[![ ][image0]][anchor0]_
__
[![ ][image0]][anchor0]
## Context
@ -19,14 +17,9 @@ This document provides an elegant and extensible pattern about how to extend the
The Dynamics 365 Business Central release (April 2018) introduces a new HeadlinePart page type. This page type defines a page that rotates a display of several headlines after another, in the web client. A user can also click to switch to another headline. Headlines can also include a drilldown action that will be invoked when the user clicks the headline Text of the payload can be emphasized.
Headlines are divided in 2 parts: the qualifier, and the payload as you can see in the figure below.
_
_
[![ ][image1]][anchor1]
< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if gte mso 10\]\>
< \[endif\]--\>
_Figure 1: Qualifier, Payload and emphasized text._
## Usage
@ -61,89 +54,88 @@ To format headlines, you should use Codeunit 1439 Headline Management functions:
### Examples:
#### 1\. Extending the page with a new headline:
group(LargestSale)
{
#### 1. Extending the page with a new headline:
```al
group(LargestSale)
{
Visible = LargestSaleVisible;
ShowCaption=false;
Editable=false;
field(LargestSaleText;LargestSaleText)
{
ApplicationArea = Basic, Suite;
DrillDown=true;
trigger OnDrillDown()
var
EssentialBusHeadlineMgt: Codeunit "Essential Bus. Headline Mgt.";
begin
EssentialBusHeadlineMgt.OnDrillDownLargestSale();
end;
ApplicationArea = Basic, Suite;
DrillDown=true;
trigger OnDrillDown()
var
EssentialBusHeadlineMgt: Codeunit "Essential Bus. Headline Mgt.";
begin
EssentialBusHeadlineMgt.OnDrillDownLargestSale();
end;
}
}
}
```
####
#### 2\. Subscribing to the OnComputeHeadlines event, and computing headlines
\[EventSubscriber(ObjectType::Codeunit, Codeunit::"Headline RC Business Manager", 'OnComputeHeadlines', '', true, true)\]
#### 2. Subscribing to the OnComputeHeadlines event, and computing headlines
```al
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Headline RC Business Manager", 'OnComputeHeadlines', '', true, true)]
procedure OnComputeHeadlinesBusinessManager()
begin
// \[...\] compute headline, and init the EssentialBusinessHeadline record
if not ShowHeadline then
exit; // not enough data to compute headline
exit; // not enough data to compute headline
if not HeadlineManagement.GetHeadlineText(
'Insight from last week',
StrSubstNo('The largest posted sales invoice was for %1',
HeadlineManagement.Emphasize(Format(CustomerLedgerEntry.Amount, 0, TypeHelper.GetAmountFormatWithUserLocale('$'))))
EssentialBusinessHeadline."Headline Text")
'Insight from last week',
StrSubstNo('The largest posted sales invoice was for %1',
HeadlineManagement.Emphasize(Format(CustomerLedgerEntry.Amount, 0, TypeHelper.GetAmountFormatWithUserLocale('$'))))
EssentialBusinessHeadline."Headline Text")
then
exit;
exit;
EssentialBusinessHeadline.Validate("Headline Visible", true);
EssentialBusinessHeadline.Modify();
end;
end;
```
####
#### 3. Subscribing to the OnIsAnyExtensionHeadlineVisible event
#### 3\. Subscribing to the OnIsAnyExtensionHeadlineVisible event
\[EventSubscriber(ObjectType::Page, Page::"Headline RC Business Manager", 'OnIsAnyExtensionHeadlineVisible', '', true, true)\]
procedure OnIsAnyExtensionHeadlineVisible(var ExtensionHeadlinesVisible: Boolean)
var
```al
[EventSubscriber(ObjectType::Page, Page::"Headline RC Business Manager", 'OnIsAnyExtensionHeadlineVisible', '', true, true)]
procedure OnIsAnyExtensionHeadlineVisible(var ExtensionHeadlinesVisible: Boolean)
var
EssentialBusinessHeadline: Record "Essential Business Headline";
AtLeastOneHeadlineVisible: Boolean;
begin
begin
EssentialBusinessHeadline.SetRange("Headline Visible", true);
EssentialBusinessHeadline.SetFilter("Headline Name",'%1|%2|%3|%4|%5',
EssentialBusinessHeadline."Headline Name"::LargestOrder,
EssentialBusinessHeadline."Headline Name"::LargestSale,
EssentialBusinessHeadline."Headline Name"::BusiestResource,
EssentialBusinessHeadline."Headline Name"::MostPopularItem,
EssentialBusinessHeadline."Headline Name"::SalesIncrease,
EssentialBusinessHeadline."Headline Name"::TopCustomer);
EssentialBusinessHeadline."Headline Name"::LargestOrder,
EssentialBusinessHeadline."Headline Name"::LargestSale,
EssentialBusinessHeadline."Headline Name"::BusiestResource,
EssentialBusinessHeadline."Headline Name"::MostPopularItem,
EssentialBusinessHeadline."Headline Name"::SalesIncrease,
EssentialBusinessHeadline."Headline Name"::TopCustomer);
AtLeastOneHeadlineVisible := not EssentialBusinessHeadline.IsEmpty();
// only modify the var if this extension is making some headlines visible, setting to false could override some other extensions setting the value to true
if AtLeastOneHeadlineVisible then
ExtensionHeadlinesVisible := true;
end;
ExtensionHeadlinesVisible := true;
end;
```
####
#### 4\. Setting the headline text on the page
#### 4. Setting the headline text on the page
trigger OnAfterGetRecord()
begin
```al
trigger OnAfterGetRecord()
begin
EssentialBusinessHeadline.GetHeadline(EssentialBusinessHeadline."Headline Name"::LargestSale);
LargestSaleVisible := EssentialBusinessHeadline."Headline Visible";
LargestSaleText := EssentialBusinessHeadline."Headline Text";
end;
end;
```
[![ ][image2]][anchor2]
_Figure 2: Sequence diagram of headline usage_
@ -152,10 +144,6 @@ _Figure 2: Sequence diagram of headline usage_
* Essential Business Headlines extension
< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if gte mso 9\]\>< \[endif\]--\>< --\[if supportAnnotations\]--\>< --\[endif\]--\>< --\[if gte mso 10\]\>
< \[endif\]--\>
[anchor0]: 3733.logo.png
[anchor1]: Headline.png