From 2e7c3167f5fdba65c6c923b091e0c84d75215d0a Mon Sep 17 00:00:00 2001 From: sbwalker Date: Mon, 29 Apr 2024 14:58:30 -0400 Subject: [PATCH] refactor #4198 - copy existing module --- .../Controls/ControlPanelInteractive.resx | 19 +--------- .../Theme/ControlPanelInteractive.razor | 37 ++++++++----------- .../HtmlText/Manager/HtmlTextManager.cs | 8 ++-- 3 files changed, 22 insertions(+), 42 deletions(-) diff --git a/Oqtane.Client/Resources/Themes/Controls/ControlPanelInteractive.resx b/Oqtane.Client/Resources/Themes/Controls/ControlPanelInteractive.resx index 6a8302d75..15c567fc1 100644 --- a/Oqtane.Client/Resources/Themes/Controls/ControlPanelInteractive.resx +++ b/Oqtane.Client/Resources/Themes/Controls/ControlPanelInteractive.resx @@ -154,7 +154,7 @@ Not Authorized - You Must Select A Module. + You Must Select A Module Module Management: @@ -162,15 +162,6 @@ Select Module - - Select Copy Mode - - - Sync - - - Copy - Page Management: @@ -207,13 +198,7 @@ Top - - You Must Select A Module And The Copy Mode. - - - The Module's Content Will Not Be Synchronized. - Copy Existing Module - + \ No newline at end of file diff --git a/Oqtane.Client/Themes/Controls/Theme/ControlPanelInteractive.razor b/Oqtane.Client/Themes/Controls/Theme/ControlPanelInteractive.razor index d33b1d21e..aa281da26 100644 --- a/Oqtane.Client/Themes/Controls/Theme/ControlPanelInteractive.razor +++ b/Oqtane.Client/Themes/Controls/Theme/ControlPanelInteractive.razor @@ -94,12 +94,12 @@
- @if (PageState.Page.UserId == null) { - - + + } @if (_moduleType == "new") @@ -143,21 +143,20 @@ } else { - @foreach (Page p in _pages) { } - @foreach (Module module in _modules) { } - @((MarkupString)_copyModuleMessage) }
@@ -270,7 +269,6 @@ protected int _location { get; private set; } = int.MaxValue; protected string _visibility { get; private set; } = "view"; protected string _message { get; private set; } = ""; - protected string _copyModuleMessage { get; private set; } = ""; private string settingCategory = "CP-category"; private string settingPane = "CP-pane"; @@ -341,6 +339,13 @@ StateHasChanged(); } + private void ModuleTypeChanged(ChangeEventArgs e) + { + _moduleType = (string)e.Value; + _pageId = "-"; + _moduleId = "-"; + } + private void PageChanged(ChangeEventArgs e) { _pageId = (string)e.Value; @@ -348,26 +353,14 @@ { _modules = PageState.Modules .Where(module => module.PageId == int.Parse(_pageId) && - UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList)) + UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, module.PermissionList) && + (_moduleType == "add" || module.ModuleDefinition.IsPortable)) .ToList(); } _moduleId = "-"; StateHasChanged(); } - private void ModuleIdChanged() - { - _copyModuleMessage = string.Empty; - if(_moduleId != "-") - { - var module = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(_moduleId)); - if (module != null && !module.ModuleDefinition.IsPortable) - { - _copyModuleMessage = $"
{Localizer["Message.Module.NotPortable"]}
"; - } - } - } - private async Task AddModule() { if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList)) @@ -387,7 +380,7 @@ module = await ModuleService.AddModuleAsync(module); newModuleId = module.ModuleId; } - else if (_moduleType == "exsiting.copy") + else if (_moduleType == "copy") { var module = await ModuleService.GetModuleAsync(int.Parse(_moduleId)); module.ModuleId = 0; diff --git a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs index 959f4d071..6c9293fb3 100644 --- a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs +++ b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs @@ -7,6 +7,7 @@ using Oqtane.Shared; using Oqtane.Migrations.Framework; using Oqtane.Documentation; +using System.Linq; // ReSharper disable ConvertToUsingDeclaration @@ -29,10 +30,11 @@ public HtmlTextManager(IHtmlTextRepository htmlText, IDBContextDependencies DBCo public string ExportModule(Module module) { string content = ""; - var htmlText = _htmlText.GetHtmlText(module.ModuleId); - if (htmlText != null) + var htmltexts = _htmlText.GetHtmlTexts(module.ModuleId); + if (htmltexts != null && htmltexts.Any()) { - content = WebUtility.HtmlEncode(htmlText.Content); + var htmltext = htmltexts.OrderByDescending(item => item.CreatedOn).First(); + content = WebUtility.HtmlEncode(htmltext.Content); } return content; }