Refactoring (#314)

* Refactoring

* Refactoring

* Check for a valid email.

* Fixed missing character.

* Moved logic to  the Utilities class.

* Rename template .sql file

* Modified null and empty string check.

* Check for a valid email.

* Fixed missing character.

* Moved logic to  the Utilities class.

* Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options

* Refactoring

* Refactoring

* Check for a valid email.

* Moved logic to  the Utilities class.

Co-authored-by: Aubrey <aubrey.b@treskcow.tech>
Co-authored-by: MIchael Atwood <matwood@dragonmastery.com>
Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
This commit is contained in:
Hisham Bin Ateya
2020-03-31 17:21:05 +03:00
committed by GitHub
parent c9baa2bb56
commit 66ad089088
82 changed files with 958 additions and 829 deletions

View File

@ -196,6 +196,22 @@
}
@code {
private bool _deleteConfirmation = false;
private string _moduleType = "new";
private List<string> _categories = new List<string>();
private List<ModuleDefinition> _allModuleDefinitions;
private List<ModuleDefinition> _moduleDefinitions;
private List<Page> _pages = new List<Page>();
private string _pageId = "-";
private string _moduleId = "-";
private List<Module> _modules = new List<Module>();
private Dictionary<string, string> _containers = new Dictionary<string, string>();
private string _moduleDefinitionName = "-";
private string _pane = "";
private string _title = "";
private string _containerType = "";
private string _display = "display: none;";
private string _message = "";
[Parameter]
public string ButtonClass { get; set; }
@ -209,37 +225,23 @@
[Parameter]
public string BodyClass { get; set; }
bool _deleteConfirmation = false;
string _moduleType = "new";
List<string> _categories = new List<string>();
List<ModuleDefinition> _allModuleDefinitions;
List<ModuleDefinition> _moduleDefinitions;
List<Page> _pages = new List<Page>();
string _pageId = "-";
string _moduleId = "-";
List<Module> _modules = new List<Module>();
Dictionary<string, string> _containers = new Dictionary<string, string>();
string _moduleDefinitionName = "-";
string _pane = "";
string _title = "";
string _containerType = "";
string _display = "display: none;";
string _message = "";
protected override async Task OnParametersSetAsync()
{
if (string.IsNullOrEmpty(ButtonClass))
{
ButtonClass = "btn-outline-primary";
}
if (string.IsNullOrEmpty(CardClass))
{
CardClass = "card bg-secondary mb-3";
}
if (string.IsNullOrEmpty(HeaderClass))
{
HeaderClass = "card-header text-white";
}
if (string.IsNullOrEmpty(BodyClass))
{
BodyClass = "card-body";
@ -250,6 +252,7 @@
_pages?.Clear();
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
foreach (ModuleDefinition moduledefinition in _allModuleDefinitions)
{
if (moduledefinition.Categories != "")
@ -263,7 +266,9 @@
}
}
}
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
foreach (Page p in PageState.Pages)
{
if (UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, p.Permissions))
@ -271,9 +276,10 @@
_pages.Add(p);
}
}
var panes = PageState.Page.Panes.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries);
_pane = panes.Count() == 1 ? panes.SingleOrDefault() : "";
List<Theme> themes = await ThemeService.GetThemesAsync();
var themes = await ThemeService.GetThemesAsync();
_containers = ThemeService.GetContainerTypes(themes);
_containerType = PageState.Site.DefaultContainerType;
}
@ -281,7 +287,7 @@
private void CategoryChanged(ChangeEventArgs e)
{
string category = (string) e.Value;
var category = (string) e.Value;
if (category == "-")
{
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
@ -290,6 +296,7 @@
{
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(category)).ToList();
}
_moduleDefinitionName = "-";
StateHasChanged();
}
@ -298,6 +305,7 @@
{
_pageId = (string) e.Value;
_modules?.Clear();
if (_pageId != "-")
{
foreach (Module module in PageState.Modules.Where(item => item.PageId == int.Parse(_pageId) && !item.IsDeleted))
@ -308,6 +316,7 @@
}
}
}
_moduleId = "-";
StateHasChanged();
}
@ -346,6 +355,7 @@
pageModule.Title = _modules.FirstOrDefault(item => item.ModuleId == int.Parse(_moduleId))?.Title;
}
}
pageModule.Pane = _pane;
pageModule.Order = int.MaxValue;
pageModule.ContainerType = _containerType;
@ -426,18 +436,21 @@
switch (location)
{
case "Admin":
// get admin dashboard moduleid
// get admin dashboard moduleid
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule);
if (module != null)
{
NavigationManager.NavigateTo(EditUrl(PageState.Page.Path, module.ModuleId, "Index", ""));
}
break;
case "Add":
case "Edit":
string url = "";
// get page management moduleid
// get page management moduleid
module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.PageManagementModule);
if (module != null)
{
switch (location)
@ -450,10 +463,12 @@
break;
}
}
if (url != "")
{
NavigationManager.NavigateTo(url);
}
break;
}
}
@ -467,7 +482,8 @@
private async Task DeletePage()
{
ConfirmDelete();
Page page = PageState.Page;
var page = PageState.Page;
try
{
if (page.UserId == null)