Skip to content

Commit

Permalink
redesign the page structure and filter handling
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Jul 18, 2024
1 parent 9ecf6f7 commit 4b2ac97
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 90 deletions.
17 changes: 6 additions & 11 deletions MSDyn365BC.Ntfy/src/EventTypes/ApprovalRequested.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ codeunit 71179884 ApprovalRequestedNTSTM implements INtfyEventNTSTM

procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM)
var
FilterPageBuilder: FilterPageBuilder;
NtfyHelper: Codeunit NtfyHelperNTSTM;
FilterText: Text[2048];
begin
FilterPageBuilder.AddTable('Approval Entry', Database::"Approval Entry");
if NtfyEvent.FilterText <> '' then
FilterPageBuilder.SetView('Approval Entry', NtfyEvent.FilterText);
if FilterPageBuilder.RunModal() then begin
if not FilterPageBuilder.GetView('Approval Entry').Contains('WHERE') then
NtfyEvent.Validate(FilterText, '')
else
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Approval Entry'));
NtfyEvent.Modify(true);
end;
FilterText := NtfyEvent.FilterText;
NtfyHelper.GetFilterTextForTable(Database::"Approval Entry", NtfyEvent.FilterText);
NtfyEvent.Validate(FilterText, NtfyEvent.FilterText);
NtfyEvent.Modify(true);
end;

procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM);
Expand Down
17 changes: 6 additions & 11 deletions MSDyn365BC.Ntfy/src/EventTypes/JobQueueFailed.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ codeunit 71179885 JobQueueFailedNTSTM implements INtfyEventNTSTM

procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM)
var
FilterPageBuilder: FilterPageBuilder;
NtfyHelper: Codeunit NtfyHelperNTSTM;
FilterText: Text[2048];
begin
FilterPageBuilder.AddTable('Job Queue Entry', Database::"Job Queue Entry");
if NtfyEvent.FilterText <> '' then
FilterPageBuilder.SetView('Job Queue Entry', NtfyEvent.FilterText);
if FilterPageBuilder.RunModal() then begin
if not FilterPageBuilder.GetView('Job Queue Entry').Contains('WHERE') then
NtfyEvent.Validate(FilterText, '')
else
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Job Queue Entry'));
NtfyEvent.Modify(true);
end;
FilterText := NtfyEvent.FilterText;
NtfyHelper.GetFilterTextForTable(Database::"Job Queue Entry", FilterText);
NtfyEvent.Validate(FilterText, FilterText);
NtfyEvent.Modify(true);
end;

procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@ codeunit 71179883 ReportFinishedProcessingNTSTM implements INtfyEventNTSTM
procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM)
var
AllObjWithCaption: Record AllObjWithCaption;
NtfyHelper: Codeunit NtfyHelperNTSTM;
FilterPageBuilder: FilterPageBuilder;
FilterText: Text[2048];
FilterPageCaptionLbl: Label 'Report List';
begin
FilterPageBuilder.AddTable('Report List', Database::AllObjWithCaption);
FilterPageBuilder.AddField('Report List', AllObjWithCaption."Object Type", 'Report');
FilterPageBuilder.AddField('Report List', AllObjWithCaption."Object ID");
if NtfyEvent.FilterText <> '' then
FilterPageBuilder.SetView('Report List', NtfyEvent.FilterText);
if FilterPageBuilder.RunModal() then begin
if not FilterPageBuilder.GetView('Report List').Contains('WHERE') then
NtfyEvent.Validate(FilterText, '')
else
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Report List'));
NtfyEvent.Modify(true);
end;
FilterPageBuilder.AddField(FilterPageCaptionLbl, AllObjWithCaption."Object Type", 'Report');
FilterPageBuilder.AddField(FilterPageCaptionLbl, AllObjWithCaption."Object ID");

FilterText := NtfyEvent.FilterText;
NtfyHelper.GetFilterTextForTable(FilterPageBuilder, FilterPageCaptionLbl, Database::AllObjWithCaption, FilterText);
NtfyEvent.Validate(FilterText, FilterText);
NtfyEvent.Modify(true);
end;

procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM)
Expand Down
17 changes: 6 additions & 11 deletions MSDyn365BC.Ntfy/src/EventTypes/SalesDocumentReleased.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ codeunit 71179877 SalesDocumentReleasedNTSTM implements INtfyEventNTSTM

procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM)
var
FilterPageBuilder: FilterPageBuilder;
NtfyHelper: Codeunit NtfyHelperNTSTM;
FilterText: Text[2048];
begin
FilterPageBuilder.AddTable('Sales Header', Database::"Sales Header");
if NtfyEvent.FilterText <> '' then
FilterPageBuilder.SetView('Sales Header', NtfyEvent.FilterText);
if FilterPageBuilder.RunModal() then begin
if not FilterPageBuilder.GetView('Sales Header').Contains('WHERE') then
NtfyEvent.Validate(FilterText, '')
else
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Sales Header'));
NtfyEvent.Modify(true);
end;
FilterText := NtfyEvent.FilterText;
NtfyHelper.GetFilterTextForTable(Database::"Sales Header", FilterText);
NtfyEvent.Validate(FilterText, FilterText);
NtfyEvent.Modify(true);
end;

procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM)
Expand Down
17 changes: 6 additions & 11 deletions MSDyn365BC.Ntfy/src/EventTypes/SalesDocumentReopened.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ codeunit 71179878 SalesDocumentReopenedNTSTM implements INtfyEventNTSTM

procedure SetSettings(NtfyEvent: Record NtfyEventNTSTM)
var
FilterPageBuilder: FilterPageBuilder;
NtfyHelper: Codeunit NtfyHelperNTSTM;
FilterText: Text[2048];
begin
FilterPageBuilder.AddTable('Sales Header', Database::"Sales Header");
if NtfyEvent.FilterText <> '' then
FilterPageBuilder.SetView('Sales Header', NtfyEvent.FilterText);
if FilterPageBuilder.RunModal() then begin
if not FilterPageBuilder.GetView('Sales Header').Contains('WHERE') then
NtfyEvent.Validate(FilterText, '')
else
NtfyEvent.Validate(FilterText, FilterPageBuilder.GetView('Sales Header'));
NtfyEvent.Modify(true);
end;
FilterText := NtfyEvent.FilterText;
NtfyHelper.GetFilterTextForTable(Database::"Sales Header", FilterText);
NtfyEvent.Validate(FilterText, FilterText);
NtfyEvent.Modify(true);
end;

procedure ResetSettings(NtfyEvent: Record NtfyEventNTSTM);
Expand Down
25 changes: 4 additions & 21 deletions MSDyn365BC.Ntfy/src/foundation/NtfyEvent.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ using StefanMaron.Ntfy;
page 71179875 NtfyEventsNTSTM
{
Caption = 'Ntfy Events';
PageType = List;
PageType = ListPart;
ApplicationArea = All;
UsageCategory = Administration;
UsageCategory = None;
DelayedInsert = true;
SourceTable = NtfyEventNTSTM;
PopulateAllFields = true;
AutoSplitKey = true;
InherentEntitlements = X;
InherentPermissions = X;

Expand All @@ -18,13 +19,8 @@ page 71179875 NtfyEventsNTSTM
{
repeater(GroupName)
{
field(UserName; Rec.UserName)
{
//TODO: Visible for administrators
Visible = false;
}
field(NtfyTopic; Rec.NtfyTopic) { }
field(EventType; Rec.EventType) { }
field(Description; Rec.Description) { }
field(FilterText; Rec.FilterText)
{
Caption = 'Filter';
Expand Down Expand Up @@ -66,17 +62,4 @@ page 71179875 NtfyEventsNTSTM
}
}
}

trigger OnOpenPage()
begin
SetUserFilter();
end;

local procedure SetUserFilter()
begin
//TODO: Administrators should be able to see all users
Rec.FilterGroup(2);
Rec.SetRange(UserName, UserId);
Rec.FilterGroup(0);
end;
}
17 changes: 13 additions & 4 deletions MSDyn365BC.Ntfy/src/foundation/NtfyEvent.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using System.Security.AccessControl;

table 71179875 NtfyEventNTSTM
{
Caption = 'Ntfy Event';
DataClassification = CustomerContent;
DrillDownPageId = NtfyEventsNTSTM;
LookupPageId = NtfyEventsNTSTM;
Expand All @@ -18,15 +19,23 @@ table 71179875 NtfyEventNTSTM
TableRelation = User."User Name";
ValidateTableRelation = false;
}
field(2; NtfyTopic; Text[150])
field(2; Topic; Text[150])
{
Caption = 'Topic';
TableRelation = NtfyTopicNTSTM.Topic;
}
field(5; LineNo; Integer)
{
Caption = 'Line No.';
}
field(3; EventType; Enum EventTypeNTSTM)
{
Caption = 'Event Type';
}
field(6; Description; Text[100])
{
Caption = 'Description';
}
field(4; FilterText; Text[2048])
{
AllowInCustomizations = Never;
Expand All @@ -36,7 +45,7 @@ table 71179875 NtfyEventNTSTM

keys
{
key(Key1; UserName, NtfyTopic, EventType)
key(Key1; UserName, Topic, LineNo)
{
Clustered = true;
}
Expand Down Expand Up @@ -70,14 +79,14 @@ table 71179875 NtfyEventNTSTM
NtfyEventRequest: Record NtfyEventRequestNTSTM;
begin
Rec.SetRange(EventType, Type);
Rec.SetFilter(NtfyTopic, '<>%1', '');
Rec.SetFilter(Topic, '<>%1', '');
INtfyEvent.FilterNtfyEntriesBeforeBatchSend(Rec, Params);
if Rec.FindSet() then
repeat
if INtfyEvent.DoCallNtfyEvent(Rec, Params) then begin
NtfyEventRequest.Init();
NtfyEventRequest.Validate(EntryNo, NtfyEventRequest.EntryNo + 1);
NtfyEventRequest.Validate(NtfyTopic, Rec.NtfyTopic);
NtfyEventRequest.Validate(NtfyTopic, Rec.Topic);
NtfyEventRequest.Validate(NtfyTitle, INtfyEvent.GetTitle(Rec, Params));
NtfyEventRequest.Validate(NtfyMessage, INtfyEvent.GetMessage(Rec, Params));
if NtfyEventRequest.NtfyMessage = '' then
Expand Down
10 changes: 8 additions & 2 deletions MSDyn365BC.Ntfy/src/foundation/NtfyTopic.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ using System.Security.AccessControl;
table 71179876 NtfyTopicNTSTM
{
Caption = 'Ntfy Topic';
DrillDownPageId = NtfyTopicsNTSTM;
LookupPageId = NtfyTopicsNTSTM;
DrillDownPageId = NtfyTopicListNTSTM;
LookupPageId = NtfyTopicListNTSTM;
DataClassification = CustomerContent;
InherentEntitlements = RIMDX;
InherentPermissions = RIMDX;
Expand All @@ -18,11 +18,17 @@ table 71179876 NtfyTopicNTSTM
Caption = 'User Name';
TableRelation = User."User Name";
ValidateTableRelation = false;
Editable = false;
}
field(2; Topic; Text[150])
{
Caption = 'Topic';
}
field(3; Enabled; Boolean)
{
Caption = 'Enabled';
InitValue = true;
}
}

keys
Expand Down
32 changes: 32 additions & 0 deletions MSDyn365BC.Ntfy/src/foundation/NtfyTopicCard.Page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace StefanMaron.Ntfy;
using StefanMaron.Ntfy;
page 71179878 NtfyTopicCardNTSTM
{
Caption = 'Ntfy Topic';
PageType = Card;
ApplicationArea = All;
UsageCategory = None;
DelayedInsert = true;
PopulateAllFields = true;
SourceTable = NtfyTopicNTSTM;
InherentEntitlements = X;
InherentPermissions = X;

layout
{
area(Content)
{
group(General)
{
field(NtfyTopic; Rec.Topic) { }
field(UserName; Rec.UserName) { }
field(Enabled; Rec.Enabled) { }
}
part(NtfyEventsNTSTM; NtfyEventsNTSTM)
{
Caption = 'Events';
SubPageLink = UserName = field(UserName), Topic = field(Topic);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
namespace StefanMaron.Ntfy;
using StefanMaron.Ntfy;
page 71179876 NtfyTopicsNTSTM
page 71179876 NtfyTopicListNTSTM
{
Caption = 'Ntfy Topics';
PageType = List;
ApplicationArea = All;
UsageCategory = Administration;
CardPageId = NtfyTopicCardNTSTM;
DelayedInsert = true;
PopulateAllFields = true;
Editable = false;
SourceTable = NtfyTopicNTSTM;
InherentEntitlements = X;
InherentPermissions = X;
Expand All @@ -18,12 +19,9 @@ page 71179876 NtfyTopicsNTSTM
{
repeater(GroupName)
{
field(UserName; Rec.UserName)
{
//TODO: Visible for administrators
Visible = false;
}
field(NtfyTopic; Rec.Topic) { }
field(UserName; Rec.UserName) { }
field(Enabled; Rec.Enabled) { }
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions MSDyn365BC.Ntfy/src/helperInterfaces/NtfyHelper.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace StefanMaron.Ntfy;

codeunit 71179886 NtfyHelperNTSTM
{

Access = Public;
InherentEntitlements = X;
InherentPermissions = X;

procedure GetFilterTextForTable(var FilterPageBuilder: FilterPageBuilder; Caption: Text; TableId: Integer; var FilterText: Text[2048])
begin
FilterPageBuilder.AddTable(Caption, TableId);
if FilterText <> '' then
FilterPageBuilder.SetView(Caption, FilterText);
if FilterPageBuilder.RunModal() then
if not FilterPageBuilder.GetView(Caption).Contains('WHERE') then
FilterText := ''
else
FilterText := CopyStr(FilterPageBuilder.GetView(Caption), 1, MaxStrLen(FilterText));
end;

procedure GetFilterTextForTable(TableId: Integer; var FilterText: Text[2048])
var
FilterPageBuilder: FilterPageBuilder;
RecRef: RecordRef;
begin
RecRef.Open(TableId);
GetFilterTextForTable(FilterPageBuilder, RecRef.Caption, TableId, FilterText);
end;
}

0 comments on commit 4b2ac97

Please sign in to comment.