form_fields_templ.go 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. // Code generated by templ - DO NOT EDIT.
  2. // templ: version: v0.3.906
  3. package components
  4. //lint:file-ignore SA4006 This context is only used if a nested component is present.
  5. import "github.com/a-h/templ"
  6. import templruntime "github.com/a-h/templ/runtime"
  7. import "fmt"
  8. // FormFieldData represents common form field data
  9. type FormFieldData struct {
  10. Name string
  11. Label string
  12. Description string
  13. Required bool
  14. }
  15. // TextFieldData represents text input field data
  16. type TextFieldData struct {
  17. FormFieldData
  18. Value string
  19. Placeholder string
  20. }
  21. // NumberFieldData represents number input field data
  22. type NumberFieldData struct {
  23. FormFieldData
  24. Value float64
  25. Step string
  26. Min *float64
  27. Max *float64
  28. }
  29. // CheckboxFieldData represents checkbox field data
  30. type CheckboxFieldData struct {
  31. FormFieldData
  32. Checked bool
  33. }
  34. // SelectFieldData represents select field data
  35. type SelectFieldData struct {
  36. FormFieldData
  37. Value string
  38. Options []SelectOption
  39. }
  40. type SelectOption struct {
  41. Value string
  42. Label string
  43. }
  44. // DurationFieldData represents duration input field data
  45. type DurationFieldData struct {
  46. FormFieldData
  47. Value string
  48. Placeholder string
  49. }
  50. // DurationInputFieldData represents duration input with number + unit dropdown
  51. type DurationInputFieldData struct {
  52. FormFieldData
  53. Seconds int // The duration value in seconds
  54. }
  55. // TextField renders a Bootstrap text input field
  56. func TextField(data TextFieldData) templ.Component {
  57. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  58. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  59. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  60. return templ_7745c5c3_CtxErr
  61. }
  62. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  63. if !templ_7745c5c3_IsBuffer {
  64. defer func() {
  65. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  66. if templ_7745c5c3_Err == nil {
  67. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  68. }
  69. }()
  70. }
  71. ctx = templ.InitializeContext(ctx)
  72. templ_7745c5c3_Var1 := templ.GetChildren(ctx)
  73. if templ_7745c5c3_Var1 == nil {
  74. templ_7745c5c3_Var1 = templ.NopComponent
  75. }
  76. ctx = templ.ClearChildren(ctx)
  77. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"mb-3\"><label for=\"")
  78. if templ_7745c5c3_Err != nil {
  79. return templ_7745c5c3_Err
  80. }
  81. var templ_7745c5c3_Var2 string
  82. templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  83. if templ_7745c5c3_Err != nil {
  84. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 63, Col: 30}
  85. }
  86. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
  87. if templ_7745c5c3_Err != nil {
  88. return templ_7745c5c3_Err
  89. }
  90. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" class=\"form-label\">")
  91. if templ_7745c5c3_Err != nil {
  92. return templ_7745c5c3_Err
  93. }
  94. var templ_7745c5c3_Var3 string
  95. templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  96. if templ_7745c5c3_Err != nil {
  97. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 64, Col: 24}
  98. }
  99. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
  100. if templ_7745c5c3_Err != nil {
  101. return templ_7745c5c3_Err
  102. }
  103. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " ")
  104. if templ_7745c5c3_Err != nil {
  105. return templ_7745c5c3_Err
  106. }
  107. if data.Required {
  108. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<span class=\"text-danger\">*</span>")
  109. if templ_7745c5c3_Err != nil {
  110. return templ_7745c5c3_Err
  111. }
  112. }
  113. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</label> <input type=\"text\" class=\"form-control\" id=\"")
  114. if templ_7745c5c3_Err != nil {
  115. return templ_7745c5c3_Err
  116. }
  117. var templ_7745c5c3_Var4 string
  118. templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  119. if templ_7745c5c3_Err != nil {
  120. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 72, Col: 26}
  121. }
  122. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
  123. if templ_7745c5c3_Err != nil {
  124. return templ_7745c5c3_Err
  125. }
  126. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\" name=\"")
  127. if templ_7745c5c3_Err != nil {
  128. return templ_7745c5c3_Err
  129. }
  130. var templ_7745c5c3_Var5 string
  131. templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  132. if templ_7745c5c3_Err != nil {
  133. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 73, Col: 28}
  134. }
  135. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
  136. if templ_7745c5c3_Err != nil {
  137. return templ_7745c5c3_Err
  138. }
  139. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\" value=\"")
  140. if templ_7745c5c3_Err != nil {
  141. return templ_7745c5c3_Err
  142. }
  143. var templ_7745c5c3_Var6 string
  144. templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.Value)
  145. if templ_7745c5c3_Err != nil {
  146. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 74, Col: 30}
  147. }
  148. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
  149. if templ_7745c5c3_Err != nil {
  150. return templ_7745c5c3_Err
  151. }
  152. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\"")
  153. if templ_7745c5c3_Err != nil {
  154. return templ_7745c5c3_Err
  155. }
  156. if data.Placeholder != "" {
  157. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " placeholder=\"")
  158. if templ_7745c5c3_Err != nil {
  159. return templ_7745c5c3_Err
  160. }
  161. var templ_7745c5c3_Var7 string
  162. templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(data.Placeholder)
  163. if templ_7745c5c3_Err != nil {
  164. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 76, Col: 46}
  165. }
  166. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
  167. if templ_7745c5c3_Err != nil {
  168. return templ_7745c5c3_Err
  169. }
  170. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\"")
  171. if templ_7745c5c3_Err != nil {
  172. return templ_7745c5c3_Err
  173. }
  174. }
  175. if data.Required {
  176. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " required")
  177. if templ_7745c5c3_Err != nil {
  178. return templ_7745c5c3_Err
  179. }
  180. }
  181. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "> ")
  182. if templ_7745c5c3_Err != nil {
  183. return templ_7745c5c3_Err
  184. }
  185. if data.Description != "" {
  186. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<div class=\"form-text text-muted\">")
  187. if templ_7745c5c3_Err != nil {
  188. return templ_7745c5c3_Err
  189. }
  190. var templ_7745c5c3_Var8 string
  191. templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  192. if templ_7745c5c3_Err != nil {
  193. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 83, Col: 64}
  194. }
  195. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
  196. if templ_7745c5c3_Err != nil {
  197. return templ_7745c5c3_Err
  198. }
  199. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</div>")
  200. if templ_7745c5c3_Err != nil {
  201. return templ_7745c5c3_Err
  202. }
  203. }
  204. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div>")
  205. if templ_7745c5c3_Err != nil {
  206. return templ_7745c5c3_Err
  207. }
  208. return nil
  209. })
  210. }
  211. // NumberField renders a Bootstrap number input field
  212. func NumberField(data NumberFieldData) templ.Component {
  213. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  214. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  215. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  216. return templ_7745c5c3_CtxErr
  217. }
  218. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  219. if !templ_7745c5c3_IsBuffer {
  220. defer func() {
  221. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  222. if templ_7745c5c3_Err == nil {
  223. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  224. }
  225. }()
  226. }
  227. ctx = templ.InitializeContext(ctx)
  228. templ_7745c5c3_Var9 := templ.GetChildren(ctx)
  229. if templ_7745c5c3_Var9 == nil {
  230. templ_7745c5c3_Var9 = templ.NopComponent
  231. }
  232. ctx = templ.ClearChildren(ctx)
  233. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"mb-3\"><label for=\"")
  234. if templ_7745c5c3_Err != nil {
  235. return templ_7745c5c3_Err
  236. }
  237. var templ_7745c5c3_Var10 string
  238. templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  239. if templ_7745c5c3_Err != nil {
  240. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 91, Col: 30}
  241. }
  242. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
  243. if templ_7745c5c3_Err != nil {
  244. return templ_7745c5c3_Err
  245. }
  246. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\" class=\"form-label\">")
  247. if templ_7745c5c3_Err != nil {
  248. return templ_7745c5c3_Err
  249. }
  250. var templ_7745c5c3_Var11 string
  251. templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  252. if templ_7745c5c3_Err != nil {
  253. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 92, Col: 24}
  254. }
  255. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
  256. if templ_7745c5c3_Err != nil {
  257. return templ_7745c5c3_Err
  258. }
  259. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ")
  260. if templ_7745c5c3_Err != nil {
  261. return templ_7745c5c3_Err
  262. }
  263. if data.Required {
  264. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<span class=\"text-danger\">*</span>")
  265. if templ_7745c5c3_Err != nil {
  266. return templ_7745c5c3_Err
  267. }
  268. }
  269. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "</label> <input type=\"number\" class=\"form-control\" id=\"")
  270. if templ_7745c5c3_Err != nil {
  271. return templ_7745c5c3_Err
  272. }
  273. var templ_7745c5c3_Var12 string
  274. templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  275. if templ_7745c5c3_Err != nil {
  276. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 100, Col: 26}
  277. }
  278. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
  279. if templ_7745c5c3_Err != nil {
  280. return templ_7745c5c3_Err
  281. }
  282. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\" name=\"")
  283. if templ_7745c5c3_Err != nil {
  284. return templ_7745c5c3_Err
  285. }
  286. var templ_7745c5c3_Var13 string
  287. templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  288. if templ_7745c5c3_Err != nil {
  289. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 101, Col: 28}
  290. }
  291. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
  292. if templ_7745c5c3_Err != nil {
  293. return templ_7745c5c3_Err
  294. }
  295. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\" value=\"")
  296. if templ_7745c5c3_Err != nil {
  297. return templ_7745c5c3_Err
  298. }
  299. var templ_7745c5c3_Var14 string
  300. templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.6g", data.Value))
  301. if templ_7745c5c3_Err != nil {
  302. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 102, Col: 51}
  303. }
  304. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
  305. if templ_7745c5c3_Err != nil {
  306. return templ_7745c5c3_Err
  307. }
  308. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\"")
  309. if templ_7745c5c3_Err != nil {
  310. return templ_7745c5c3_Err
  311. }
  312. if data.Step != "" {
  313. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " step=\"")
  314. if templ_7745c5c3_Err != nil {
  315. return templ_7745c5c3_Err
  316. }
  317. var templ_7745c5c3_Var15 string
  318. templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(data.Step)
  319. if templ_7745c5c3_Err != nil {
  320. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 104, Col: 32}
  321. }
  322. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
  323. if templ_7745c5c3_Err != nil {
  324. return templ_7745c5c3_Err
  325. }
  326. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\"")
  327. if templ_7745c5c3_Err != nil {
  328. return templ_7745c5c3_Err
  329. }
  330. } else {
  331. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " step=\"any\"")
  332. if templ_7745c5c3_Err != nil {
  333. return templ_7745c5c3_Err
  334. }
  335. }
  336. if data.Min != nil {
  337. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, " min=\"")
  338. if templ_7745c5c3_Err != nil {
  339. return templ_7745c5c3_Err
  340. }
  341. var templ_7745c5c3_Var16 string
  342. templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.6g", *data.Min))
  343. if templ_7745c5c3_Err != nil {
  344. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 109, Col: 52}
  345. }
  346. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
  347. if templ_7745c5c3_Err != nil {
  348. return templ_7745c5c3_Err
  349. }
  350. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\"")
  351. if templ_7745c5c3_Err != nil {
  352. return templ_7745c5c3_Err
  353. }
  354. }
  355. if data.Max != nil {
  356. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " max=\"")
  357. if templ_7745c5c3_Err != nil {
  358. return templ_7745c5c3_Err
  359. }
  360. var templ_7745c5c3_Var17 string
  361. templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.6g", *data.Max))
  362. if templ_7745c5c3_Err != nil {
  363. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 112, Col: 52}
  364. }
  365. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
  366. if templ_7745c5c3_Err != nil {
  367. return templ_7745c5c3_Err
  368. }
  369. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "\"")
  370. if templ_7745c5c3_Err != nil {
  371. return templ_7745c5c3_Err
  372. }
  373. }
  374. if data.Required {
  375. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, " required")
  376. if templ_7745c5c3_Err != nil {
  377. return templ_7745c5c3_Err
  378. }
  379. }
  380. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "> ")
  381. if templ_7745c5c3_Err != nil {
  382. return templ_7745c5c3_Err
  383. }
  384. if data.Description != "" {
  385. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<div class=\"form-text text-muted\">")
  386. if templ_7745c5c3_Err != nil {
  387. return templ_7745c5c3_Err
  388. }
  389. var templ_7745c5c3_Var18 string
  390. templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  391. if templ_7745c5c3_Err != nil {
  392. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 119, Col: 64}
  393. }
  394. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
  395. if templ_7745c5c3_Err != nil {
  396. return templ_7745c5c3_Err
  397. }
  398. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</div>")
  399. if templ_7745c5c3_Err != nil {
  400. return templ_7745c5c3_Err
  401. }
  402. }
  403. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</div>")
  404. if templ_7745c5c3_Err != nil {
  405. return templ_7745c5c3_Err
  406. }
  407. return nil
  408. })
  409. }
  410. // CheckboxField renders a Bootstrap checkbox field
  411. func CheckboxField(data CheckboxFieldData) templ.Component {
  412. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  413. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  414. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  415. return templ_7745c5c3_CtxErr
  416. }
  417. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  418. if !templ_7745c5c3_IsBuffer {
  419. defer func() {
  420. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  421. if templ_7745c5c3_Err == nil {
  422. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  423. }
  424. }()
  425. }
  426. ctx = templ.InitializeContext(ctx)
  427. templ_7745c5c3_Var19 := templ.GetChildren(ctx)
  428. if templ_7745c5c3_Var19 == nil {
  429. templ_7745c5c3_Var19 = templ.NopComponent
  430. }
  431. ctx = templ.ClearChildren(ctx)
  432. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "<div class=\"mb-3\"><div class=\"form-check\"><input type=\"checkbox\" class=\"form-check-input\" id=\"")
  433. if templ_7745c5c3_Err != nil {
  434. return templ_7745c5c3_Err
  435. }
  436. var templ_7745c5c3_Var20 string
  437. templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  438. if templ_7745c5c3_Err != nil {
  439. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 131, Col: 30}
  440. }
  441. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
  442. if templ_7745c5c3_Err != nil {
  443. return templ_7745c5c3_Err
  444. }
  445. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\" name=\"")
  446. if templ_7745c5c3_Err != nil {
  447. return templ_7745c5c3_Err
  448. }
  449. var templ_7745c5c3_Var21 string
  450. templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  451. if templ_7745c5c3_Err != nil {
  452. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 132, Col: 32}
  453. }
  454. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
  455. if templ_7745c5c3_Err != nil {
  456. return templ_7745c5c3_Err
  457. }
  458. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "\"")
  459. if templ_7745c5c3_Err != nil {
  460. return templ_7745c5c3_Err
  461. }
  462. if data.Checked {
  463. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, " checked")
  464. if templ_7745c5c3_Err != nil {
  465. return templ_7745c5c3_Err
  466. }
  467. }
  468. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "> <label class=\"form-check-label\" for=\"")
  469. if templ_7745c5c3_Err != nil {
  470. return templ_7745c5c3_Err
  471. }
  472. var templ_7745c5c3_Var22 string
  473. templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  474. if templ_7745c5c3_Err != nil {
  475. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 137, Col: 59}
  476. }
  477. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
  478. if templ_7745c5c3_Err != nil {
  479. return templ_7745c5c3_Err
  480. }
  481. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "\">")
  482. if templ_7745c5c3_Err != nil {
  483. return templ_7745c5c3_Err
  484. }
  485. var templ_7745c5c3_Var23 string
  486. templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  487. if templ_7745c5c3_Err != nil {
  488. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 138, Col: 28}
  489. }
  490. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
  491. if templ_7745c5c3_Err != nil {
  492. return templ_7745c5c3_Err
  493. }
  494. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "</label></div>")
  495. if templ_7745c5c3_Err != nil {
  496. return templ_7745c5c3_Err
  497. }
  498. if data.Description != "" {
  499. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "<div class=\"form-text text-muted\">")
  500. if templ_7745c5c3_Err != nil {
  501. return templ_7745c5c3_Err
  502. }
  503. var templ_7745c5c3_Var24 string
  504. templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  505. if templ_7745c5c3_Err != nil {
  506. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 142, Col: 64}
  507. }
  508. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
  509. if templ_7745c5c3_Err != nil {
  510. return templ_7745c5c3_Err
  511. }
  512. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "</div>")
  513. if templ_7745c5c3_Err != nil {
  514. return templ_7745c5c3_Err
  515. }
  516. }
  517. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "</div>")
  518. if templ_7745c5c3_Err != nil {
  519. return templ_7745c5c3_Err
  520. }
  521. return nil
  522. })
  523. }
  524. // SelectField renders a Bootstrap select field
  525. func SelectField(data SelectFieldData) templ.Component {
  526. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  527. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  528. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  529. return templ_7745c5c3_CtxErr
  530. }
  531. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  532. if !templ_7745c5c3_IsBuffer {
  533. defer func() {
  534. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  535. if templ_7745c5c3_Err == nil {
  536. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  537. }
  538. }()
  539. }
  540. ctx = templ.InitializeContext(ctx)
  541. templ_7745c5c3_Var25 := templ.GetChildren(ctx)
  542. if templ_7745c5c3_Var25 == nil {
  543. templ_7745c5c3_Var25 = templ.NopComponent
  544. }
  545. ctx = templ.ClearChildren(ctx)
  546. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "<div class=\"mb-3\"><label for=\"")
  547. if templ_7745c5c3_Err != nil {
  548. return templ_7745c5c3_Err
  549. }
  550. var templ_7745c5c3_Var26 string
  551. templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  552. if templ_7745c5c3_Err != nil {
  553. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 150, Col: 30}
  554. }
  555. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
  556. if templ_7745c5c3_Err != nil {
  557. return templ_7745c5c3_Err
  558. }
  559. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "\" class=\"form-label\">")
  560. if templ_7745c5c3_Err != nil {
  561. return templ_7745c5c3_Err
  562. }
  563. var templ_7745c5c3_Var27 string
  564. templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  565. if templ_7745c5c3_Err != nil {
  566. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 151, Col: 24}
  567. }
  568. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
  569. if templ_7745c5c3_Err != nil {
  570. return templ_7745c5c3_Err
  571. }
  572. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, " ")
  573. if templ_7745c5c3_Err != nil {
  574. return templ_7745c5c3_Err
  575. }
  576. if data.Required {
  577. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "<span class=\"text-danger\">*</span>")
  578. if templ_7745c5c3_Err != nil {
  579. return templ_7745c5c3_Err
  580. }
  581. }
  582. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "</label> <select class=\"form-select\" id=\"")
  583. if templ_7745c5c3_Err != nil {
  584. return templ_7745c5c3_Err
  585. }
  586. var templ_7745c5c3_Var28 string
  587. templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  588. if templ_7745c5c3_Err != nil {
  589. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 158, Col: 26}
  590. }
  591. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
  592. if templ_7745c5c3_Err != nil {
  593. return templ_7745c5c3_Err
  594. }
  595. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "\" name=\"")
  596. if templ_7745c5c3_Err != nil {
  597. return templ_7745c5c3_Err
  598. }
  599. var templ_7745c5c3_Var29 string
  600. templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  601. if templ_7745c5c3_Err != nil {
  602. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 159, Col: 28}
  603. }
  604. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
  605. if templ_7745c5c3_Err != nil {
  606. return templ_7745c5c3_Err
  607. }
  608. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "\"")
  609. if templ_7745c5c3_Err != nil {
  610. return templ_7745c5c3_Err
  611. }
  612. if data.Required {
  613. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, " required")
  614. if templ_7745c5c3_Err != nil {
  615. return templ_7745c5c3_Err
  616. }
  617. }
  618. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, ">")
  619. if templ_7745c5c3_Err != nil {
  620. return templ_7745c5c3_Err
  621. }
  622. for _, option := range data.Options {
  623. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "<option value=\"")
  624. if templ_7745c5c3_Err != nil {
  625. return templ_7745c5c3_Err
  626. }
  627. var templ_7745c5c3_Var30 string
  628. templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(option.Value)
  629. if templ_7745c5c3_Err != nil {
  630. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 166, Col: 40}
  631. }
  632. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
  633. if templ_7745c5c3_Err != nil {
  634. return templ_7745c5c3_Err
  635. }
  636. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "\"")
  637. if templ_7745c5c3_Err != nil {
  638. return templ_7745c5c3_Err
  639. }
  640. if option.Value == data.Value {
  641. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, " selected")
  642. if templ_7745c5c3_Err != nil {
  643. return templ_7745c5c3_Err
  644. }
  645. }
  646. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, ">")
  647. if templ_7745c5c3_Err != nil {
  648. return templ_7745c5c3_Err
  649. }
  650. var templ_7745c5c3_Var31 string
  651. templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(option.Label)
  652. if templ_7745c5c3_Err != nil {
  653. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 171, Col: 34}
  654. }
  655. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
  656. if templ_7745c5c3_Err != nil {
  657. return templ_7745c5c3_Err
  658. }
  659. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "</option>")
  660. if templ_7745c5c3_Err != nil {
  661. return templ_7745c5c3_Err
  662. }
  663. }
  664. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "</select> ")
  665. if templ_7745c5c3_Err != nil {
  666. return templ_7745c5c3_Err
  667. }
  668. if data.Description != "" {
  669. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "<div class=\"form-text text-muted\">")
  670. if templ_7745c5c3_Err != nil {
  671. return templ_7745c5c3_Err
  672. }
  673. var templ_7745c5c3_Var32 string
  674. templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  675. if templ_7745c5c3_Err != nil {
  676. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 176, Col: 64}
  677. }
  678. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32))
  679. if templ_7745c5c3_Err != nil {
  680. return templ_7745c5c3_Err
  681. }
  682. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "</div>")
  683. if templ_7745c5c3_Err != nil {
  684. return templ_7745c5c3_Err
  685. }
  686. }
  687. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "</div>")
  688. if templ_7745c5c3_Err != nil {
  689. return templ_7745c5c3_Err
  690. }
  691. return nil
  692. })
  693. }
  694. // DurationField renders a Bootstrap duration input field
  695. func DurationField(data DurationFieldData) templ.Component {
  696. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  697. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  698. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  699. return templ_7745c5c3_CtxErr
  700. }
  701. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  702. if !templ_7745c5c3_IsBuffer {
  703. defer func() {
  704. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  705. if templ_7745c5c3_Err == nil {
  706. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  707. }
  708. }()
  709. }
  710. ctx = templ.InitializeContext(ctx)
  711. templ_7745c5c3_Var33 := templ.GetChildren(ctx)
  712. if templ_7745c5c3_Var33 == nil {
  713. templ_7745c5c3_Var33 = templ.NopComponent
  714. }
  715. ctx = templ.ClearChildren(ctx)
  716. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "<div class=\"mb-3\"><label for=\"")
  717. if templ_7745c5c3_Err != nil {
  718. return templ_7745c5c3_Err
  719. }
  720. var templ_7745c5c3_Var34 string
  721. templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  722. if templ_7745c5c3_Err != nil {
  723. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 184, Col: 30}
  724. }
  725. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34))
  726. if templ_7745c5c3_Err != nil {
  727. return templ_7745c5c3_Err
  728. }
  729. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "\" class=\"form-label\">")
  730. if templ_7745c5c3_Err != nil {
  731. return templ_7745c5c3_Err
  732. }
  733. var templ_7745c5c3_Var35 string
  734. templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  735. if templ_7745c5c3_Err != nil {
  736. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 185, Col: 24}
  737. }
  738. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35))
  739. if templ_7745c5c3_Err != nil {
  740. return templ_7745c5c3_Err
  741. }
  742. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, " ")
  743. if templ_7745c5c3_Err != nil {
  744. return templ_7745c5c3_Err
  745. }
  746. if data.Required {
  747. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "<span class=\"text-danger\">*</span>")
  748. if templ_7745c5c3_Err != nil {
  749. return templ_7745c5c3_Err
  750. }
  751. }
  752. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "</label> <input type=\"text\" class=\"form-control\" id=\"")
  753. if templ_7745c5c3_Err != nil {
  754. return templ_7745c5c3_Err
  755. }
  756. var templ_7745c5c3_Var36 string
  757. templ_7745c5c3_Var36, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  758. if templ_7745c5c3_Err != nil {
  759. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 193, Col: 26}
  760. }
  761. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var36))
  762. if templ_7745c5c3_Err != nil {
  763. return templ_7745c5c3_Err
  764. }
  765. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "\" name=\"")
  766. if templ_7745c5c3_Err != nil {
  767. return templ_7745c5c3_Err
  768. }
  769. var templ_7745c5c3_Var37 string
  770. templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  771. if templ_7745c5c3_Err != nil {
  772. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 194, Col: 28}
  773. }
  774. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37))
  775. if templ_7745c5c3_Err != nil {
  776. return templ_7745c5c3_Err
  777. }
  778. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "\" value=\"")
  779. if templ_7745c5c3_Err != nil {
  780. return templ_7745c5c3_Err
  781. }
  782. var templ_7745c5c3_Var38 string
  783. templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(data.Value)
  784. if templ_7745c5c3_Err != nil {
  785. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 195, Col: 30}
  786. }
  787. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38))
  788. if templ_7745c5c3_Err != nil {
  789. return templ_7745c5c3_Err
  790. }
  791. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "\"")
  792. if templ_7745c5c3_Err != nil {
  793. return templ_7745c5c3_Err
  794. }
  795. if data.Placeholder != "" {
  796. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, " placeholder=\"")
  797. if templ_7745c5c3_Err != nil {
  798. return templ_7745c5c3_Err
  799. }
  800. var templ_7745c5c3_Var39 string
  801. templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(data.Placeholder)
  802. if templ_7745c5c3_Err != nil {
  803. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 197, Col: 46}
  804. }
  805. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
  806. if templ_7745c5c3_Err != nil {
  807. return templ_7745c5c3_Err
  808. }
  809. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "\"")
  810. if templ_7745c5c3_Err != nil {
  811. return templ_7745c5c3_Err
  812. }
  813. } else {
  814. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, " placeholder=\"e.g., 30m, 2h, 24h\"")
  815. if templ_7745c5c3_Err != nil {
  816. return templ_7745c5c3_Err
  817. }
  818. }
  819. if data.Required {
  820. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, " required")
  821. if templ_7745c5c3_Err != nil {
  822. return templ_7745c5c3_Err
  823. }
  824. }
  825. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "> ")
  826. if templ_7745c5c3_Err != nil {
  827. return templ_7745c5c3_Err
  828. }
  829. if data.Description != "" {
  830. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 77, "<div class=\"form-text text-muted\">")
  831. if templ_7745c5c3_Err != nil {
  832. return templ_7745c5c3_Err
  833. }
  834. var templ_7745c5c3_Var40 string
  835. templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  836. if templ_7745c5c3_Err != nil {
  837. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 206, Col: 64}
  838. }
  839. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
  840. if templ_7745c5c3_Err != nil {
  841. return templ_7745c5c3_Err
  842. }
  843. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "</div>")
  844. if templ_7745c5c3_Err != nil {
  845. return templ_7745c5c3_Err
  846. }
  847. }
  848. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "</div>")
  849. if templ_7745c5c3_Err != nil {
  850. return templ_7745c5c3_Err
  851. }
  852. return nil
  853. })
  854. }
  855. // DurationInputField renders a Bootstrap duration input with number + unit dropdown
  856. func DurationInputField(data DurationInputFieldData) templ.Component {
  857. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  858. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  859. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  860. return templ_7745c5c3_CtxErr
  861. }
  862. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  863. if !templ_7745c5c3_IsBuffer {
  864. defer func() {
  865. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  866. if templ_7745c5c3_Err == nil {
  867. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  868. }
  869. }()
  870. }
  871. ctx = templ.InitializeContext(ctx)
  872. templ_7745c5c3_Var41 := templ.GetChildren(ctx)
  873. if templ_7745c5c3_Var41 == nil {
  874. templ_7745c5c3_Var41 = templ.NopComponent
  875. }
  876. ctx = templ.ClearChildren(ctx)
  877. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "<div class=\"mb-3\"><label for=\"")
  878. if templ_7745c5c3_Err != nil {
  879. return templ_7745c5c3_Err
  880. }
  881. var templ_7745c5c3_Var42 string
  882. templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  883. if templ_7745c5c3_Err != nil {
  884. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 214, Col: 24}
  885. }
  886. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
  887. if templ_7745c5c3_Err != nil {
  888. return templ_7745c5c3_Err
  889. }
  890. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 81, "\" class=\"form-label\">")
  891. if templ_7745c5c3_Err != nil {
  892. return templ_7745c5c3_Err
  893. }
  894. var templ_7745c5c3_Var43 string
  895. templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  896. if templ_7745c5c3_Err != nil {
  897. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 215, Col: 15}
  898. }
  899. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43))
  900. if templ_7745c5c3_Err != nil {
  901. return templ_7745c5c3_Err
  902. }
  903. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 82, " ")
  904. if templ_7745c5c3_Err != nil {
  905. return templ_7745c5c3_Err
  906. }
  907. if data.Required {
  908. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 83, "<span class=\"text-danger\">*</span>")
  909. if templ_7745c5c3_Err != nil {
  910. return templ_7745c5c3_Err
  911. }
  912. }
  913. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "</label><div class=\"input-group\"><input type=\"number\" class=\"form-control\" id=\"")
  914. if templ_7745c5c3_Err != nil {
  915. return templ_7745c5c3_Err
  916. }
  917. var templ_7745c5c3_Var44 string
  918. templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  919. if templ_7745c5c3_Err != nil {
  920. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 224, Col: 18}
  921. }
  922. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
  923. if templ_7745c5c3_Err != nil {
  924. return templ_7745c5c3_Err
  925. }
  926. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "\" name=\"")
  927. if templ_7745c5c3_Err != nil {
  928. return templ_7745c5c3_Err
  929. }
  930. var templ_7745c5c3_Var45 string
  931. templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  932. if templ_7745c5c3_Err != nil {
  933. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 225, Col: 20}
  934. }
  935. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45))
  936. if templ_7745c5c3_Err != nil {
  937. return templ_7745c5c3_Err
  938. }
  939. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 86, "\" value=\"")
  940. if templ_7745c5c3_Err != nil {
  941. return templ_7745c5c3_Err
  942. }
  943. var templ_7745c5c3_Var46 string
  944. templ_7745c5c3_Var46, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.0f", convertSecondsToValue(data.Seconds, convertSecondsToUnit(data.Seconds))))
  945. if templ_7745c5c3_Err != nil {
  946. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 226, Col: 104}
  947. }
  948. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46))
  949. if templ_7745c5c3_Err != nil {
  950. return templ_7745c5c3_Err
  951. }
  952. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 87, "\" step=\"1\" min=\"1\"")
  953. if templ_7745c5c3_Err != nil {
  954. return templ_7745c5c3_Err
  955. }
  956. if data.Required {
  957. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 88, " required")
  958. if templ_7745c5c3_Err != nil {
  959. return templ_7745c5c3_Err
  960. }
  961. }
  962. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 89, "> <select class=\"form-select\" id=\"")
  963. if templ_7745c5c3_Err != nil {
  964. return templ_7745c5c3_Err
  965. }
  966. var templ_7745c5c3_Var47 string
  967. templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_unit")
  968. if templ_7745c5c3_Err != nil {
  969. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 235, Col: 28}
  970. }
  971. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47))
  972. if templ_7745c5c3_Err != nil {
  973. return templ_7745c5c3_Err
  974. }
  975. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 90, "\" name=\"")
  976. if templ_7745c5c3_Err != nil {
  977. return templ_7745c5c3_Err
  978. }
  979. var templ_7745c5c3_Var48 string
  980. templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_unit")
  981. if templ_7745c5c3_Err != nil {
  982. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 236, Col: 30}
  983. }
  984. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48))
  985. if templ_7745c5c3_Err != nil {
  986. return templ_7745c5c3_Err
  987. }
  988. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "\" style=\"max-width: 120px;\"><option value=\"minutes\"")
  989. if templ_7745c5c3_Err != nil {
  990. return templ_7745c5c3_Err
  991. }
  992. if convertSecondsToUnit(data.Seconds) == "minutes" {
  993. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, " selected")
  994. if templ_7745c5c3_Err != nil {
  995. return templ_7745c5c3_Err
  996. }
  997. }
  998. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, ">Minutes</option> <option value=\"hours\"")
  999. if templ_7745c5c3_Err != nil {
  1000. return templ_7745c5c3_Err
  1001. }
  1002. if convertSecondsToUnit(data.Seconds) == "hours" {
  1003. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 94, " selected")
  1004. if templ_7745c5c3_Err != nil {
  1005. return templ_7745c5c3_Err
  1006. }
  1007. }
  1008. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 95, ">Hours</option> <option value=\"days\"")
  1009. if templ_7745c5c3_Err != nil {
  1010. return templ_7745c5c3_Err
  1011. }
  1012. if convertSecondsToUnit(data.Seconds) == "days" {
  1013. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 96, " selected")
  1014. if templ_7745c5c3_Err != nil {
  1015. return templ_7745c5c3_Err
  1016. }
  1017. }
  1018. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, ">Days</option></select></div>")
  1019. if templ_7745c5c3_Err != nil {
  1020. return templ_7745c5c3_Err
  1021. }
  1022. if data.Description != "" {
  1023. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "<div class=\"form-text text-muted\">")
  1024. if templ_7745c5c3_Err != nil {
  1025. return templ_7745c5c3_Err
  1026. }
  1027. var templ_7745c5c3_Var49 string
  1028. templ_7745c5c3_Var49, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  1029. if templ_7745c5c3_Err != nil {
  1030. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 266, Col: 55}
  1031. }
  1032. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var49))
  1033. if templ_7745c5c3_Err != nil {
  1034. return templ_7745c5c3_Err
  1035. }
  1036. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "</div>")
  1037. if templ_7745c5c3_Err != nil {
  1038. return templ_7745c5c3_Err
  1039. }
  1040. }
  1041. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "</div>")
  1042. if templ_7745c5c3_Err != nil {
  1043. return templ_7745c5c3_Err
  1044. }
  1045. return nil
  1046. })
  1047. }
  1048. // Helper functions for duration conversion (used by DurationInputField)
  1049. // Typed conversion functions for protobuf int32 (most common) - EXPORTED
  1050. func ConvertInt32SecondsToDisplayValue(seconds int32) float64 {
  1051. return convertIntSecondsToDisplayValue(int(seconds))
  1052. }
  1053. func GetInt32DisplayUnit(seconds int32) string {
  1054. return getIntDisplayUnit(int(seconds))
  1055. }
  1056. // Typed conversion functions for regular int
  1057. func convertIntSecondsToDisplayValue(seconds int) float64 {
  1058. if seconds == 0 {
  1059. return 0
  1060. }
  1061. // Check if it's evenly divisible by days
  1062. if seconds%(24*3600) == 0 {
  1063. return float64(seconds / (24 * 3600))
  1064. }
  1065. // Check if it's evenly divisible by hours
  1066. if seconds%3600 == 0 {
  1067. return float64(seconds / 3600)
  1068. }
  1069. // Default to minutes
  1070. return float64(seconds / 60)
  1071. }
  1072. func getIntDisplayUnit(seconds int) string {
  1073. if seconds == 0 {
  1074. return "minutes"
  1075. }
  1076. // Check if it's evenly divisible by days
  1077. if seconds%(24*3600) == 0 {
  1078. return "days"
  1079. }
  1080. // Check if it's evenly divisible by hours
  1081. if seconds%3600 == 0 {
  1082. return "hours"
  1083. }
  1084. // Default to minutes
  1085. return "minutes"
  1086. }
  1087. func convertSecondsToUnit(seconds int) string {
  1088. if seconds == 0 {
  1089. return "minutes"
  1090. }
  1091. // Try days first
  1092. if seconds%(24*3600) == 0 && seconds >= 24*3600 {
  1093. return "days"
  1094. }
  1095. // Try hours
  1096. if seconds%3600 == 0 && seconds >= 3600 {
  1097. return "hours"
  1098. }
  1099. // Default to minutes
  1100. return "minutes"
  1101. }
  1102. func convertSecondsToValue(seconds int, unit string) float64 {
  1103. if seconds == 0 {
  1104. return 0
  1105. }
  1106. switch unit {
  1107. case "days":
  1108. return float64(seconds / (24 * 3600))
  1109. case "hours":
  1110. return float64(seconds / 3600)
  1111. case "minutes":
  1112. return float64(seconds / 60)
  1113. default:
  1114. return float64(seconds / 60) // Default to minutes
  1115. }
  1116. }
  1117. // IntervalFieldData represents interval input field data with separate value and unit
  1118. type IntervalFieldData struct {
  1119. FormFieldData
  1120. Seconds int // The interval value in seconds
  1121. }
  1122. // IntervalField renders a Bootstrap interval input with number + unit dropdown (like task config)
  1123. func IntervalField(data IntervalFieldData) templ.Component {
  1124. return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
  1125. templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
  1126. if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
  1127. return templ_7745c5c3_CtxErr
  1128. }
  1129. templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
  1130. if !templ_7745c5c3_IsBuffer {
  1131. defer func() {
  1132. templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
  1133. if templ_7745c5c3_Err == nil {
  1134. templ_7745c5c3_Err = templ_7745c5c3_BufErr
  1135. }
  1136. }()
  1137. }
  1138. ctx = templ.InitializeContext(ctx)
  1139. templ_7745c5c3_Var50 := templ.GetChildren(ctx)
  1140. if templ_7745c5c3_Var50 == nil {
  1141. templ_7745c5c3_Var50 = templ.NopComponent
  1142. }
  1143. ctx = templ.ClearChildren(ctx)
  1144. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "<div class=\"mb-3\"><label for=\"")
  1145. if templ_7745c5c3_Err != nil {
  1146. return templ_7745c5c3_Err
  1147. }
  1148. var templ_7745c5c3_Var51 string
  1149. templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name)
  1150. if templ_7745c5c3_Err != nil {
  1151. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 366, Col: 24}
  1152. }
  1153. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51))
  1154. if templ_7745c5c3_Err != nil {
  1155. return templ_7745c5c3_Err
  1156. }
  1157. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "\" class=\"form-label\">")
  1158. if templ_7745c5c3_Err != nil {
  1159. return templ_7745c5c3_Err
  1160. }
  1161. var templ_7745c5c3_Var52 string
  1162. templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(data.Label)
  1163. if templ_7745c5c3_Err != nil {
  1164. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 367, Col: 15}
  1165. }
  1166. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52))
  1167. if templ_7745c5c3_Err != nil {
  1168. return templ_7745c5c3_Err
  1169. }
  1170. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, " ")
  1171. if templ_7745c5c3_Err != nil {
  1172. return templ_7745c5c3_Err
  1173. }
  1174. if data.Required {
  1175. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "<span class=\"text-danger\">*</span>")
  1176. if templ_7745c5c3_Err != nil {
  1177. return templ_7745c5c3_Err
  1178. }
  1179. }
  1180. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "</label><div class=\"input-group\"><input type=\"number\" class=\"form-control\" id=\"")
  1181. if templ_7745c5c3_Err != nil {
  1182. return templ_7745c5c3_Err
  1183. }
  1184. var templ_7745c5c3_Var53 string
  1185. templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_value")
  1186. if templ_7745c5c3_Err != nil {
  1187. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 376, Col: 29}
  1188. }
  1189. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
  1190. if templ_7745c5c3_Err != nil {
  1191. return templ_7745c5c3_Err
  1192. }
  1193. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "\" name=\"")
  1194. if templ_7745c5c3_Err != nil {
  1195. return templ_7745c5c3_Err
  1196. }
  1197. var templ_7745c5c3_Var54 string
  1198. templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_value")
  1199. if templ_7745c5c3_Err != nil {
  1200. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 377, Col: 31}
  1201. }
  1202. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54))
  1203. if templ_7745c5c3_Err != nil {
  1204. return templ_7745c5c3_Err
  1205. }
  1206. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "\" value=\"")
  1207. if templ_7745c5c3_Err != nil {
  1208. return templ_7745c5c3_Err
  1209. }
  1210. var templ_7745c5c3_Var55 string
  1211. templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.0f", convertSecondsToValue(data.Seconds, convertSecondsToUnit(data.Seconds))))
  1212. if templ_7745c5c3_Err != nil {
  1213. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 378, Col: 104}
  1214. }
  1215. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55))
  1216. if templ_7745c5c3_Err != nil {
  1217. return templ_7745c5c3_Err
  1218. }
  1219. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 108, "\" step=\"1\" min=\"1\"")
  1220. if templ_7745c5c3_Err != nil {
  1221. return templ_7745c5c3_Err
  1222. }
  1223. if data.Required {
  1224. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 109, " required")
  1225. if templ_7745c5c3_Err != nil {
  1226. return templ_7745c5c3_Err
  1227. }
  1228. }
  1229. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "> <select class=\"form-select\" id=\"")
  1230. if templ_7745c5c3_Err != nil {
  1231. return templ_7745c5c3_Err
  1232. }
  1233. var templ_7745c5c3_Var56 string
  1234. templ_7745c5c3_Var56, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_unit")
  1235. if templ_7745c5c3_Err != nil {
  1236. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 387, Col: 28}
  1237. }
  1238. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var56))
  1239. if templ_7745c5c3_Err != nil {
  1240. return templ_7745c5c3_Err
  1241. }
  1242. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "\" name=\"")
  1243. if templ_7745c5c3_Err != nil {
  1244. return templ_7745c5c3_Err
  1245. }
  1246. var templ_7745c5c3_Var57 string
  1247. templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(data.Name + "_unit")
  1248. if templ_7745c5c3_Err != nil {
  1249. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 388, Col: 30}
  1250. }
  1251. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57))
  1252. if templ_7745c5c3_Err != nil {
  1253. return templ_7745c5c3_Err
  1254. }
  1255. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, "\" style=\"max-width: 120px;\"")
  1256. if templ_7745c5c3_Err != nil {
  1257. return templ_7745c5c3_Err
  1258. }
  1259. if data.Required {
  1260. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, " required")
  1261. if templ_7745c5c3_Err != nil {
  1262. return templ_7745c5c3_Err
  1263. }
  1264. }
  1265. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "><option value=\"minutes\"")
  1266. if templ_7745c5c3_Err != nil {
  1267. return templ_7745c5c3_Err
  1268. }
  1269. if convertSecondsToUnit(data.Seconds) == "minutes" {
  1270. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, " selected")
  1271. if templ_7745c5c3_Err != nil {
  1272. return templ_7745c5c3_Err
  1273. }
  1274. }
  1275. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, ">Minutes</option> <option value=\"hours\"")
  1276. if templ_7745c5c3_Err != nil {
  1277. return templ_7745c5c3_Err
  1278. }
  1279. if convertSecondsToUnit(data.Seconds) == "hours" {
  1280. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, " selected")
  1281. if templ_7745c5c3_Err != nil {
  1282. return templ_7745c5c3_Err
  1283. }
  1284. }
  1285. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, ">Hours</option> <option value=\"days\"")
  1286. if templ_7745c5c3_Err != nil {
  1287. return templ_7745c5c3_Err
  1288. }
  1289. if convertSecondsToUnit(data.Seconds) == "days" {
  1290. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, " selected")
  1291. if templ_7745c5c3_Err != nil {
  1292. return templ_7745c5c3_Err
  1293. }
  1294. }
  1295. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, ">Days</option></select></div>")
  1296. if templ_7745c5c3_Err != nil {
  1297. return templ_7745c5c3_Err
  1298. }
  1299. if data.Description != "" {
  1300. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 121, "<div class=\"form-text text-muted\">")
  1301. if templ_7745c5c3_Err != nil {
  1302. return templ_7745c5c3_Err
  1303. }
  1304. var templ_7745c5c3_Var58 string
  1305. templ_7745c5c3_Var58, templ_7745c5c3_Err = templ.JoinStringErrs(data.Description)
  1306. if templ_7745c5c3_Err != nil {
  1307. return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/components/form_fields.templ`, Line: 421, Col: 55}
  1308. }
  1309. _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var58))
  1310. if templ_7745c5c3_Err != nil {
  1311. return templ_7745c5c3_Err
  1312. }
  1313. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 122, "</div>")
  1314. if templ_7745c5c3_Err != nil {
  1315. return templ_7745c5c3_Err
  1316. }
  1317. }
  1318. templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "</div>")
  1319. if templ_7745c5c3_Err != nil {
  1320. return templ_7745c5c3_Err
  1321. }
  1322. return nil
  1323. })
  1324. }
  1325. var _ = templruntime.GeneratedTemplate