Skip to content

Commit

Permalink
Manual layout group container variant doesn't add layout properties (#…
Browse files Browse the repository at this point in the history
…190)

* Manual layout group contaner variant doesn't add layout properties

* PR feedback, comments
  • Loading branch information
lesaltzm authored Mar 19, 2021
1 parent 503a6f8 commit e4ae39a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/PAModel/ControlTemplates/DynamicProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ namespace Microsoft.PowerPlatform.Formulas.Tools.ControlTemplates
// Responsible for handling dynamic properties and their default vaues
internal static class DynamicProperties
{
internal static bool AddsChildDynamicProperties(string template)
// Group container controls add dynamic properties to their children
private const string GroupContainerTemplate = "groupContainer";

// ... Except for the manual layout variant. It uses the old x/y layout style
private const string ManualLayoutVariant = "manualLayoutContainer";

internal static bool AddsChildDynamicProperties(string template, string variant)
{
return template == "groupContainer";
return template == GroupContainerTemplate && variant != ManualLayoutVariant;
}


Expand Down
2 changes: 1 addition & 1 deletion src/PAModel/IR/IRStateHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private static (ControlInfoJson.Item item, int index) CombineIRAndState(BlockNod
var children = new List<(ControlInfoJson.Item item, int index)>();
foreach (var childBlock in blockNode.Children)
{
children.Add(CombineIRAndState(childBlock, errors, controlName, DynamicProperties.AddsChildDynamicProperties(templateName), stateStore, templateStore, uniqueIdRestorer, entropy));
children.Add(CombineIRAndState(childBlock, errors, controlName, DynamicProperties.AddsChildDynamicProperties(templateName, variantName), stateStore, templateStore, uniqueIdRestorer, entropy));
}

var orderedChildren = children.OrderBy(childPair => childPair.index).Select(pair => pair.item).ToArray();
Expand Down
6 changes: 4 additions & 2 deletions src/PAModel/SourceTransforms/SourceTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public SourceTransformer(ErrorContainer errors, Dictionary<string, ControlTempla
public void ApplyAfterRead(BlockNode control, bool inResponsiveContext = false)
{
var controlTemplateName = control.Name?.Kind?.TypeName ?? string.Empty;
var controlTemplateVariantName = control.Name?.Kind?.OptionalVariant ?? string.Empty;

var childResponsiveContext = DynamicProperties.AddsChildDynamicProperties(controlTemplateName);
var childResponsiveContext = DynamicProperties.AddsChildDynamicProperties(controlTemplateName, controlTemplateVariantName);
foreach (var child in control.Children)
{
ApplyAfterRead(child, childResponsiveContext);
Expand All @@ -59,7 +60,8 @@ public void ApplyAfterRead(BlockNode control, bool inResponsiveContext = false)
public void ApplyBeforeWrite(BlockNode control, bool inResponsiveContext = false)
{
var controlTemplateName = control.Name?.Kind?.TypeName ?? string.Empty;
var childResponsiveContext = DynamicProperties.AddsChildDynamicProperties(controlTemplateName);
var controlTemplateVariantName = control.Name?.Kind?.OptionalVariant ?? string.Empty;
var childResponsiveContext = DynamicProperties.AddsChildDynamicProperties(controlTemplateName, controlTemplateVariantName);

_groupControlTransform.BeforeWrite(control);
foreach (var transform in _templateTransforms.Reverse())
Expand Down

0 comments on commit e4ae39a

Please sign in to comment.