Skip to content

Commit

Permalink
Fixed #685, #693, and a bit layout of Settings form
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Apr 13, 2022
1 parent d587996 commit ab7962c
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 118 deletions.
2 changes: 2 additions & 0 deletions FetchXmlBuilder/AppCode/FXBSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class QueryOptions
public bool ShowQuickActions { get; set; } = true;
public bool UseSingleQuotation { get; set; }
public string NewQueryTemplate { get; set; } = DefaultNewQuery;
public bool ShowAllAttributes { get; set; } = false;
}

public abstract class ShowMetaTypes
Expand Down Expand Up @@ -108,6 +109,7 @@ public class ResultOptions
public bool RetrieveAllPages { get; set; } = false;
public bool AlwaysNewWindow { get; set; } = false;
public bool QuickFilter { get; set; } = false;
public bool ClickableLinks { get; set; } = true;
}

public class DockStates
Expand Down
6 changes: 5 additions & 1 deletion FetchXmlBuilder/AppCode/TreeNodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ internal static void SetNodeTooltip(TreeNode node)
/// <summary>Adds a context menu to a TreeNode control</summary>
/// <param name="node">TreeNode where to add the context menu</param>
/// <param name="tree">Current application form</param>
public static void AddContextMenu(TreeNode node, TreeBuilderControl tree)
public static void AddContextMenu(TreeNode node, TreeBuilderControl tree, QueryOptions options)
{
tree.addMenu.Items.Clear();
var tmplbl = tree.lblQAExpander;
Expand All @@ -372,6 +372,10 @@ public static void AddContextMenu(TreeNode node, TreeBuilderControl tree)
}
foreach (var childcapability in nodecapabilities.ChildTypes)
{
if (childcapability.Name == "all-attributes" && !options.ShowAllAttributes)
{
continue;
}
if (childcapability.Name == "-")
{
tree.addMenu.Items.Add(new ToolStripSeparator());
Expand Down
4 changes: 4 additions & 0 deletions FetchXmlBuilder/DockControls/ResultGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ private void RefreshData()

private void crmGridView1_RecordDoubleClick(object sender, Rappen.XTB.Helpers.Controls.XRMRecordEventArgs e)
{
if (!form.settings.Results.ClickableLinks)
{
return;
}
if (e.Value is EntityReference entref && form.ConnectionDetail.GetEntityReferenceUrl(entref) is string urlref && !string.IsNullOrEmpty(urlref))
{
form.LogUse("OpenParentRecord");
Expand Down
2 changes: 1 addition & 1 deletion FetchXmlBuilder/DockControls/TreeBuilderControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private void HandleNodeSelection(TreeNode node)
Control existingControl = panelContainer.Controls.Count > 0 ? panelContainer.Controls[0] : null;
if (node != null)
{
TreeNodeHelper.AddContextMenu(node, this);
TreeNodeHelper.AddContextMenu(node, this, fxb.settings.QueryOptions);
this.deleteToolStripMenuItem.Text = "Delete " + node.Name;
var collec = (Dictionary<string, string>)node.Tag;

Expand Down
2 changes: 1 addition & 1 deletion FetchXmlBuilder/FetchXmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ private void FetchXmlBuilder_Load(object sender, EventArgs e)
SetupDockControls();
ApplySettings(true);
RebuildRepositoryMenu(null);
TreeNodeHelper.AddContextMenu(null, dockControlBuilder);
TreeNodeHelper.AddContextMenu(null, dockControlBuilder, settings.QueryOptions);
EnableControls(true);
}

Expand Down
189 changes: 83 additions & 106 deletions FetchXmlBuilder/Forms/Settings.Designer.cs

Large diffs are not rendered by default.

39 changes: 30 additions & 9 deletions FetchXmlBuilder/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,27 @@ private void PopulateSettings(FXBSettings settings)
chkShowValidation.Checked = settings.ShowValidation;
chkShowValidationInfo.Checked = settings.ShowValidationInfo;
chkShowRepository.Checked = settings.ShowRepository;
switch (settings.Results.ResultOutput)
{
case ResultOutput.XML: rbResSerializedXML.Checked = true; break;
case ResultOutput.JSON: rbResSerializedJSON.Checked = true; break;
case ResultOutput.JSONWebAPI: rbResSerializedJSONWebAPI.Checked = true; break;
case ResultOutput.Raw: rbResRaw.Checked = true; break;
default: rbResGrid.Checked = true; break;
}
chkShowAllAttributes.Checked = settings.QueryOptions.ShowAllAttributes;
cmbResult.SelectedIndex = SettingResultToComboBoxItem(settings.Results.ResultOutput);
chkResAllPages.Checked = settings.Results.RetrieveAllPages;
chkClickableLinks.Checked = settings.Results.ClickableLinks;
propXmlColors.SelectedObject = settings.XmlColors;
txtFetch.ConfigureForXml(settings);
txtFetch.FormatXML(settings.QueryOptions.NewQueryTemplate, settings);
}

private int SettingResultToComboBoxItem(ResultOutput resultOutput)
{
switch (resultOutput)
{
case ResultOutput.XML: return 1;
case ResultOutput.JSON: return 2;
case ResultOutput.JSONWebAPI: return 3;
case ResultOutput.Raw: return 4;
default: return 0;
}
}

internal FXBSettings GetSettings()
{
var settings = fxb.settings;
Expand All @@ -58,8 +65,9 @@ internal FXBSettings GetSettings()
settings.QueryOptions.NewQueryTemplate = txtFetch.Text;
settings.DoNotPromptToSave = chkAppNoSavePrompt.Checked;
settings.Results.AlwaysNewWindow = chkAppResultsNewWindow.Checked;
settings.Results.ResultOutput = rbResSerializedXML.Checked ? ResultOutput.XML : rbResSerializedJSON.Checked ? ResultOutput.JSON : rbResRaw.Checked ? ResultOutput.Raw : rbResSerializedJSONWebAPI.Checked ? ResultOutput.JSONWebAPI : ResultOutput.Grid;
settings.Results.ResultOutput = ResultItemToSettingResult(cmbResult.SelectedIndex);
settings.Results.RetrieveAllPages = chkResAllPages.Checked;
settings.Results.ClickableLinks = chkClickableLinks.Checked;
settings.OpenUncustomizableViews = chkAppAllowUncustViews.Checked;
settings.AddConditionToFilter = chkAddConditionToFilter.Checked;
settings.UseSQL4CDS = chkUseSQL4CDS.Checked;
Expand All @@ -70,10 +78,23 @@ internal FXBSettings GetSettings()
settings.ShowValidation = chkShowValidation.Checked;
settings.ShowValidationInfo = settings.ShowValidation && chkShowValidationInfo.Checked;
settings.ShowRepository = chkShowRepository.Checked;
settings.QueryOptions.ShowAllAttributes = chkShowAllAttributes.Checked;
settings.XmlColors = propXmlColors.SelectedObject as XmlColors;
return settings;
}

private ResultOutput ResultItemToSettingResult(int selectedIndex)
{
switch (selectedIndex)
{
case 1: return ResultOutput.XML;
case 2: return ResultOutput.JSON;
case 3: return ResultOutput.JSONWebAPI;
case 4: return ResultOutput.Raw;
default: return ResultOutput.Grid;
}
}

private void llShowWelcome_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
fxb.LogUse("ShowWelcome-Manual");
Expand Down

0 comments on commit ab7962c

Please sign in to comment.