VmModal.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. namespace VberAdmin.Web.Models.Modals;
  2. public class VmModal
  3. {
  4. public VmModal(string id, string formId)
  5. {
  6. Id = id;
  7. FormId = formId;
  8. }
  9. public VmModal(string id) : this(id, id + "_form")
  10. {
  11. Id = id;
  12. }
  13. public VmModal() : this("modal", "form")
  14. {
  15. }
  16. public VmModalHeader Header { get; set; }
  17. public int? Footer { get; set; } = 0;
  18. private VmModalBody _body;
  19. public string Other { get; set; }
  20. public string Class { get; set; }
  21. public string SizeClass { get; set; } = "modal-lg";
  22. public string DialogClass { get; set; } = "modal-dialog-centered modal-dialog-scrollable";
  23. public int? Width { get; set; }
  24. public VmModalBody Body
  25. {
  26. get
  27. {
  28. _body.Modal = this;
  29. return _body;
  30. }
  31. set => _body = value;
  32. }
  33. public string Id { get; set; }
  34. public string FormId { get; set; }
  35. public VmModal WithOther(string other)
  36. {
  37. Other = other;
  38. return this;
  39. }
  40. public VmModal WithClass(string @class)
  41. {
  42. Class = @class;
  43. return this;
  44. }
  45. public VmModal WithSizeClass(string sizeClass, string @class)
  46. {
  47. SizeClass = sizeClass;
  48. Class = @class;
  49. return this;
  50. }
  51. public VmModal WithWidth(int width)
  52. {
  53. Width = width;
  54. return this;
  55. }
  56. public VmModal WithHeaderAndFooter(VmModalHeader header, int? footer = 0)
  57. {
  58. Header = header;
  59. Footer = footer;
  60. return this;
  61. }
  62. public VmModal WithHeaderAndFooter(string title, string preFix = null, string subFix = null, int? footer = 0)
  63. {
  64. Header = new VmModalHeader(title, preFix, subFix);
  65. Footer = footer;
  66. return this;
  67. }
  68. public VmModal WithBody(string body)
  69. {
  70. Body = new VmModalBody().WithBodyContent(body);
  71. return this;
  72. }
  73. public VmModal WithBody(VmModalTabBodyBase body)
  74. {
  75. Body = (VmModalBody)body;
  76. return this;
  77. }
  78. public VmModal WithBody(VmModalBody body)
  79. {
  80. Body = body;
  81. return this;
  82. }
  83. public VmModalBody WithBody()
  84. {
  85. Body = new VmModalBody();
  86. return Body;
  87. }
  88. }