Merge pull request #4874 from oqtane/revert-4871-HTMLTabError
Revert "Rework for Tabstrip regression issue"
This commit is contained in:
commit
1ed4c8a094
|
@ -242,6 +242,7 @@
|
|||
|
||||
private async Task SaveModule()
|
||||
{
|
||||
|
||||
validated = true;
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
|
|
|
@ -469,7 +469,6 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
||||
}
|
||||
|
||||
|
@ -477,13 +476,11 @@
|
|||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Saving Page {Page} {Error}", page, ex.Message);
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,7 +523,7 @@
|
|||
|
||||
private async Task SavePage()
|
||||
{
|
||||
//_activetab = "Settings";
|
||||
_activetab = "Settings";
|
||||
validated = true;
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
|
@ -672,20 +672,17 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(Localizer["Message.Required.PageInfo"], MessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Saving Page {Page} {Error}", _page, ex.Message);
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(Localizer["Error.Page.Save"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_activetab = "Settings";
|
||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
@inject IStringLocalizer<SharedResources> SharedLocalizer
|
||||
|
||||
<div class="quill-text-editor">
|
||||
<TabStrip ActiveTab="@_activetab" TabChangeEvent=false>
|
||||
<TabStrip ActiveTab="@_activetab">
|
||||
@if (_allowRichText)
|
||||
{
|
||||
<TabPanel Name="Rich" Heading="Rich Text Editor" ResourceKey="RichTextEditor">
|
||||
|
@ -254,11 +254,11 @@
|
|||
protected override void OnInitialized()
|
||||
{
|
||||
_interop = new QuillEditorInterop(JSRuntime);
|
||||
|
||||
if (string.IsNullOrEmpty(Placeholder))
|
||||
{
|
||||
Placeholder = Localizer["Placeholder"];
|
||||
}
|
||||
// _activetab = "Rich";
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
|
@ -269,10 +269,6 @@
|
|||
{
|
||||
_activetab = "Raw";
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// _activetab = "Rich";
|
||||
// }
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
|
|
|
@ -30,20 +30,15 @@ else
|
|||
[Parameter]
|
||||
public SecurityAccessLevel? Security { get; set; } // optional - can be used to specify SecurityAccessLevel
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
Parent.AddTabPanel((TabPanel)this);
|
||||
|
||||
if (string.IsNullOrEmpty(Heading))
|
||||
{
|
||||
Heading = Localize(nameof(Name), Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Heading = Localize(nameof(Heading), Heading);
|
||||
}
|
||||
Heading = string.IsNullOrEmpty(Heading) ? Localize(nameof(Name), Name) : Localize(nameof(Heading), Heading);
|
||||
}
|
||||
|
||||
public string DisplayHeading()
|
||||
|
|
|
@ -8,18 +8,9 @@
|
|||
@foreach (TabPanel tabPanel in _tabPanels)
|
||||
{
|
||||
<li class="nav-item" @key="tabPanel.Name">
|
||||
@if (tabPanel.Name.ToLower() == ActiveTab.ToLower())
|
||||
{
|
||||
<a class="nav-link active" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick="() => { if (TabChangeEvent) ChangeTab(tabPanel.Name); }">
|
||||
@tabPanel.DisplayHeading()
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="nav-link" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick="() => { if (TabChangeEvent) ChangeTab(tabPanel.Name); }">
|
||||
@tabPanel.DisplayHeading()
|
||||
</a>
|
||||
}
|
||||
<a class="nav-link @(tabPanel.IsActive ? "active" : "")" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick:preventDefault="true" @onclick="() => SetActiveTab(tabPanel.Name)">
|
||||
@tabPanel.DisplayHeading()
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
@ -32,47 +23,70 @@
|
|||
</CascadingValue>
|
||||
|
||||
@code {
|
||||
private List<TabPanel> _tabPanels;
|
||||
private string _tabpanelid = string.Empty;
|
||||
private List<TabPanel> _tabPanels;
|
||||
private string _tabpanelid = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } // contains the TabPanels
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } // contains the TabPanels
|
||||
|
||||
[Parameter]
|
||||
public bool TabChangeEvent { get; set; } = true;
|
||||
[Parameter]
|
||||
public string ActiveTab { get; set; } // optional - defaults to first TabPanel if not specified. Can also be set using a "tab=" querystring parameter.
|
||||
|
||||
[Parameter]
|
||||
public string ActiveTab { get; set; } // optional - defaults to first TabPanel if not specified. Can also be set using a "tab=" querystring parameter.
|
||||
[Parameter]
|
||||
public bool Refresh { get; set; } // optional - used in scenarios where TabPanels are added/removed dynamically within a parent form. ActiveTab may need to be reset as well when this property is used.
|
||||
|
||||
[Parameter]
|
||||
public bool Refresh { get; set; } // optional - used in scenarios where TabPanels are added/removed dynamically within a parent form. ActiveTab may need to be reset as well when this property is used.
|
||||
|
||||
[Parameter]
|
||||
public string Id { get; set; } // optional - used to uniquely identify an instance of a tab strip component (will be set automatically if no value provided)
|
||||
[Parameter]
|
||||
public string Id { get; set; } // optional - used to uniquely identify an instance of a tab strip component (will be set automatically if no value provided)
|
||||
|
||||
[Parameter]
|
||||
public string TabContentClass { get; set; } // optional - to extend the TabContent div.
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Id))
|
||||
{
|
||||
// create unique id for component
|
||||
Id = "TabStrip_" + Guid.NewGuid().ToString("N") + "_";
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Id))
|
||||
{
|
||||
// create unique id for component
|
||||
Id = "TabStrip_" + Guid.NewGuid().ToString("N") + "_" ;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
if (PageState.QueryString.ContainsKey("tab"))
|
||||
{
|
||||
ActiveTab = PageState.QueryString["tab"];
|
||||
}
|
||||
|
||||
if (_tabPanels == null || Refresh)
|
||||
{
|
||||
_tabPanels = new List<TabPanel>();
|
||||
}
|
||||
StateHasChanged();
|
||||
|
||||
// Ensure the active tab is valid and exists
|
||||
if (!string.IsNullOrEmpty(ActiveTab) && _tabPanels.Any())
|
||||
{
|
||||
var activeTabExists = _tabPanels.Any(tp => tp.Name.Equals(ActiveTab, StringComparison.OrdinalIgnoreCase));
|
||||
if (!activeTabExists)
|
||||
{
|
||||
ActiveTab = _tabPanels[0].Name;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the active tab in the UI
|
||||
UpdateActiveTab();
|
||||
}
|
||||
|
||||
private void UpdateActiveTab()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ActiveTab) && _tabPanels != null)
|
||||
{
|
||||
foreach (var tabPanel in _tabPanels)
|
||||
{
|
||||
tabPanel.IsActive = tabPanel.Name.Equals(ActiveTab, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddTabPanel(TabPanel tabPanel)
|
||||
|
@ -80,12 +94,20 @@
|
|||
if (!_tabPanels.Exists(item => item.Name == tabPanel.Name) && IsAuthorized(tabPanel))
|
||||
{
|
||||
_tabPanels.Add(tabPanel);
|
||||
if (string.IsNullOrEmpty(ActiveTab))
|
||||
{
|
||||
ActiveTab = tabPanel.Name;
|
||||
}
|
||||
UpdateActiveTab();
|
||||
StateHasChanged();
|
||||
}
|
||||
if (string.IsNullOrEmpty(ActiveTab))
|
||||
{
|
||||
ActiveTab = tabPanel.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveTab(string tabName)
|
||||
{
|
||||
ActiveTab = tabName;
|
||||
UpdateActiveTab();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private bool IsAuthorized(TabPanel tabPanel)
|
||||
|
@ -114,13 +136,4 @@
|
|||
}
|
||||
return authorized;
|
||||
}
|
||||
|
||||
private void ChangeTab(string tabName)
|
||||
{
|
||||
if (ActiveTab != tabName)
|
||||
{
|
||||
ActiveTab = tabName;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user