diff --git a/Moonlight/App/Models/Forms/Community/AddPostForm.cs b/Moonlight/App/Models/Forms/Community/AddPostForm.cs
new file mode 100644
index 00000000..c4dded80
--- /dev/null
+++ b/Moonlight/App/Models/Forms/Community/AddPostForm.cs
@@ -0,0 +1,16 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Moonlight.App.Models.Forms.Community;
+
+public class AddPostForm
+{
+ [Required(ErrorMessage = "You need to enter a title")]
+ [MaxLength(40, ErrorMessage = "The title can only be 40 characters long")]
+ [MinLength(8, ErrorMessage = "The title must at least have 8 characters")]
+ public string Title { get; set; } = "";
+
+ [Required(ErrorMessage = "You need to enter post content")]
+ [MaxLength(2048, ErrorMessage = "The post content can only be 2048 characters long")]
+ [MinLength(8, ErrorMessage = "The post content must at least have 8 characters")]
+ public string Content { get; set; } = "";
+}
\ No newline at end of file
diff --git a/Moonlight/App/Services/Interop/ModalService.cs b/Moonlight/App/Services/Interop/ModalService.cs
index 45d1984f..fcff73e2 100644
--- a/Moonlight/App/Services/Interop/ModalService.cs
+++ b/Moonlight/App/Services/Interop/ModalService.cs
@@ -11,11 +11,11 @@ public class ModalService
JsRuntime = jsRuntime;
}
- public async Task Show(string id)
+ public async Task Show(string id, bool focus = true) // Focus can be specified to fix issues with other components
{
try
{
- await JsRuntime.InvokeVoidAsync("moonlight.modals.show", id);
+ await JsRuntime.InvokeVoidAsync("moonlight.modals.show", id, focus);
}
catch (Exception)
{
diff --git a/Moonlight/Shared/Components/Forms/TextEditor.razor b/Moonlight/Shared/Components/Forms/TextEditor.razor
index f02e4387..54e1f59b 100644
--- a/Moonlight/Shared/Components/Forms/TextEditor.razor
+++ b/Moonlight/Shared/Components/Forms/TextEditor.razor
@@ -8,6 +8,13 @@
-
+
@code
{
[Parameter]
public string InitialContent { get; set; }
+
+ [Parameter]
+ public string CssClasses { get; set; } = "";
+
+ [Parameter]
+ public string Styles { get; set; } = ""; // We added this parameter to allow custom heights to be set
private string Id;
private bool IsInitialized = false;
diff --git a/Moonlight/Shared/Components/Modals/Community/CreatePostModal.razor b/Moonlight/Shared/Components/Modals/Community/CreatePostModal.razor
new file mode 100644
index 00000000..3607ed90
--- /dev/null
+++ b/Moonlight/Shared/Components/Modals/Community/CreatePostModal.razor
@@ -0,0 +1,64 @@
+@using Moonlight.App.Models.Forms.Community
+@using Moonlight.App.Services
+@using Moonlight.App.Services.Community
+@using Moonlight.App.Database.Enums
+
+@inject PostService PostService
+@inject IdentityService IdentityService
+@inject ToastService ToastService
+
+
+
+
Create a new post
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@code
+{
+ [Parameter]
+ public Func? OnUpdate { get; set; }
+
+ [Parameter]
+ public PostType PostType { get; set; }
+
+ private AddPostForm Form = new();
+ private SmartModal Modal;
+
+ public async Task Show()
+ {
+ Form = new();
+ await Modal.Show(false);
+ }
+
+ private async Task Submit()
+ {
+ await PostService.Create(
+ IdentityService.CurrentUser,
+ Form.Title,
+ Form.Content,
+ PostType
+ );
+
+ await Modal.Hide();
+ await ToastService.Success("Successfully created post");
+
+ if (OnUpdate != null)
+ await OnUpdate.Invoke();
+ }
+}
\ No newline at end of file
diff --git a/Moonlight/Shared/Components/Navigations/CommunityNavigation.razor b/Moonlight/Shared/Components/Navigations/CommunityNavigation.razor
new file mode 100644
index 00000000..4000e033
--- /dev/null
+++ b/Moonlight/Shared/Components/Navigations/CommunityNavigation.razor
@@ -0,0 +1,41 @@
+
+ Planned events and current happenings can be found here.
+ If you want to know what will happen in the future or is going on now have a look at the posts below
+
+ These announcements provide you with the latest news and information.
+ The posts here have been created by an admin and can contain valuable information
+ so consider reading it from time to time
+
+
+
+
+ @foreach (var post in Posts)
+ {
+
+
+ }
+
+
+ You have a interesting project or a fun game server you want to share with the community?
+ You can share it here. Please keep in mind to follow basic rules and dont offend anyone.
+ Be nice and respectful
+
+
+
+
+
+ @foreach (var post in Posts)
+ {
+
+
+ }
+
+
+
+
+
+
+
+@code
+{
+ private LazyLoader LazyLoader;
+ private CreatePostModal CreateModal;
+ private Post[] Posts;
+
+ private Task Load(LazyLoader _)
+ {
+ Posts = PostRepository
+ .Get()
+ .Include(x => x.Author)
+ .Where(x => x.Type == PostType.Project)
+ .ToArray();
+
+ return Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Moonlight/wwwroot/js/moonlight.js b/Moonlight/wwwroot/js/moonlight.js
index 657bc9c5..b59aeca3 100644
--- a/Moonlight/wwwroot/js/moonlight.js
+++ b/Moonlight/wwwroot/js/moonlight.js
@@ -23,9 +23,12 @@ window.moonlight = {
}
},
modals: {
- show: function (id)
+ show: function (id, focus)
{
- let modal = new bootstrap.Modal(document.getElementById(id));
+ let modal = new bootstrap.Modal(document.getElementById(id), {
+ focus: focus
+ });
+
modal.show();
},
hide: function (id)