Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public CanvasControlCollection Controls
/// </summary>
public bool ShowDividerLine { get; set; }

/// <summary>
/// Defines Heading Level for collapsible Canvas Section Title of a Client-side Page.
/// </summary>
public int HeadingLevel { get; set; }
#endregion

#region Constructors
Expand All @@ -93,7 +97,7 @@ public CanvasSection()
/// <returns>Returns HashCode</returns>
public override int GetHashCode()
{
return (String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|",
return (String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|",
this.Controls.Aggregate(0, (acc, next) => acc += (next != null ? next.GetHashCode() : 0)),
Order.GetHashCode(),
Type.GetHashCode(),
Expand All @@ -103,7 +107,8 @@ public override int GetHashCode()
(this.DisplayName != null ? this.DisplayName.GetHashCode() : 0),
this.IsExpanded.GetHashCode(),
this.IconAlignment.GetHashCode(),
this.ShowDividerLine.GetHashCode()
this.ShowDividerLine.GetHashCode(),
this.HeadingLevel.GetHashCode()
).GetHashCode());
}

Expand Down Expand Up @@ -142,7 +147,8 @@ public bool Equals(CanvasSection other)
this.DisplayName == other.DisplayName &&
this.IsExpanded == other.IsExpanded &&
this.IconAlignment == other.IconAlignment &&
this.ShowDividerLine == other.ShowDividerLine
this.ShowDividerLine == other.ShowDividerLine &&
this.HeadingLevel == other.HeadingLevel
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ private void CreatePage(Web web, ProvisioningTemplate template, TokenParser pars
typeof(PnP.Core.Model.SharePoint.IconAlignment),
section.IconAlignment.ToString());
targetSection.ShowDividerLine = section.ShowDividerLine;
//XML-Schema does not support HeadingLevel-Value, so we need to get it from JsonControlData if not set through code manually
if (section.HeadingLevel == 0)
{
SetSectionHeadingLevel(section);
}
if( section.HeadingLevel > 0)
targetSection.HeadingLevel = section.HeadingLevel;
}

// Add controls to the section
Expand Down Expand Up @@ -1105,6 +1112,20 @@ private static void SetZoneReflowStrategy(PnPCore.ICanvasColumn canvasColumn, JO
}
}

private static void SetSectionHeadingLevel(CanvasSection section)
{
var control = section.Controls.FirstOrDefault(p => !string.IsNullOrWhiteSpace(p.JsonControlData) && p.JsonControlData.ToLower().Contains("headinglevel"));
if (control != null)
{
var json = JsonConvert.DeserializeObject<JObject>(control.JsonControlData);
var headingLevel = json.SelectToken("zoneGroupMetadata.headingLevel")?.Value<int>();
if (headingLevel.HasValue)
{
section.HeadingLevel = headingLevel.Value;
}
}
}

private static string DeterminePageName(TokenParser parser, BaseClientSidePage clientSidePage)
{
string pageName;
Expand Down
Loading