Skip to content

Commit

Permalink
Added two checked Always Primary, Addresses. Fixed #668
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Apr 15, 2022
1 parent be8eec5 commit 20fad5e
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 30 deletions.
4 changes: 3 additions & 1 deletion FetchXmlBuilder/AppCode/FXBSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ public class ShowMetaTypesAttribute : ShowMetaTypes
public CheckState IsRetrievable { get; set; } = CheckState.Indeterminate; //A
public CheckState IsValidForGrid { get; set; } = CheckState.Indeterminate; //A
public CheckState AttributeOf { get; set; } = CheckState.Unchecked; //A
public bool AlwaysPrimary { get; set; } = true;
public bool AlwaysAddresses { get; set; } = true;
}

public class ResultOptions
public class ResultOptions
{
public bool Friendly { get; set; }
public bool Id { get; set; }
Expand Down
10 changes: 10 additions & 0 deletions FetchXmlBuilder/FetchXmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,16 @@ internal AttributeMetadata[] GetDisplayAttributes(string entityName, ShowMetaTyp
var attributes = GetAllAttribues(entityName);
foreach (var attribute in attributes)
{
if (selectattributes.AlwaysPrimary && attribute.IsLogical != true && (attribute.IsPrimaryId == true || attribute.IsPrimaryName == true))
{
result.Add(attribute);
continue;
}
if (selectattributes.AlwaysAddresses && attribute.IsLogical == true && attribute.AttributeType != AttributeTypeCode.Virtual && attribute.LogicalName.StartsWith("address"))
{
result.Add(attribute);
continue;
}
if (!CheckMetadata(selectattributes.IsManaged, attribute.IsManaged)) { continue; }
if (!CheckMetadata(selectattributes.IsCustom, attribute.IsCustomAttribute)) { continue; }
if (!CheckMetadata(selectattributes.IsCustomizable, attribute.IsCustomizable)) { continue; }
Expand Down
109 changes: 81 additions & 28 deletions FetchXmlBuilder/Forms/ShowMetadataOptions.Designer.cs

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

19 changes: 18 additions & 1 deletion FetchXmlBuilder/Forms/ShowMetadataOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ private void PopulateAttributesSettings(ShowMetaTypesAttribute setting)
chkARead.CheckState = setting.IsValidForRead;
chkARetrievable.CheckState = setting.IsRetrievable;
chkAAttributeOf.CheckState = setting.AttributeOf;
chkAShowPrimary.Checked = setting.AlwaysPrimary;
chkAShowAddress.Checked = setting.AlwaysAddresses;
}

private ShowMetaTypesEntity GetEntitiesSettings()
Expand Down Expand Up @@ -94,7 +96,9 @@ private ShowMetaTypesAttribute GetAttributesSettings()
IsValidForGrid = chkAGrid.CheckState,
IsFiltered = chkAFiltered.CheckState,
IsRetrievable = chkARetrievable.CheckState,
AttributeOf = chkAAttributeOf.CheckState
AttributeOf = chkAAttributeOf.CheckState,
AlwaysPrimary=chkAShowPrimary.Checked,
AlwaysAddresses=chkAShowAddress.Checked
};
}

Expand Down Expand Up @@ -124,6 +128,14 @@ private void UpdateSelections(object sender = null, EventArgs e = null)
.OfType<CheckBox>()
.Where(c => c.CheckState != CheckState.Indeterminate)
.Select(c => c.Text).ToList();
if (chkAShowPrimary.Checked)
{
selattributes.Add("Always Primary");
}
if (chkAShowAddress.Checked)
{
selattributes.Add("Always Addresses");
}
lblAttributes.Text = string.Join(", ", selattributes.ToArray());
if (Width < 600)
{
Expand Down Expand Up @@ -178,5 +190,10 @@ private void Preview(bool preview)
Width = gbAttributes.Left + gbAttributes.Width + 30;
}
}

private void chkAShowAlways_CheckedChanged(object sender, EventArgs e)
{
UpdateSelections();
}
}
}

0 comments on commit 20fad5e

Please sign in to comment.