Skip to content

Commit

Permalink
Add preview Smart result
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Aug 29, 2021
1 parent fdaf249 commit 2d1a84e
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 40 deletions.
54 changes: 41 additions & 13 deletions XRMTokensRun/GetAttribute.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 24 additions & 11 deletions XRMTokensRun/GetAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@ public static string ShowDialog(XRMTR owner, EntityMetadata entity = null, IEnum
dialog.xrmColumn.DataSource = attributes ?? entity.Attributes.Where(a => a.IsLogical == false);
if (dialog.ShowDialog((Control)owner) == DialogResult.OK)
{
var result = "{" + dialog.xrmColumn.SelectedAttribute.LogicalName;
if (dialog.chkParent.Checked)
{
result += "." + dialog.xrmParentAttr.SelectedAttribute.LogicalName;
}
if (dialog.chkValue.Checked)
{
result += "|<value>";
}
result += "}";
return result;
return dialog.GetResult();
}
return null;
}

private string GetResult()
{
var result = "{" + xrmColumn.SelectedAttribute.LogicalName;
if (chkParent.Checked)
{
result += "." + xrmParentAttr.SelectedAttribute.LogicalName;
}
if (chkValue.Checked)
{
result += "|<value>";
}
result += "}";
return result;
}

private void xrmColumn_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (xrmColumn.SelectedAttribute is LookupAttributeMetadata look)
Expand All @@ -58,6 +63,7 @@ private void xrmColumn_SelectedIndexChanged(object sender, System.EventArgs e)
chkParent.Checked = false;
xrmParentEntity.DataSource = null;
}
ShowResult();
}

private void xrmParentEntity_SelectedIndexChanged(object sender, System.EventArgs e)
Expand All @@ -79,6 +85,7 @@ private void xrmParentEntity_SelectedIndexChanged(object sender, System.EventArg
{
xrmParentAttr.DataSource = null;
}
ShowResult();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
Expand All @@ -102,6 +109,12 @@ private void chkParent_CheckedChanged(object sender, System.EventArgs e)
xrmParentEntity.SelectedItem = null;
xrmParentAttr.SelectedItem = null;
}
ShowResult();
}

private void ShowResult(object sender = null, System.EventArgs e = null)
{
txtResult.Text = GetResult();
}
}
}
41 changes: 38 additions & 3 deletions XRMTokensRun/GetChildEntityAttribute.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions XRMTokensRun/GetChildEntityAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ public static string ShowDialog(XRMTR owner, EntityMetadata entity = null, IEnum
dialog.xrmEntityComboBox1.DataSource = owner.entities.Where(e => ents.Contains(e.LogicalName));
if (dialog.ShowDialog((Control)owner) == DialogResult.OK)
{
return "<expand|" +
dialog.xrmEntityComboBox1.SelectedEntity?.LogicalName + "|" +
dialog.xrmLookup.SelectedAttribute?.LogicalName + "|" +
"{" + dialog.xrmShow.SelectedAttribute?.LogicalName + "}|" +
dialog.xrmOrder.SelectedAttribute?.LogicalName + "/asc|" +
dialog.txtSeparate.Text + "|" +
(dialog.chkDistinct.Checked ? "true" : "false") + "|" +
(dialog.chkActive.Checked ? "true" : "false") + "|" +
dialog.mskMax.Text + ">";
return dialog.GetResult();
}
return null;
}

private string GetResult()
{
return "<expand|" +
xrmEntityComboBox1.SelectedEntity?.LogicalName + "|" +
xrmLookup.SelectedAttribute?.LogicalName + "|" +
"{" + xrmShow.SelectedAttribute?.LogicalName + "}|" +
xrmOrder.SelectedAttribute?.LogicalName + "/asc|" +
txtSeparate.Text + "|" +
(chkDistinct.Checked ? "true" : "false") + "|" +
(chkActive.Checked ? "true" : "false") + "|" +
mskMax.Text + ">";
}

private void xrmEntityComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (xrmEntityComboBox1.SelectedEntity is EntityMetadata select)
Expand All @@ -61,11 +66,17 @@ private void xrmEntityComboBox1_SelectedIndexChanged(object sender, System.Event
xrmShow.DataSource = null;
xrmOrder.DataSource = null;
}
ShowResult();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://jonasr.app/xrm-tokens/#expand");
}

private void ShowResult(object sender = null, System.EventArgs e = null)
{
txtResult.Text = GetResult();
}
}
}
Loading

0 comments on commit 2d1a84e

Please sign in to comment.