Add Edit Mode for Administration
This commit is contained in:
parent
1e4c07889b
commit
e1cc1ce973
@ -11,7 +11,7 @@
|
||||
|
||||
<ModuleMessage Message="@message" />
|
||||
|
||||
@if (profiles != null)
|
||||
@if (PageState.User != null && profiles != null)
|
||||
{
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
@ -55,6 +55,7 @@
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="@SaveUser">Save</button>
|
||||
<button type="button" class="btn btn-secondary" @onclick="@Cancel">Cancel</button>
|
||||
<br /><br />
|
||||
}
|
||||
|
||||
@code {
|
||||
@ -70,12 +71,19 @@
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (PageState.User != null)
|
||||
{
|
||||
displayname = PageState.User.DisplayName;
|
||||
email = PageState.User.Email;
|
||||
profiles = await ProfileService.GetProfilesAsync(ModuleState.SiteId);
|
||||
settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Current User Is Not Logged In";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
@ -88,6 +96,8 @@
|
||||
}
|
||||
|
||||
private async Task SaveUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = PageState.User;
|
||||
user.DisplayName = displayname;
|
||||
@ -102,10 +112,15 @@
|
||||
|
||||
UriHelper.NavigateTo("");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
UriHelper.NavigateTo(NavigateUrl("")); // navigate to home
|
||||
UriHelper.NavigateTo(NavigateUrl(""));
|
||||
}
|
||||
|
||||
private void ProfileChanged(UIChangeEventArgs e, string SettingName)
|
||||
|
@ -34,7 +34,7 @@
|
||||
string style = "";
|
||||
bool authorized = false;
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
text = Action;
|
||||
if (!String.IsNullOrEmpty(Text))
|
||||
@ -59,6 +59,8 @@
|
||||
|
||||
url = EditUrl(Action, parameters);
|
||||
|
||||
if (PageState.EditMode)
|
||||
{
|
||||
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameClass(ModuleState.ModuleType) + ",", Action + ",");
|
||||
Type moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
@ -85,4 +87,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
|
@ -19,6 +19,7 @@ namespace Oqtane.Shared
|
||||
public Dictionary<string, string> QueryString { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
public string Control { get; set; }
|
||||
public bool EditMode { get; set; }
|
||||
public int Reload { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,9 @@
|
||||
string paneadminborder = "";
|
||||
string panetitle = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
{
|
||||
paneadminborder = "pane-admin-border";
|
||||
panetitle = "<div class=\"pane-admin-title\">" + Name + " Pane</div>";
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
|
@ -86,11 +86,13 @@
|
||||
List<Module> modules;
|
||||
int moduleid = -1;
|
||||
string control = "";
|
||||
bool editmode = false;
|
||||
int reload = 0;
|
||||
|
||||
if (PageState != null)
|
||||
{
|
||||
reload = PageState.Reload;
|
||||
editmode = PageState.EditMode;
|
||||
}
|
||||
|
||||
if (PageState == null || reload == Constants.ReloadApplication)
|
||||
@ -188,6 +190,7 @@
|
||||
{
|
||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||
reload = Constants.ReloadPage;
|
||||
editmode = false;
|
||||
}
|
||||
|
||||
user = null;
|
||||
@ -238,6 +241,7 @@
|
||||
modules = PageState.Modules;
|
||||
}
|
||||
pagestate.Modules = modules;
|
||||
pagestate.EditMode = editmode;
|
||||
pagestate.Reload = 0;
|
||||
|
||||
OnStateChange?.Invoke(pagestate);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
RenderFragment DynamicComponent { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
|
@ -12,7 +12,9 @@
|
||||
@inject IModuleService ModuleService
|
||||
@inject IPageModuleService PageModuleService
|
||||
|
||||
<div id="actions" class="overlay">
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
<div id="actions" class="overlay">
|
||||
<a href="javascript:void(0)" class="closebtn" onclick="closeActions()">x</a>
|
||||
<div class="overlay-content">
|
||||
<ul class="nav flex-column">
|
||||
@ -68,11 +70,25 @@
|
||||
<button type="button" class="btn btn-primary" @onclick="@AddModule">Add Module To Page</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="oi oi-menu" style="@display" onclick="openActions()"></span>
|
||||
</div>
|
||||
|
||||
@if (PageState.EditMode)
|
||||
{
|
||||
<button type="button" class="btn btn-outline-primary active" data-toggle="button" aria-pressed="true" autocomplete="off" @onclick="EditMode">
|
||||
<span class="oi oi-pencil"></span>
|
||||
</button>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<button type="button" class="btn btn-outline-primary" data-toggle="button" aria-pressed="false" autocomplete="off" @onclick="EditMode">
|
||||
<span class="oi oi-pencil"></span>
|
||||
</button>
|
||||
}
|
||||
<span class="oi oi-menu" onclick="openActions()"></span>
|
||||
}
|
||||
|
||||
@code {
|
||||
string display = "display: none";
|
||||
List<ModuleDefinition> moduledefinitions;
|
||||
Dictionary<string, string> containers = new Dictionary<string, string>();
|
||||
int pagemanagementmoduleid = -1;
|
||||
@ -82,6 +98,8 @@
|
||||
string containertype;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
moduledefinitions = PageState.ModuleDefinitions;
|
||||
containers = ThemeService.GetContainerTypes(PageState.Themes);
|
||||
@ -90,13 +108,12 @@
|
||||
{
|
||||
pagemanagementmoduleid = modules.FirstOrDefault().ModuleId;
|
||||
}
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
display = "display: inline";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddModule()
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
Module module = new Module();
|
||||
module.SiteId = PageState.Site.SiteId;
|
||||
@ -123,6 +140,7 @@
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
||||
|
||||
private string PageUrl(string action)
|
||||
{
|
||||
@ -144,4 +162,21 @@
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
private void EditMode()
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", PageState.Page.Permissions))
|
||||
{
|
||||
if (PageState.EditMode)
|
||||
{
|
||||
PageState.EditMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PageState.EditMode = true;
|
||||
}
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl(PageState.Page.Path, "edit=" + PageState.EditMode.ToString().ToLower()));
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,9 @@
|
||||
@inject IUserService UserService
|
||||
@inject IPageModuleService PageModuleService
|
||||
|
||||
<div class="dropdown" style="@display">
|
||||
@if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||
{
|
||||
<div class="dropdown">
|
||||
<button type="button" class="btn dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@foreach (var action in actions)
|
||||
@ -16,13 +18,15 @@
|
||||
<a class="dropdown-item" @onclick="@(async () => await ModuleAction(action.Action))">@action.Name</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
string display = "display: none";
|
||||
List<ActionViewModel> actions;
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||
{
|
||||
actions = new List<ActionViewModel>();
|
||||
if (ModuleState.PaneModuleIndex > 0)
|
||||
@ -42,14 +46,12 @@
|
||||
}
|
||||
actions.Add(new ActionViewModel { Action = "settings", Name = "Settings" });
|
||||
actions.Add(new ActionViewModel { Action = "delete", Name = "Delete" });
|
||||
|
||||
if (UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||
{
|
||||
display = "display: inline";
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task ModuleAction(string action)
|
||||
{
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||
{
|
||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||
|
||||
@ -78,6 +80,7 @@
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(url);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionViewModel
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace Oqtane.Repository
|
||||
|
||||
public IEnumerable<Profile> GetProfiles(int SiteId)
|
||||
{
|
||||
return db.Profile.Where(item => item.SiteId == SiteId);
|
||||
return db.Profile.Where(item => item.SiteId == SiteId || item.SiteId == null);
|
||||
}
|
||||
|
||||
public Profile AddProfile(Profile Profile)
|
||||
|
@ -383,28 +383,28 @@ GO
|
||||
SET IDENTITY_INSERT [dbo].[Profile] ON
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (1, 1, 'FirstName', 'First Name', 'Your First Or Given Name', 'Name', 1, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (1, null, 'FirstName', 'First Name', 'Your First Or Given Name', 'Name', 1, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (2, 1, 'LastName', 'Last Name', 'Your Last Or family Name', 'Name', 2, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (2, null, 'LastName', 'Last Name', 'Your Last Or family Name', 'Name', 2, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (3, 1, 'Street', 'Street', 'Street Or Building Address', 'Address', 3, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (3, null, 'Street', 'Street', 'Street Or Building Address', 'Address', 3, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (4, 1, 'City', 'City', 'City', 'Address', 4, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (4, null, 'City', 'City', 'City', 'Address', 4, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (5, 1, 'Region', 'Region', 'State Or Province', 'Address', 5, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (5, null, 'Region', 'Region', 'State Or Province', 'Address', 5, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (6, 1, 'Country', 'Country', 'Country', 'Address', 6, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (6, null, 'Country', 'Country', 'Country', 'Address', 6, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (7, 1, 'PostalCode', 'Postal Code', 'Postal Code Or Zip Code', 'Address', 7, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (7, null, 'PostalCode', 'Postal Code', 'Postal Code Or Zip Code', 'Address', 7, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
INSERT [dbo].[Profile]([ProfileId], [SiteId], [Name], [Title], [Description], [Category], [ViewOrder], [MaxLength], [DefaultValue], [IsRequired], [IsPrivate], [CreatedBy], [CreatedOn], [ModifiedBy], [ModifiedOn])
|
||||
VALUES (8, 1, 'Phone', 'Phone Number', 'Phone Number', 'Contact', 8, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
VALUES (8, null, 'Phone', 'Phone Number', 'Phone Number', 'Contact', 8, 50, '', 1, 0, '', getdate(), '', getdate())
|
||||
GO
|
||||
SET IDENTITY_INSERT [dbo].[Profile] OFF
|
||||
GO
|
||||
|
@ -5,7 +5,7 @@ namespace Oqtane.Models
|
||||
public class Profile : IAuditable
|
||||
{
|
||||
public int ProfileId { get; set; }
|
||||
public int SiteId { get; set; }
|
||||
public int? SiteId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
Reference in New Issue
Block a user