commit 9c6922d69c0f2aed10f831654660a67cb9355814
parent 0bf410846cece5304f77ce26266748ae2a6e9717
Author: William Lindholm <william_lindholm@outlook.com>
Date: Fri, 13 Oct 2023 15:47:39 +0200
Implemented modalbuilder.
Diffstat:
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/MVC-databaskonstruktion/Utils/Modal.cs b/MVC-databaskonstruktion/Utils/Modal.cs
@@ -0,0 +1,19 @@
+using Microsoft.AspNetCore.Mvc.Rendering;
+
+namespace MVC_databaskonstruktion.Utils
+{
+ public class Modal
+ {
+ public string Title { get; set; }
+ public List<ModalInput> Inputs { get; set; }
+ }
+
+ public class ModalInput
+ {
+ public string Id { get; set; }
+ public string Label { get; set; }
+ public string Type { get; set; }
+ public IEnumerable<SelectListItem> DropdownItems { get; set; } // For dropdown type
+ public string Placeholder { get; set; }
+ }
+}
diff --git a/MVC-databaskonstruktion/Utils/ModalBuilder.cs b/MVC-databaskonstruktion/Utils/ModalBuilder.cs
@@ -0,0 +1,26 @@
+using Microsoft.AspNetCore.Mvc.Rendering;
+
+namespace MVC_databaskonstruktion.Utils
+{
+ public class ModalBuilder
+ {
+ private Modal _modal = new Modal { Inputs = new List<ModalInput>() };
+
+ public ModalBuilder WithTitle(string title)
+ {
+ _modal.Title = title;
+ return this;
+ }
+
+ public ModalBuilder AddInput(string id, string label, string type, string placeholder = "", IEnumerable<SelectListItem> dropdownItems = null)
+ {
+ _modal.Inputs.Add(new ModalInput { Id = id, Label = label, Type = type, Placeholder = placeholder, DropdownItems = dropdownItems });
+ return this;
+ }
+
+ public Modal Build()
+ {
+ return _modal;
+ }
+ }
+}