|
49 | 49 | </div> |
50 | 50 |
|
51 | 51 | <!-- Add Button --> |
52 | | - <button[[if ne (buttonClass .CSSFramework "primary") ""]] class="[[buttonClass .CSSFramework "primary"]]"[[end]] lvt-click="open_add"> |
| 52 | + <button[[if ne (buttonClass .CSSFramework "primary") ""]] class="[[buttonClass .CSSFramework "primary"]]"[[end]] lvt-modal-open="add-modal"> |
53 | 53 | + Add [[.ResourceName]] |
54 | 54 | </button> |
55 | 55 | </div> |
|
60 | 60 | [[- end]] |
61 | 61 |
|
62 | 62 | <!-- Add Modal --> |
63 | | - {{if .IsAdding}} |
64 | | - <div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000;"> |
| 63 | + <div id="add-modal" hidden aria-hidden="true" role="dialog" data-modal-backdrop data-modal-id="add-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000;"> |
65 | 64 | [[- if needsArticle .CSSFramework]] |
66 | 65 | <article style="max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;"> |
67 | 66 | [[- else if ne (boxClass .CSSFramework) ""]] |
68 | 67 | <div class="[[boxClass .CSSFramework]]" style="max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto; background: white;"> |
69 | 68 | [[- else]] |
70 | 69 | <div style="background: white; border-radius: 8px; padding: 2rem; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;"> |
71 | 70 | [[- end]] |
72 | | - <h2[[if ne (subtitleClass .CSSFramework) ""]] class="[[subtitleClass .CSSFramework]]"[[end]]>Add New [[.ResourceName]]</h2> |
| 71 | + <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;"> |
| 72 | + <h2[[if ne (subtitleClass .CSSFramework) ""]] class="[[subtitleClass .CSSFramework]]"[[end]] style="margin: 0;">Add New [[.ResourceName]]</h2> |
| 73 | + <button type="button" lvt-modal-close="add-modal" style="background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;" aria-label="Close">×</button> |
| 74 | + </div> |
73 | 75 |
|
74 | 76 | {{if .lvt.HasError "_general"}} |
75 | 77 | <div style="margin-bottom: 1rem; padding: 0.75rem; background-color: #fee; border: 1px solid #fcc; border-radius: 0.25rem; color: #c00;"> |
|
81 | 83 | [[- range .Fields]] |
82 | 84 | <div[[if ne (fieldClass $.CSSFramework) ""]] class="[[fieldClass $.CSSFramework]]"[[end]]> |
83 | 85 | <label[[if ne (labelClass $.CSSFramework) ""]] class="[[labelClass $.CSSFramework]]"[[end]]>[[.Name | title]]</label> |
84 | | -[[- if eq .GoType "string"]] |
| 86 | + [[/* Use textarea for text/longtext types, input for regular strings */]] |
| 87 | +[[- if .IsTextarea]] |
| 88 | + <textarea[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] name="[[.Name]]" placeholder="Enter [[.Name]]" rows="5" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}></textarea> |
| 89 | +[[- else if eq .GoType "string"]] |
85 | 90 | <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="text" name="[[.Name]]" placeholder="Enter [[.Name]]" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
86 | 91 | [[- else if eq .GoType "int64"]] |
87 | 92 | <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="number" name="[[.Name]]" placeholder="Enter [[.Name]]" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
|
100 | 105 | [[- end]] |
101 | 106 | <div[[if ne (fieldClass .CSSFramework) ""]] class="[[fieldClass .CSSFramework]]"[[end]]> |
102 | 107 | <button[[if ne (buttonClass .CSSFramework "primary") ""]] class="[[buttonClass .CSSFramework "primary"]]"[[end]] type="submit" lvt-disable-with="Adding...">Add [[.ResourceName]]</button> |
103 | | - <button[[if ne (buttonClass .CSSFramework "secondary") ""]] class="[[buttonClass .CSSFramework "secondary"]]"[[end]] type="button" lvt-click="cancel_add">Cancel</button> |
| 108 | + <button[[if ne (buttonClass .CSSFramework "secondary") ""]] class="[[buttonClass .CSSFramework "secondary"]]"[[end]] type="button" lvt-modal-close="add-modal">Cancel</button> |
104 | 109 | </div> |
105 | 110 | </form> |
106 | 111 | [[- if needsArticle .CSSFramework]] |
|
109 | 114 | </div> |
110 | 115 | [[- end]] |
111 | 116 | </div> |
112 | | - {{end}} |
113 | 117 |
|
114 | 118 | <!-- Edit Modal --> |
115 | 119 | {{if ne .EditingID 0}} |
|
121 | 125 | [[- else]] |
122 | 126 | <div style="background: white; border-radius: 8px; padding: 2rem; max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;"> |
123 | 127 | [[- end]] |
124 | | - <h2[[if ne (subtitleClass .CSSFramework) ""]] class="[[subtitleClass .CSSFramework]]"[[end]]>Edit [[.ResourceName]]</h2> |
| 128 | + <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;"> |
| 129 | + <h2[[if ne (subtitleClass .CSSFramework) ""]] class="[[subtitleClass .CSSFramework]]"[[end]] style="margin: 0;">Edit [[.ResourceName]]</h2> |
| 130 | + <button type="button" lvt-click="cancel_edit" style="background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;" aria-label="Close">×</button> |
| 131 | + </div> |
125 | 132 |
|
126 | 133 | {{if .lvt.HasError "_general"}} |
127 | 134 | <div style="margin-bottom: 1rem; padding: 0.75rem; background-color: #fee; border: 1px solid #fcc; border-radius: 0.25rem; color: #c00;"> |
|
134 | 141 | [[- range .Fields]] |
135 | 142 | <div[[if ne (fieldClass $.CSSFramework) ""]] class="[[fieldClass $.CSSFramework]]"[[end]]> |
136 | 143 | <label[[if ne (labelClass $.CSSFramework) ""]] class="[[labelClass $.CSSFramework]]"[[end]]>[[.Name | title]]</label> |
137 | | -[[- if eq .GoType "string"]] |
138 | | - <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="text" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | title]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
| 144 | +[[- if .IsTextarea]] |
| 145 | + <textarea[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] name="[[.Name]]" placeholder="Enter [[.Name]]" rows="5" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}>{{.Editing[[$.ResourceName]].[[.Name | camelCase]]}}</textarea> |
| 146 | +[[- else if eq .GoType "string"]] |
| 147 | + <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="text" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | camelCase]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
139 | 148 | [[- else if eq .GoType "int64"]] |
140 | | - <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="number" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | title]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
| 149 | + <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="number" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | camelCase]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
141 | 150 | [[- else if eq .GoType "bool"]] |
142 | 151 | <label[[if ne (checkboxClass $.CSSFramework) ""]] class="[[checkboxClass $.CSSFramework]]"[[end]]> |
143 | | - <input type="checkbox" name="[[.Name]]" value="true" {{if .Editing[[$.ResourceName]].[[.Name | title]]}}checked{{end}} {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
| 152 | + <input type="checkbox" name="[[.Name]]" value="true" {{if .Editing[[$.ResourceName]].[[.Name | camelCase]]}}checked{{end}} {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
144 | 153 | [[.Name | title]] |
145 | 154 | </label> |
146 | 155 | [[- else if eq .GoType "float64"]] |
147 | | - <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="number" step="0.01" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | title]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
| 156 | + <input[[if ne (inputClass $.CSSFramework) ""]] class="[[inputClass $.CSSFramework]]"[[end]] type="number" step="0.01" name="[[.Name]]" placeholder="Enter [[.Name]]" value="{{.Editing[[$.ResourceName]].[[.Name | camelCase]]}}" required {{if .lvt.HasError "[[.Name]]"}}aria-invalid="true"{{end}}> |
148 | 157 | [[- end]] |
149 | 158 | {{if .lvt.HasError "[[.Name]]"}} |
150 | 159 | <small style="color: #c00; font-size: 0.875rem;">{{.lvt.Error "[[.Name]]"}}</small> |
|
0 commit comments