From aadcf2c06f9bd88b3866e645ee4722ef21eb9a1d Mon Sep 17 00:00:00 2001 From: Kitt Parker Date: Mon, 5 Oct 2026 17:26:41 -0400 Subject: [PATCH] Initial public release --- .gitattributes | 11 + .gitignore | 11 + .../extensions/SM208000_GISidePanels.html | 13 + .../extensions/SM208000_GISidePanels.ts | 36 +++ AcuProjectSource/_project/ProjectMetadata.xml | 1 + .../_project/Sql_GISidePanelParameter.xml | 24 ++ .../_project/Sql_GISidePanelTarget.xml | 30 ++ GISidePanelMessages.cs | 23 ++ GISidePanelParameter.cs | 130 +++++++++ GISidePanelRuntime.cs | 275 ++++++++++++++++++ GISidePanelTarget.cs | 141 +++++++++ GISidePanels.csproj | 60 ++++ GISidePanels.sln | 64 ++++ GenericInquiryDesigner_Extension.cs | 264 +++++++++++++++++ Package/project.xml | 59 ++++ Properties/AssemblyInfo.cs | 33 +++ README.md | 179 ++++++++++++ 17 files changed, 1354 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.html create mode 100644 AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.ts create mode 100644 AcuProjectSource/_project/ProjectMetadata.xml create mode 100644 AcuProjectSource/_project/Sql_GISidePanelParameter.xml create mode 100644 AcuProjectSource/_project/Sql_GISidePanelTarget.xml create mode 100644 GISidePanelMessages.cs create mode 100644 GISidePanelParameter.cs create mode 100644 GISidePanelRuntime.cs create mode 100644 GISidePanelTarget.cs create mode 100644 GISidePanels.csproj create mode 100644 GISidePanels.sln create mode 100644 GenericInquiryDesigner_Extension.cs create mode 100644 Package/project.xml create mode 100644 Properties/AssemblyInfo.cs create mode 100644 README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fd30d92 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text=auto + +.gitattributes text eol=lf +.gitignore text eol=lf +*.cs text eol=crlf +*.sln text eol=lf +*.csproj text eol=lf +*.xml text eol=lf +*.ts text eol=lf +*.html text eol=lf +*.md text eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b7749ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +bin/ +obj/ +.vs/ +.idea/ +*.user +*.suo +*.pdb +Package/Bin/ +GISidePanels.zip +TestResults/ +artifacts/ diff --git a/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.html b/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.html new file mode 100644 index 0000000..4cf3326 --- /dev/null +++ b/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.html @@ -0,0 +1,13 @@ + diff --git a/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.ts b/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.ts new file mode 100644 index 0000000..75d6d97 --- /dev/null +++ b/AcuProjectSource/FrontendSources/screen/src/development/GISidePanels/screens/SM/SM208000/extensions/SM208000_GISidePanels.ts @@ -0,0 +1,36 @@ +import { + createCollection, + gridConfig, + GridPreset, + PXFieldOptions, + PXFieldState, + PXView, + viewInfo +} from "client-controls"; +import { SM208000 } from "src/screens/SM/SM208000/SM208000"; + +export interface SM208000_GISidePanels extends SM208000 { } + +export class SM208000_GISidePanels { + @viewInfo({ containerName: "Side Panel Targets" }) + SidePanelTargets = createCollection(GISidePanelTarget); + + @viewInfo({ containerName: "Side Panel Parameters" }) + SidePanelParameters = createCollection(GISidePanelParameter); +} + +@gridConfig({ preset: GridPreset.Details, initNewRow: true, syncPosition: true }) +export class GISidePanelTarget extends PXView { + IsActive: PXFieldState; + TargetScreenID: PXFieldState; + Title: PXFieldState; + Icon: PXFieldState; + SortOrder: PXFieldState; +} + +@gridConfig({ preset: GridPreset.Details, initNewRow: true }) +export class GISidePanelParameter extends PXView { + ParameterName: PXFieldState; + SourceViewName: PXFieldState; + SourceFieldName: PXFieldState; +} diff --git a/AcuProjectSource/_project/ProjectMetadata.xml b/AcuProjectSource/_project/ProjectMetadata.xml new file mode 100644 index 0000000..3c9d5ca --- /dev/null +++ b/AcuProjectSource/_project/ProjectMetadata.xml @@ -0,0 +1 @@ + diff --git a/AcuProjectSource/_project/Sql_GISidePanelParameter.xml b/AcuProjectSource/_project/Sql_GISidePanelParameter.xml new file mode 100644 index 0000000..02e0548 --- /dev/null +++ b/AcuProjectSource/_project/Sql_GISidePanelParameter.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + +]]> + diff --git a/AcuProjectSource/_project/Sql_GISidePanelTarget.xml b/AcuProjectSource/_project/Sql_GISidePanelTarget.xml new file mode 100644 index 0000000..6dcb65a --- /dev/null +++ b/AcuProjectSource/_project/Sql_GISidePanelTarget.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + diff --git a/GISidePanelMessages.cs b/GISidePanelMessages.cs new file mode 100644 index 0000000..92d7ab9 --- /dev/null +++ b/GISidePanelMessages.cs @@ -0,0 +1,23 @@ +using PX.Common; + +namespace GISidePanels +{ + [PXLocalizable(ErrorTitle)] + public static class GISidePanelMessages + { + public const string ErrorTitle = "GI Side Panels Error"; + public const string GISidePanelTarget = "GI Side Panel Target"; + public const string GISidePanelParameter = "GI Side Panel Parameter"; + public const string GenericInquirySidePanel = "Generic Inquiry"; + public const string TargetGraphUnavailable = "The target screen '{0}' does not use an Acumatica graph and cannot host a side panel."; + public const string SourceViewUnavailable = "The source view '{0}' is not available on target screen '{1}'."; + public const string SourceFieldUnavailable = "The source field '{0}' is not available in view '{1}' on target screen '{2}'."; + public const string SourceFieldValueUnavailable = "The source field '{0}' in view '{1}' has no value on target screen '{2}'."; + public const string SourceRecordUnavailable = "No current record is available in view '{0}' on screen '{1}'."; + public const string GIParameterUnavailable = "The active GI parameter '{0}' does not exist on this Generic Inquiry."; + public const string DuplicateGIParameterMapping = "The GI parameter '{0}' is already mapped for this target screen."; + public const string GenericInquiryUnavailable = "The Generic Inquiry with ID '{0}' is no longer available."; + public const string RuntimeRegistrationFailure = "GISidePanels could not register target screen '{0}': {1}"; + public const string RuntimeLoadFailure = "GISidePanels could not load configured target screens: {0}"; + } +} diff --git a/GISidePanelParameter.cs b/GISidePanelParameter.cs new file mode 100644 index 0000000..ebeeaa3 --- /dev/null +++ b/GISidePanelParameter.cs @@ -0,0 +1,130 @@ +using PX.Data; +using PX.Data.BQL; +using PX.Data.ReferentialIntegrity.Attributes; +using System; + +namespace GISidePanels +{ + [Serializable] + [PXCacheName(GISidePanelMessages.GISidePanelParameter)] + public class GISidePanelParameter : PXBqlTable, IBqlTable + { + public class PK : PrimaryKeyOf.By + { + public static GISidePanelParameter Find(PXGraph graph, Guid? designID, string targetScreenID, int? lineNbr, PKFindOptions options = PKFindOptions.None) + { + return FindBy(graph, designID, targetScreenID, lineNbr, options); + } + } + + public static class FK + { + public class Target : GISidePanelTarget.PK.ForeignKeyOf.By { } + } + + #region DesignID + [PXDBGuid(false, IsKey = true)] + [PXDBDefault(typeof(GISidePanelTarget.designID))] + public virtual Guid? DesignID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class designID : BqlGuid.Field { } + #endregion + + #region TargetScreenID + [PXDBString(8, IsFixed = true, IsKey = true, InputMask = "CC.CC.CC.CC")] + [PXDBDefault(typeof(GISidePanelTarget.targetScreenID))] + [PXParent(typeof(FK.Target))] + public virtual string TargetScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class targetScreenID : BqlString.Field { } + #endregion + + #region LineNbr + [PXDBInt(IsKey = true)] + [PXLineNbr(typeof(GISidePanelTarget.parameterLineCntr))] + [PXUIField(DisplayName = "Line Nbr.", Visible = false, Enabled = false)] + public virtual int? LineNbr { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lineNbr : BqlInt.Field { } + #endregion + + #region ParameterName + [PXDBString(255, IsUnicode = true)] + [PXDefault] + [PXUIField(DisplayName = "GI Parameter")] + [PXStringList(new string[] { }, new string[] { }, ExclusiveValues = true)] + public virtual string ParameterName { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class parameterName : BqlString.Field { } + #endregion + + #region SourceViewName + [PXDBString(255, IsUnicode = true)] + [PXDefault] + [PXUIField(DisplayName = "Source View")] + [PXStringList(new string[] { }, new string[] { }, ExclusiveValues = true)] + public virtual string SourceViewName { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class sourceViewName : BqlString.Field { } + #endregion + + #region SourceFieldName + [PXDBString(255, IsUnicode = true)] + [PXDefault] + [PXUIField(DisplayName = "Source Field")] + [PXStringList(new string[] { }, new string[] { }, ExclusiveValues = true)] + public virtual string SourceFieldName { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class sourceFieldName : BqlString.Field { } + #endregion + + #region CreatedByID + [PXDBCreatedByID] + public virtual Guid? CreatedByID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdByID : BqlGuid.Field { } + #endregion + + #region CreatedByScreenID + [PXDBCreatedByScreenID] + public virtual string CreatedByScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdByScreenID : BqlString.Field { } + #endregion + + #region CreatedDateTime + [PXDBCreatedDateTime] + public virtual DateTime? CreatedDateTime { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdDateTime : BqlDateTime.Field { } + #endregion + + #region LastModifiedByID + [PXDBLastModifiedByID] + public virtual Guid? LastModifiedByID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedByID : BqlGuid.Field { } + #endregion + + #region LastModifiedByScreenID + [PXDBLastModifiedByScreenID] + public virtual string LastModifiedByScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedByScreenID : BqlString.Field { } + #endregion + + #region LastModifiedDateTime + [PXDBLastModifiedDateTime] + public virtual DateTime? LastModifiedDateTime { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedDateTime : BqlDateTime.Field { } + #endregion + + #region Tstamp + [PXDBTimestamp] + public virtual byte[] Tstamp { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class tstamp : BqlByteArray.Field { } + #endregion + } +} diff --git a/GISidePanelRuntime.cs b/GISidePanelRuntime.cs new file mode 100644 index 0000000..c4ca1e1 --- /dev/null +++ b/GISidePanelRuntime.cs @@ -0,0 +1,275 @@ +using PX.Common; +using PX.Data; +using PX.Data.BQL; +using PX.Data.BQL.Fluent; +using PX.Data.Maintenance.GI; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Web.Compilation; + +namespace GISidePanels +{ + // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod This universal extension resolves applicability from the configured target screen at runtime. + public class GISidePanelUniversalExtension : PXGraphExtension + { + public override void Initialize() + { + base.Initialize(); + GISidePanelRuntime.RegisterConfiguredSidePanels(Base); + } + } + + public static class GISidePanelRuntime + { + private sealed class ConfiguredTarget + { + public Guid DesignID { get; set; } + public string TargetScreenID { get; set; } + public string Title { get; set; } + public string Icon { get; set; } + public int SortOrder { get; set; } + } + + private sealed class NavigateActionHandler + { + private readonly PXGraph _graph; + private readonly Guid _designID; + private readonly string _targetScreenID; + + internal NavigateActionHandler(PXGraph graph, Guid designID, string targetScreenID) + { + _graph = graph; + _designID = designID; + _targetScreenID = targetScreenID; + } + + internal IEnumerable Invoke(PXAdapter adapter) + { + NavigateToGenericInquiry(_graph, _designID, _targetScreenID); + return adapter.Get(); + } + } + + private sealed class ConfigurationSlot : IPrefetchable + { + private const string SlotName = nameof(GISidePanelRuntime) + "." + nameof(ConfigurationSlot); + private readonly Dictionary> _targetsByScreen = + new Dictionary>(StringComparer.OrdinalIgnoreCase); + + void IPrefetchable.Prefetch() + { + _targetsByScreen.Clear(); + + foreach (PXDataRecord record in PXDatabase.SelectMulti( + new PXDataField(), + new PXDataField(), + new PXDataField(), + new PXDataField(), + new PXDataField(), + new PXDataFieldValue(PXDbType.Bit, true))) + { + Guid? designID = record.GetGuid(0); + string screenID = NormalizeScreenID(record.GetString(1)); + if (designID == null || string.IsNullOrWhiteSpace(screenID)) + { + continue; + } + + if (!_targetsByScreen.TryGetValue(screenID, out List targets)) + { + targets = new List(); + _targetsByScreen.Add(screenID, targets); + } + + targets.Add(new ConfiguredTarget + { + DesignID = designID.Value, + TargetScreenID = screenID, + Title = record.GetString(2), + Icon = record.GetString(3), + SortOrder = record.GetInt32(4) ?? 0 + }); + } + + foreach (List targets in _targetsByScreen.Values) + { + targets.Sort((left, right) => + { + int orderComparison = left.SortOrder.CompareTo(right.SortOrder); + return orderComparison != 0 + ? orderComparison + : left.DesignID.CompareTo(right.DesignID); + }); + } + } + + internal static IReadOnlyList GetTargets(string screenID) + { + ConfigurationSlot slot = PXDatabase.GetSlot( + SlotName, + typeof(GISidePanelTarget)); + + if (slot._targetsByScreen.TryGetValue(screenID, out List targets)) + { + return targets; + } + + return Array.Empty(); + } + } + + internal static bool IsMappableSourceField(PXCache cache, string fieldName) + { + return cache != null + && !string.IsNullOrWhiteSpace(fieldName) + && cache.GetBqlField(fieldName) != null; + } + + public static Type ResolveTargetGraphType(PXGraph graph, string screenID) + { + if (graph == null || string.IsNullOrWhiteSpace(screenID)) + { + return null; + } + + PX.SM.SiteMap siteMapNode = PX.SM.SiteMap.UK.Find(graph, screenID); + if (siteMapNode == null || string.IsNullOrWhiteSpace(siteMapNode.Graphtype)) + { + return null; + } + + Type graphType = PXBuildManager.GetType(siteMapNode.Graphtype, false); + if (graphType == null || graphType.IsAbstract || graphType.ContainsGenericParameters || !typeof(PXGraph).IsAssignableFrom(graphType)) + { + return null; + } + + return graphType; + } + + internal static string[] GetTargetViewNames(Type graphType) + { + if (graphType == null) + { + return Array.Empty(); + } + + return GraphHelper.GetGraphViews(graphType, false) + .Where(view => view.Cache?.CacheType != null && !string.IsNullOrWhiteSpace(view.Name)) + .Select(view => view.Name) + .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(viewName => viewName, StringComparer.OrdinalIgnoreCase) + .ToArray(); + } + + internal static Type ResolveTargetViewCacheType(Type graphType, string viewName) + { + if (graphType == null || string.IsNullOrWhiteSpace(viewName)) + { + return null; + } + + PXViewInfo viewInfo = GraphHelper.GetGraphViews(graphType, false) + .FirstOrDefault(view => string.Equals(view.Name, viewName, StringComparison.OrdinalIgnoreCase)); + return viewInfo?.Cache?.CacheType; + } + + internal static void RegisterConfiguredSidePanels(PXGraph graph) + { + string screenID = NormalizeScreenID(graph.Accessinfo.ScreenID ?? PXContext.GetScreenID()); + if (string.IsNullOrWhiteSpace(screenID) || graph.PrimaryItemType == null) + { + return; + } + + Type targetGraphType = ResolveTargetGraphType(graph, screenID); + if (targetGraphType == null || !targetGraphType.IsAssignableFrom(graph.GetType())) + { + return; + } + + string customActionPrefix = PXGraph.SidePanelAction.Prefix + "GISP_"; + graph.SidePanelActions.RemoveAll(action => action.ActionName?.StartsWith( + customActionPrefix, + StringComparison.OrdinalIgnoreCase) == true); + + foreach (ConfiguredTarget target in ConfigurationSlot.GetTargets(screenID)) + { + string actionName = PXGraph.SidePanelAction.Prefix + "GISP_" + target.DesignID.ToString("N"); + if (graph.Actions[actionName] == null) + { + NavigateActionHandler handler = new NavigateActionHandler( + graph, + target.DesignID, + target.TargetScreenID); + PXNamedAction.AddHiddenAction(graph, graph.PrimaryItemType, actionName, handler.Invoke); + } + + string title = string.IsNullOrWhiteSpace(target.Title) + ? GISidePanelMessages.GenericInquirySidePanel + : target.Title; + string icon = string.IsNullOrWhiteSpace(target.Icon) ? "apps" : target.Icon; + graph.SidePanelActions.Add(new PXGraph.SidePanelAction(actionName, icon, title)); + } + } + + private static string NormalizeScreenID(string screenID) + { + return screenID?.Replace(".", string.Empty).Trim(); + } + + private static void NavigateToGenericInquiry(PXGraph graph, Guid designID, string targetScreenID) + { + GIDesign design = GIDesign.PK.Find(graph, designID); + if (design == null || string.IsNullOrWhiteSpace(design.Name)) + { + throw new PXException(GISidePanelMessages.GenericInquiryUnavailable, designID); + } + + Dictionary parameters = new Dictionary(StringComparer.OrdinalIgnoreCase); + PXResultset mappings = SelectFrom + .Where + .And>> + .OrderBy + .View.ReadOnly.Select(graph, designID, targetScreenID); + + foreach (GISidePanelParameter mapping in mappings.RowCast()) + { + PXView sourceView = graph.Views[mapping.SourceViewName] + ?? throw new PXException(GISidePanelMessages.SourceViewUnavailable, mapping.SourceViewName, targetScreenID); + + PXCache sourceCache = sourceView.Cache; + if (!IsMappableSourceField(sourceCache, mapping.SourceFieldName)) + { + throw new PXException(GISidePanelMessages.SourceFieldUnavailable, mapping.SourceFieldName, mapping.SourceViewName, targetScreenID); + } + + object currentRecord = sourceCache.Current + ?? throw new PXException(GISidePanelMessages.SourceRecordUnavailable, mapping.SourceViewName, targetScreenID); + + object value = sourceCache.GetValue(currentRecord, mapping.SourceFieldName); + string valueText = value == null + ? null + : Convert.ToString(value, CultureInfo.CurrentCulture); + if (string.IsNullOrWhiteSpace(valueText)) + { + throw new PXException( + GISidePanelMessages.SourceFieldValueUnavailable, + mapping.SourceFieldName, + mapping.SourceViewName, + targetScreenID); + } + + parameters[mapping.ParameterName] = valueText; + } + + throw new PXRedirectToGIRequiredException( + design.Name, + parameters, + PXBaseRedirectException.WindowMode.Layer); + } + } +} diff --git a/GISidePanelTarget.cs b/GISidePanelTarget.cs new file mode 100644 index 0000000..11f747a --- /dev/null +++ b/GISidePanelTarget.cs @@ -0,0 +1,141 @@ +using PX.Data; +using PX.Data.BQL; +using PX.Data.Maintenance.GI; +using PX.Data.ReferentialIntegrity.Attributes; +using PX.SM; +using System; + +namespace GISidePanels +{ + [Serializable] + [PXCacheName(GISidePanelMessages.GISidePanelTarget)] + public class GISidePanelTarget : PXBqlTable, IBqlTable + { + public class PK : PrimaryKeyOf.By + { + public static GISidePanelTarget Find(PXGraph graph, Guid? designID, string targetScreenID, PKFindOptions options = PKFindOptions.None) + { + return FindBy(graph, designID, targetScreenID, options); + } + } + + public static class FK + { + public class GenericInquiry : GIDesign.PK.ForeignKeyOf.By { } + } + + #region DesignID + [PXDBGuid(false, IsKey = true)] + [PXDBDefault(typeof(GIDesign.designID))] + [PXParent(typeof(FK.GenericInquiry))] + public virtual Guid? DesignID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class designID : BqlGuid.Field { } + #endregion + + #region TargetScreenID + [PXDBString(8, IsFixed = true, IsKey = true, InputMask = "CC.CC.CC.CC")] + [PXDefault] + [PXUIField(DisplayName = "Target Screen", Visibility = PXUIVisibility.SelectorVisible)] + [PXSiteMapNodeSelector] + public virtual string TargetScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class targetScreenID : BqlString.Field { } + #endregion + + #region IsActive + [PXDBBool] + [PXDefault(true)] + [PXUIField(DisplayName = "Active")] + public virtual bool? IsActive { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class isActive : BqlBool.Field { } + #endregion + + #region Title + [PXDBString(255, IsUnicode = true)] + [PXDefault(PersistingCheck = PXPersistingCheck.Nothing)] + [PXUIField(DisplayName = "Side Panel Title")] + public virtual string Title { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class title : BqlString.Field { } + #endregion + + #region Icon + [PXDBString(255, IsUnicode = true)] + [PXDefault("apps", PersistingCheck = PXPersistingCheck.Nothing)] + [PXUIField(DisplayName = "Icon")] + [PXScalableIconsList] + public virtual string Icon { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class icon : BqlString.Field<icon> { } + #endregion + + #region SortOrder + [PXDBInt] + [PXDefault(0)] + [PXUIField(DisplayName = "Order")] + public virtual int? SortOrder { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class sortOrder : BqlInt.Field<sortOrder> { } + #endregion + + #region ParameterLineCntr + [PXDBInt] + [PXDefault(0)] + [PXUIField(Visible = false, Enabled = false)] + public virtual int? ParameterLineCntr { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class parameterLineCntr : BqlInt.Field<parameterLineCntr> { } + #endregion + + #region CreatedByID + [PXDBCreatedByID] + public virtual Guid? CreatedByID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdByID : BqlGuid.Field<createdByID> { } + #endregion + + #region CreatedByScreenID + [PXDBCreatedByScreenID] + public virtual string CreatedByScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdByScreenID : BqlString.Field<createdByScreenID> { } + #endregion + + #region CreatedDateTime + [PXDBCreatedDateTime] + public virtual DateTime? CreatedDateTime { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class createdDateTime : BqlDateTime.Field<createdDateTime> { } + #endregion + + #region LastModifiedByID + [PXDBLastModifiedByID] + public virtual Guid? LastModifiedByID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedByID : BqlGuid.Field<lastModifiedByID> { } + #endregion + + #region LastModifiedByScreenID + [PXDBLastModifiedByScreenID] + public virtual string LastModifiedByScreenID { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedByScreenID : BqlString.Field<lastModifiedByScreenID> { } + #endregion + + #region LastModifiedDateTime + [PXDBLastModifiedDateTime] + public virtual DateTime? LastModifiedDateTime { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class lastModifiedDateTime : BqlDateTime.Field<lastModifiedDateTime> { } + #endregion + + #region Tstamp + [PXDBTimestamp] + public virtual byte[] Tstamp { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Acumatica Standard")] + public abstract class tstamp : BqlByteArray.Field<tstamp> { } + #endregion + } +} diff --git a/GISidePanels.csproj b/GISidePanels.csproj new file mode 100644 index 0000000..ecc4b37 --- /dev/null +++ b/GISidePanels.csproj @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net48</TargetFramework> + <OutputType>Library</OutputType> + <RootNamespace>GISidePanels</RootNamespace> + <AssemblyName>GISidePanels</AssemblyName> + <GenerateAssemblyInfo>false</GenerateAssemblyInfo> + <FileVersion>26.101.0225</FileVersion> + <InformationalVersion>26.101.0225</InformationalVersion> + <Deterministic>false</Deterministic> + <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> + <RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild> + <AcumaticaBinPath Condition="'$(AcumaticaBinPath)' == ''">$(MSBuildProjectDirectory)\..\..\..\Acumatica ERP\Acu26R1\Bin</AcumaticaBinPath> + </PropertyGroup> + <ItemGroup> + <Reference Include="PX.Common"> + <HintPath>$(AcumaticaBinPath)\PX.Common.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.Common.Std"> + <HintPath>$(AcumaticaBinPath)\PX.Common.Std.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.CS.Contracts"> + <HintPath>$(AcumaticaBinPath)\PX.CS.Contracts.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.Data"> + <HintPath>$(AcumaticaBinPath)\PX.Data.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.Data.BQL.Fluent"> + <HintPath>$(AcumaticaBinPath)\PX.Data.BQL.Fluent.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.DbServices"> + <HintPath>$(AcumaticaBinPath)\PX.DbServices.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="PX.Objects"> + <HintPath>$(AcumaticaBinPath)\PX.Objects.dll</HintPath> + <Private>False</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <PackageReference Include="Acuminator.Analyzers" Version="4.0.1"> + <PrivateAssets>all</PrivateAssets> + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> + </PackageReference> + <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" /> + <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" /> + </ItemGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Web" /> + <Reference Include="System.Xml" /> + </ItemGroup> +</Project> diff --git a/GISidePanels.sln b/GISidePanels.sln new file mode 100644 index 0000000..f42cebd --- /dev/null +++ b/GISidePanels.sln @@ -0,0 +1,64 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 18 +VisualStudioVersion = 18.3.11505.172 d18.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GISidePanels", "GISidePanels.csproj", "{B4DF60EA-2873-4DCE-867A-6C62233F07D2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AcuProjectSource", "AcuProjectSource", "{A626E9B2-AFFE-46BD-9049-225C8AF497FA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_project", "_project", "{323F4BB6-5A2B-4897-9EAB-727A3CD16A29}" + ProjectSection(SolutionItems) = preProject + AcuProjectSource\_project\ProjectMetadata.xml = AcuProjectSource\_project\ProjectMetadata.xml + AcuProjectSource\_project\Sql_GISidePanelParameter.xml = AcuProjectSource\_project\Sql_GISidePanelParameter.xml + AcuProjectSource\_project\Sql_GISidePanelTarget.xml = AcuProjectSource\_project\Sql_GISidePanelTarget.xml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FrontendSources", "FrontendSources", "{08190DE6-A1BE-40CE-8613-3D9543FBDE46}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "screen", "screen", "{7A764483-C4D0-40E7-AE28-B67DE706258D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EA655123-D45C-480F-981F-DCE7FC57A0F6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "development", "development", "{A002A8A4-700A-4796-B153-2A63D9B34B4A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GISidePanels", "GISidePanels", "{EE868D0D-3F61-49B0-BAA6-C3833DB00D28}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "screens", "screens", "{68B253B5-EB25-4E74-9DD0-D3F7339E55D5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SM", "SM", "{1E0D19A9-5AE3-413A-9537-A2E7C0059E5B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SM208000", "SM208000", "{60D1E36F-31AB-4B14-A06B-5EABAB540C78}" + ProjectSection(SolutionItems) = preProject + AcuProjectSource\FrontendSources\screen\src\development\GISidePanels\screens\SM\SM208000\extensions\SM208000_GISidePanels.html = AcuProjectSource\FrontendSources\screen\src\development\GISidePanels\screens\SM\SM208000\extensions\SM208000_GISidePanels.html + AcuProjectSource\FrontendSources\screen\src\development\GISidePanels\screens\SM\SM208000\extensions\SM208000_GISidePanels.ts = AcuProjectSource\FrontendSources\screen\src\development\GISidePanels\screens\SM\SM208000\extensions\SM208000_GISidePanels.ts + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B4DF60EA-2873-4DCE-867A-6C62233F07D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B4DF60EA-2873-4DCE-867A-6C62233F07D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4DF60EA-2873-4DCE-867A-6C62233F07D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B4DF60EA-2873-4DCE-867A-6C62233F07D2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {323F4BB6-5A2B-4897-9EAB-727A3CD16A29} = {A626E9B2-AFFE-46BD-9049-225C8AF497FA} + {08190DE6-A1BE-40CE-8613-3D9543FBDE46} = {A626E9B2-AFFE-46BD-9049-225C8AF497FA} + {7A764483-C4D0-40E7-AE28-B67DE706258D} = {08190DE6-A1BE-40CE-8613-3D9543FBDE46} + {EA655123-D45C-480F-981F-DCE7FC57A0F6} = {7A764483-C4D0-40E7-AE28-B67DE706258D} + {A002A8A4-700A-4796-B153-2A63D9B34B4A} = {EA655123-D45C-480F-981F-DCE7FC57A0F6} + {EE868D0D-3F61-49B0-BAA6-C3833DB00D28} = {A002A8A4-700A-4796-B153-2A63D9B34B4A} + {68B253B5-EB25-4E74-9DD0-D3F7339E55D5} = {EE868D0D-3F61-49B0-BAA6-C3833DB00D28} + {1E0D19A9-5AE3-413A-9537-A2E7C0059E5B} = {68B253B5-EB25-4E74-9DD0-D3F7339E55D5} + {60D1E36F-31AB-4B14-A06B-5EABAB540C78} = {1E0D19A9-5AE3-413A-9537-A2E7C0059E5B} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B1BF3E13-B02B-4002-B218-B545195DFD4A} + EndGlobalSection +EndGlobal diff --git a/GenericInquiryDesigner_Extension.cs b/GenericInquiryDesigner_Extension.cs new file mode 100644 index 0000000..668612f --- /dev/null +++ b/GenericInquiryDesigner_Extension.cs @@ -0,0 +1,264 @@ +using PX.Data; +using PX.Data.BQL; +using PX.Data.BQL.Fluent; +using PX.Data.Maintenance.GI; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace GISidePanels +{ + // Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod This extension is required on Generic Inquiry (SM208000). + public class GenericInquiryDesigner_Extension : PXGraphExtension<GenericInquiryDesigner> + { + public PXSelect<GISidePanelTarget, + Where<GISidePanelTarget.designID, Equal<Current<GIDesign.designID>>>, + OrderBy<Asc<GISidePanelTarget.sortOrder, Asc<GISidePanelTarget.targetScreenID>>>> SidePanelTargets; + + public PXSelect<GISidePanelParameter, + Where<GISidePanelParameter.designID, Equal<Current<GISidePanelTarget.designID>>, + And<GISidePanelParameter.targetScreenID, Equal<Current<GISidePanelTarget.targetScreenID>>>>, + OrderBy<Asc<GISidePanelParameter.lineNbr>>> SidePanelParameters; + + protected virtual void _(Events.RowInserting<GISidePanelTarget> eventArgs) + { + GISidePanelTarget row = eventArgs.Row; + if (row == null) + { + return; + } + + GIDesign design = Base.Designs.Current; + row.DesignID = design?.DesignID; + row.IsActive = row.IsActive ?? true; + row.Title = string.IsNullOrWhiteSpace(row.Title) + ? (string.IsNullOrWhiteSpace(design?.SitemapTitle) ? design?.Name : design.SitemapTitle) + : row.Title; + row.Icon = string.IsNullOrWhiteSpace(row.Icon) ? "apps" : row.Icon; + } + + protected virtual void _(Events.RowPersisting<GISidePanelTarget> eventArgs) + { + GISidePanelTarget row = eventArgs.Row; + if (row == null || eventArgs.Operation == PXDBOperation.Delete) + { + return; + } + + if (GISidePanelRuntime.ResolveTargetGraphType(Base, row.TargetScreenID) == null) + { + throw new PXRowPersistingException( + nameof(GISidePanelTarget.TargetScreenID), + row.TargetScreenID, + GISidePanelMessages.TargetGraphUnavailable, + row.TargetScreenID); + } + } + + protected virtual void _(Events.RowInserting<GISidePanelParameter> eventArgs) + { + GISidePanelParameter row = eventArgs.Row; + if (row == null) + { + return; + } + + GISidePanelTarget target = SidePanelTargets.Current; + row.DesignID = row.DesignID ?? target?.DesignID ?? Base.Designs.Current?.DesignID; + row.TargetScreenID = string.IsNullOrWhiteSpace(row.TargetScreenID) + ? target?.TargetScreenID + : row.TargetScreenID; + } + + protected virtual void _(Events.RowSelected<GISidePanelParameter> eventArgs) + { + ConfigureParameterLists(eventArgs.Cache, eventArgs.Row); + } + + protected virtual void _(Events.FieldUpdated<GISidePanelParameter, GISidePanelParameter.sourceViewName> eventArgs) + { + if (eventArgs.Row != null) + { + eventArgs.Cache.SetValue<GISidePanelParameter.sourceFieldName>(eventArgs.Row, null); + } + } + + protected virtual void _(Events.RowPersisting<GISidePanelParameter> eventArgs) + { + GISidePanelParameter row = eventArgs.Row; + if (row == null || eventArgs.Operation == PXDBOperation.Delete) + { + return; + } + + if (string.IsNullOrWhiteSpace(row.ParameterName) + && string.IsNullOrWhiteSpace(row.SourceViewName) + && string.IsNullOrWhiteSpace(row.SourceFieldName)) + { + eventArgs.Cancel = true; + return; + } + + Guid? designID = row.DesignID ?? Base.Designs.Current?.DesignID; + bool parameterExists = SelectActiveParameters(designID) + .Any(parameter => string.Equals(parameter.Name, row.ParameterName, StringComparison.OrdinalIgnoreCase)); + if (!parameterExists) + { + throw new PXRowPersistingException( + nameof(GISidePanelParameter.ParameterName), + row.ParameterName, + GISidePanelMessages.GIParameterUnavailable, + row.ParameterName); + } + + bool duplicateParameterExists = SidePanelParameters.Select() + .RowCast<GISidePanelParameter>() + .Any(parameter => parameter.LineNbr != row.LineNbr + && string.Equals(parameter.ParameterName, row.ParameterName, StringComparison.OrdinalIgnoreCase)); + if (duplicateParameterExists) + { + throw new PXRowPersistingException( + nameof(GISidePanelParameter.ParameterName), + row.ParameterName, + GISidePanelMessages.DuplicateGIParameterMapping, + row.ParameterName); + } + + Type graphType = GISidePanelRuntime.ResolveTargetGraphType(Base, row.TargetScreenID) + ?? throw new PXRowPersistingException( + nameof(GISidePanelParameter.TargetScreenID), + row.TargetScreenID, + GISidePanelMessages.TargetGraphUnavailable, + row.TargetScreenID); + + Type sourceCacheType = string.IsNullOrWhiteSpace(row.SourceViewName) + ? null + : GISidePanelRuntime.ResolveTargetViewCacheType(graphType, row.SourceViewName); + sourceCacheType = sourceCacheType + ?? throw new PXRowPersistingException( + nameof(GISidePanelParameter.SourceViewName), + row.SourceViewName, + GISidePanelMessages.SourceViewUnavailable, + row.SourceViewName, + row.TargetScreenID); + + PXCache sourceCache = Base.Caches[sourceCacheType]; + if (!GISidePanelRuntime.IsMappableSourceField(sourceCache, row.SourceFieldName)) + { + throw new PXRowPersistingException( + nameof(GISidePanelParameter.SourceFieldName), + row.SourceFieldName, + GISidePanelMessages.SourceFieldUnavailable, + row.SourceFieldName, + row.SourceViewName, + row.TargetScreenID); + } + } + + private void ConfigureParameterLists(PXCache cache, GISidePanelParameter row) + { + if (row == null) + { + return; + } + + if (Base.Designs.Current?.DesignID == null) + { + SetEmptyParameterLists(cache, row); + return; + } + + string[] parameterNames = SelectActiveParameters(Base.Designs.Current.DesignID) + .Select(parameter => parameter.Name) + .OrderBy(name => name, StringComparer.OrdinalIgnoreCase) + .ToArray(); + PXStringListAttribute.SetList<GISidePanelParameter.parameterName>( + cache, row, parameterNames, parameterNames); + + if (string.IsNullOrWhiteSpace(row.ParameterName) + || string.IsNullOrWhiteSpace(row.TargetScreenID)) + { + SetEmptySourceLists(cache, row); + return; + } + + Type graphType = GISidePanelRuntime.ResolveTargetGraphType(Base, row.TargetScreenID); + if (graphType == null) + { + SetEmptySourceLists(cache, row); + return; + } + + string[] viewNames = GISidePanelRuntime.GetTargetViewNames(graphType); + PXStringListAttribute.SetList<GISidePanelParameter.sourceViewName>( + cache, row, viewNames, viewNames); + + if (string.IsNullOrWhiteSpace(row.SourceViewName)) + { + PXStringListAttribute.SetList<GISidePanelParameter.sourceFieldName>( + cache, row, Array.Empty<string>(), Array.Empty<string>()); + return; + } + + Type sourceCacheType = GISidePanelRuntime.ResolveTargetViewCacheType(graphType, row.SourceViewName); + if (sourceCacheType == null) + { + PXStringListAttribute.SetList<GISidePanelParameter.sourceFieldName>( + cache, row, Array.Empty<string>(), Array.Empty<string>()); + return; + } + + PXCache sourceCache = Base.Caches[sourceCacheType]; + List<KeyValuePair<string, string>> fields = sourceCache.Fields + .Where(fieldName => GISidePanelRuntime.IsMappableSourceField(sourceCache, fieldName)) + .Select(fieldName => new KeyValuePair<string, string>( + fieldName, + GetFieldLabel(sourceCache, fieldName))) + .OrderBy(field => field.Value, StringComparer.OrdinalIgnoreCase) + .ToList(); + PXStringListAttribute.SetList<GISidePanelParameter.sourceFieldName>( + cache, + row, + fields.Select(field => field.Key).ToArray(), + fields.Select(field => field.Value).ToArray()); + } + + private static string GetFieldLabel(PXCache cache, string fieldName) + { + string displayName = PXUIFieldAttribute.GetDisplayName(cache, fieldName); + return string.IsNullOrWhiteSpace(displayName) || string.Equals(displayName, fieldName, StringComparison.OrdinalIgnoreCase) + ? fieldName + : displayName + " (" + fieldName + ")"; + } + + private IEnumerable<GIFilter> SelectActiveParameters(Guid? designID) + { + if (designID == null) + { + return Enumerable.Empty<GIFilter>(); + } + + return SelectFrom<GIFilter> + .Where<GIFilter.designID.IsEqual<@P.AsGuid>> + .View.ReadOnly.Select(Base, designID) + .RowCast<GIFilter>() + .ToArray() + .Where(parameter => parameter.IsActive == true && !string.IsNullOrWhiteSpace(parameter.Name)); + } + + private static void SetEmptySourceLists(PXCache cache, GISidePanelParameter row) + { + PXStringListAttribute.SetList<GISidePanelParameter.sourceViewName>( + cache, row, Array.Empty<string>(), Array.Empty<string>()); + PXStringListAttribute.SetList<GISidePanelParameter.sourceFieldName>( + cache, row, Array.Empty<string>(), Array.Empty<string>()); + } + + private static void SetEmptyParameterLists(PXCache cache, GISidePanelParameter row) + { + PXStringListAttribute.SetList<GISidePanelParameter.parameterName>( + cache, row, Array.Empty<string>(), Array.Empty<string>()); + SetEmptySourceLists(cache, row); + } + } +} diff --git a/Package/project.xml b/Package/project.xml new file mode 100644 index 0000000..d714f31 --- /dev/null +++ b/Package/project.xml @@ -0,0 +1,59 @@ +<Customization level="" description="Version 26 R1 2026-10-05 - Add configurable Generic Inquiry side panels with screen-context parameter mapping on Generic Inquiry (SM208000)." product-version="26.100"> + <File AppRelativePath="Bin\GISidePanels.dll" /> + <PerTenantFile AppRelativePath="screens\SM\SM208000\extensions\SM208000_GISidePanels.ts" ScreenId="SM208000" /> + <PerTenantFile AppRelativePath="screens\SM\SM208000\extensions\SM208000_GISidePanels.html" ScreenId="SM208000" /> + <Sql TableName="GISidePanelTarget" TableSchemaXml="#CDATA"> + <CDATA name="TableSchemaXml"><![CDATA[<table name="GISidePanelTarget"> + <col name="CompanyID" type="Int" default="Zero" /> + <col name="DesignID" type="UniqueIdentifier" /> + <col name="TargetScreenID" type="Char(8)" /> + <col name="IsActive" type="Bit" /> + <col name="Title" type="NVarChar(255)" nullable="true" /> + <col name="Icon" type="NVarChar(255)" nullable="true" /> + <col name="SortOrder" type="Int" /> + <col name="ParameterLineCntr" type="Int" /> + <col name="CreatedByID" type="UniqueIdentifier" /> + <col name="CreatedByScreenID" type="Char(8)" /> + <col name="CreatedDateTime" type="DateTime" /> + <col name="LastModifiedByID" type="UniqueIdentifier" /> + <col name="LastModifiedByScreenID" type="Char(8)" /> + <col name="LastModifiedDateTime" type="DateTime" /> + <col name="tstamp" type="Timestamp" /> + <index name="GISidePanelTarget_PK" clustered="true" primary="true" unique="true"> + <col name="CompanyID" /> + <col name="DesignID" /> + <col name="TargetScreenID" /> + </index> + <index name="GISidePanelTarget_Screen" clustered="false" primary="false" unique="false"> + <col name="CompanyID" /> + <col name="TargetScreenID" /> + <col name="IsActive" /> + <col name="SortOrder" /> + </index> +</table>]]></CDATA> + </Sql> + <Sql TableName="GISidePanelParameter" TableSchemaXml="#CDATA"> + <CDATA name="TableSchemaXml"><![CDATA[<table name="GISidePanelParameter"> + <col name="CompanyID" type="Int" default="Zero" /> + <col name="DesignID" type="UniqueIdentifier" /> + <col name="TargetScreenID" type="Char(8)" /> + <col name="LineNbr" type="Int" /> + <col name="ParameterName" type="NVarChar(255)" /> + <col name="SourceViewName" type="NVarChar(255)" /> + <col name="SourceFieldName" type="NVarChar(255)" /> + <col name="CreatedByID" type="UniqueIdentifier" /> + <col name="CreatedByScreenID" type="Char(8)" /> + <col name="CreatedDateTime" type="DateTime" /> + <col name="LastModifiedByID" type="UniqueIdentifier" /> + <col name="LastModifiedByScreenID" type="Char(8)" /> + <col name="LastModifiedDateTime" type="DateTime" /> + <col name="tstamp" type="Timestamp" /> + <index name="GISidePanelParameter_PK" clustered="true" primary="true" unique="true"> + <col name="CompanyID" /> + <col name="DesignID" /> + <col name="TargetScreenID" /> + <col name="LineNbr" /> + </index> +</table>]]></CDATA> + </Sql> +</Customization> diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6c91b63 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GISidePanels")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GISidePanels")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM. +[assembly: Guid("0ae007b5-4ebc-4af3-b950-8ba21efc4a3c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// The build and revision are generated because the assembly version uses '*'. +[assembly: AssemblyVersion("26.101.*")] +[assembly: AssemblyFileVersion("26.101.0225")] +[assembly: AssemblyInformationalVersion("26.101.0225")] diff --git a/README.md b/README.md new file mode 100644 index 0000000..84f975a --- /dev/null +++ b/README.md @@ -0,0 +1,179 @@ +# Acumatica Generic Inquiry Side Panels + +`GISidePanels` is an Acumatica 2026 R1 developer example that lets an administrator expose a Generic Inquiry as a contextual side-panel action on another screen. + +The customization adds a **Side Panel Targets** tab to Generic Inquiry (SM208000). Each target can map values from the current record on the host screen into GI parameters, so the inquiry opens already filtered to the record the user is viewing. + +> Example: Open a project on Projects (PM301000), select the side-panel action, and display only the inquiry rows related to that project. + +## The problem it solves + +Acumatica Generic Inquiries can define navigation from the inquiry to another screen. This project demonstrates the inverse relationship: configuring a GI so that it becomes a side-panel option on one or more target screens. + +The configuration is reusable rather than hard-coded. An administrator selects: + +- The target screen. +- The side-panel caption, icon, and display order. +- The active GI parameters to populate. +- The source view and field on the target screen for each parameter. + +## Feature highlights + +- Adds a Modern UI configuration tab to Generic Inquiry (SM208000). +- Supports multiple target screens for the same GI. +- Supports multiple GI parameter mappings per target screen. +- Discovers target graph views and BQL-backed fields dynamically. +- Registers side-panel actions on compatible target graphs at runtime. +- Uses an `IPrefetchable` database slot to avoid querying configuration during graph initialization. +- Validates target screens, GI parameters, source views, source fields, and duplicate mappings before persistence. +- Stops navigation when a required mapped value is unavailable, preventing an accidentally unfiltered inquiry. +- Packages Modern UI files as Acumatica `PerTenantFile` artifacts. +- Runs Acuminator and IDE code-style diagnostics as build gates. + +## Request flow + +```text +Generic Inquiry (SM208000) + | + | Side Panel Targets + parameter mappings + v +Configuration tables + | + | cached by screen ID + v +Target screen graph initialization + | + | dynamic hidden action + side-panel metadata + v +Current target record values + | + | mapped to GI parameters + v +Context-filtered Generic Inquiry side panel +``` + +## Example configuration + +For a project-related inquiry displayed from Projects (PM301000): + +| GI parameter | Source view | Source field | +| --- | --- | --- | +| `ProjectCD` | `Project` | `ContractCD` | + +The GI condition can then filter `PMProject.ContractCD` by `[ProjectCD]`. For a context-sensitive side panel, keep the parameter required and avoid an `OR [ProjectCD] Is Empty` fallback; otherwise a missing mapping could return data for every project. + +## How it works + +1. `GenericInquiryDesigner_Extension` adds target and parameter configuration views to the Generic Inquiry graph. +2. `GISidePanelTarget` stores the target screen, caption, icon, order, and active state. +3. `GISidePanelParameter` stores the mapping from a GI parameter to a source view and field. +4. `GISidePanelRuntime` loads active configuration through `PXDatabase.GetSlot` and registers the appropriate side-panel action for the current screen graph. +5. When invoked, the action reads the current source record, converts mapped values using the current culture, and redirects through `PXRedirectToGIRequiredException`. +6. The Modern UI extension adds the configuration grids to SM208000. + +## Project structure + +```text +GISidePanels/ +|-- AcuProjectSource/ +| |-- _project/ # Customization metadata and SQL table definitions +| `-- FrontendSources/ # SM208000 Modern UI extension +|-- Package/ +| `-- project.xml # Import package manifest +|-- Properties/ +| `-- AssemblyInfo.cs +|-- GenericInquiryDesigner_Extension.cs # GI configuration graph extension +|-- GISidePanelTarget.cs # Target-screen configuration DAC +|-- GISidePanelParameter.cs # Parameter-mapping DAC +|-- GISidePanelRuntime.cs # Runtime action registration and redirect logic +|-- GISidePanelMessages.cs # Localizable messages +|-- GISidePanels.csproj +`-- GISidePanels.sln +``` + +## Requirements + +- Acumatica ERP 2026 R1. +- .NET Framework 4.8 developer tooling. +- Access to the target Acumatica instance assemblies. +- Node.js tooling installed with the Acumatica instance when rebuilding Modern UI screen bundles. + +The project uses the overridable `AcumaticaBinPath` MSBuild property. Its default resolves to `C:\Acumatica ERP\Acu26R1\Bin` for the repository's current directory layout. If your instance is elsewhere, pass the path when building: + +```powershell +dotnet build GISidePanels.csproj -c Release -p:AcumaticaBinPath="D:\Acumatica ERP\Acu26R1\Bin" +``` + +## Build and analyzer validation + +From the repository root: + +```powershell +dotnet restore GISidePanels.csproj +dotnet build GISidePanels.csproj -c Release --no-incremental +dotnet format GISidePanels.csproj analyzers --verify-no-changes --severity info --no-restore +dotnet format GISidePanels.csproj style --verify-no-changes --severity info --no-restore +``` + +Expected result: zero compiler errors, compiler warnings, Acuminator diagnostics, and IDE code-style diagnostics. + +Framework-required camel-case BQL field classes use declaration-level `SuppressMessage` attributes with an `Acumatica Standard` justification. The project does not use blanket analyzer suppressions. + +## Creating an importable customization package + +The generated ZIP and build output are intentionally excluded from source control. Assemble the package according to `Package/project.xml` with this layout: + +```text +project.xml +Bin/ +`-- GISidePanels.dll +screens/ +`-- SM/ + `-- SM208000/ + `-- extensions/ + |-- SM208000_GISidePanels.html + `-- SM208000_GISidePanels.ts +``` + +The Modern UI files must remain `PerTenantFile` items at the `screens/...` paths shown above. Packaging them as ordinary files or under `FrontendSources/...` places them in the wrong customization-project section. + +## Configuration walkthrough + +1. Publish the customization to a development or test instance. +2. Open **Generic Inquiry** (SM208000) and select the inquiry that should appear in a side panel. +3. Define the inquiry's parameters on the standard **Parameters** tab. +4. Open **Side Panel Targets** and add the target screen, caption, icon, and order. +5. In the lower grid, map each **GI Parameter** to a **Source View** and **Source Field** from the target graph. +6. Save the inquiry. +7. Open or refresh the target screen and invoke the new side-panel action. + +Active target configuration is loaded through a table-dependent database slot on subsequent graph requests, so graph initialization does not execute BQL or direct database queries. Parameter mappings are read when the side-panel action is invoked. + +## Implementation notes + +- Only site-map entries backed by a concrete `PXGraph` can host a configured action. +- Only BQL-backed fields are offered for mapping, which avoids UI-only helper fields that cannot be read reliably from the current DAC record. +- Each active GI parameter can be mapped once per target screen. +- A source view must have a current record when the user invokes the action. +- Empty mapped values raise a clear exception rather than opening an unfiltered inquiry. +- Side-panel actions are registered server-side, so target screens are not coupled to a specific Classic or Modern UI implementation. + +## Portfolio focus + +This example demonstrates several Acumatica development patterns in one focused customization: + +- Graph extensions and event handlers. +- Custom DACs with primary and foreign key declarations. +- Fluent BQL and typed data access. +- Dynamic action registration across unrelated graphs. +- Slot-based configuration caching. +- Context-aware GI navigation. +- Modern UI TypeScript and HTML extensions. +- Customization-package assembly and validation. +- Acuminator-compliant code with narrowly scoped suppressions. + +## Disclaimer + +This is an independent developer example and is not an official Acumatica product. Acumatica is a trademark of Acumatica, Inc. + +Author: Kitt Parker