Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More StyleCop fixes #3843

Merged
merged 14 commits into from
Jun 17, 2020
  •  
  •  
  •  
160 changes: 80 additions & 80 deletions DNN Platform/Admin Modules/Dnn.Modules.Console/Settings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,82 +25,6 @@ public partial class Settings : ModuleSettingsBase
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(Settings));

private void BindTabs(int tabId, bool includeParent)
{
List<TabInfo> tempTabs = TabController.GetTabsBySortOrder(this.PortalId).OrderBy(t => t.Level).ThenBy(t => t.HasChildren).ToList();

IList<TabInfo> tabList = new List<TabInfo>();

IList<int> tabIdList = new List<int>();
tabIdList.Add(tabId);

if (includeParent)
{
TabInfo consoleTab = TabController.Instance.GetTab(tabId, this.PortalId);
if (consoleTab != null)
{
tabList.Add(consoleTab);
}
}

foreach (TabInfo tab in tempTabs)
{
bool canShowTab = TabPermissionController.CanViewPage(tab) &&
!tab.IsDeleted &&
(tab.StartDate < DateTime.Now || tab.StartDate == Null.NullDate);

if (!canShowTab)
{
continue;
}

if (tabIdList.Contains(tab.ParentId))
{
if (!tabIdList.Contains(tab.TabID))
{
tabIdList.Add(tab.TabID);
}

tabList.Add(tab);
}
}

this.tabs.DataSource = tabList;
this.tabs.DataBind();
}

private void SwitchMode()
{
int parentTabId = -1;
if (this.Settings.ContainsKey("ParentTabID") && !string.IsNullOrEmpty(Convert.ToString(this.Settings["ParentTabID"])))
{
parentTabId = Convert.ToInt32(this.Settings["ParentTabID"]);
}

switch (this.modeList.SelectedValue)
{
case "Normal":
this.parentTabRow.Visible = true;
this.includeParentRow.Visible = true;
this.tabVisibilityRow.Visible = false;
break;
case "Profile":
this.parentTabRow.Visible = false;
this.includeParentRow.Visible = false;
this.tabVisibilityRow.Visible = true;
parentTabId = this.PortalSettings.UserTabId;
break;
case "Group":
this.parentTabRow.Visible = true;
this.includeParentRow.Visible = true;
this.tabVisibilityRow.Visible = true;
break;
}

this.ParentTab.SelectedPage = TabController.Instance.GetTab(parentTabId, this.PortalId);
this.BindTabs(parentTabId, this.IncludeParent.Checked);
}

public override void LoadSettings()
{
try
Expand Down Expand Up @@ -232,6 +156,82 @@ public override void UpdateSettings()
}
}

private void BindTabs(int tabId, bool includeParent)
{
List<TabInfo> tempTabs = TabController.GetTabsBySortOrder(this.PortalId).OrderBy(t => t.Level).ThenBy(t => t.HasChildren).ToList();

IList<TabInfo> tabList = new List<TabInfo>();

IList<int> tabIdList = new List<int>();
tabIdList.Add(tabId);

if (includeParent)
{
TabInfo consoleTab = TabController.Instance.GetTab(tabId, this.PortalId);
if (consoleTab != null)
{
tabList.Add(consoleTab);
}
}

foreach (TabInfo tab in tempTabs)
{
bool canShowTab = TabPermissionController.CanViewPage(tab) &&
!tab.IsDeleted &&
(tab.StartDate < DateTime.Now || tab.StartDate == Null.NullDate);

if (!canShowTab)
{
continue;
}

if (tabIdList.Contains(tab.ParentId))
{
if (!tabIdList.Contains(tab.TabID))
{
tabIdList.Add(tab.TabID);
}

tabList.Add(tab);
}
}

this.tabs.DataSource = tabList;
this.tabs.DataBind();
}

private void SwitchMode()
{
int parentTabId = -1;
if (this.Settings.ContainsKey("ParentTabID") && !string.IsNullOrEmpty(Convert.ToString(this.Settings["ParentTabID"])))
{
parentTabId = Convert.ToInt32(this.Settings["ParentTabID"]);
}

switch (this.modeList.SelectedValue)
{
case "Normal":
this.parentTabRow.Visible = true;
this.includeParentRow.Visible = true;
this.tabVisibilityRow.Visible = false;
break;
case "Profile":
this.parentTabRow.Visible = false;
this.includeParentRow.Visible = false;
this.tabVisibilityRow.Visible = true;
parentTabId = this.PortalSettings.UserTabId;
break;
case "Group":
this.parentTabRow.Visible = true;
this.includeParentRow.Visible = true;
this.tabVisibilityRow.Visible = true;
break;
}

this.ParentTab.SelectedPage = TabController.Instance.GetTab(parentTabId, this.PortalId);
this.BindTabs(parentTabId, this.IncludeParent.Checked);
}

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Expand All @@ -242,14 +242,14 @@ protected override void OnInit(EventArgs e)
this.ParentTab.UndefinedItem = new ListItem(DynamicSharedConstants.Unspecified, string.Empty);
}

private void modeList_SelectedIndexChanged(object sender, EventArgs e)
protected void parentTab_SelectedIndexChanged(object sender, EventArgs e)
{
this.SwitchMode();
this.BindTabs(this.ParentTab.SelectedItemValueAsInt, this.IncludeParent.Checked);
}

protected void parentTab_SelectedIndexChanged(object sender, EventArgs e)
private void modeList_SelectedIndexChanged(object sender, EventArgs e)
{
this.BindTabs(this.ParentTab.SelectedItemValueAsInt, this.IncludeParent.Checked);
this.SwitchMode();
}

private void tabs_ItemDataBound(object Sender, RepeaterItemEventArgs e)
Expand Down
Loading