Skip to content

Commit b44fe3a

Browse files
committed
refactor: use CSS for marking required fields (handle conditional logic)
1 parent 8017a28 commit b44fe3a

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/main/webapp/WEB-INF/views/series/add.html

+5-7
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,11 @@ <h3 th:text="${#strings.capitalize(add_series)}">
233233
</div>
234234

235235
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('uploadedImage') ? 'has-error' : ''}">
236-
<label for="image" class="control-label col-sm-3">
237-
<span th:remove="tag" th:text="#{t_image}">
238-
Image
239-
</span>
240-
<!--/*/
241-
<span class="required_field" th:if="${not #authorization.expression('hasAuthority(''DOWNLOAD_IMAGE'')')}">*</span>
242-
/*/-->
236+
<label for="image"
237+
class="control-label col-sm-3"
238+
th:classappend="${#authorization.expression('hasAuthority(''DOWNLOAD_IMAGE'')') ? '' : 'required-field'}"
239+
th:text="#{t_image}">
240+
Image
243241
</label>
244242
<div class="col-sm-7">
245243
<input id="image"

src/main/webapp/WEB-INF/views/series/import/info.html

+8-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ <h3 th:text="#{t_gathered_data}">
125125

126126
<tr th:if="${not disabled or importSeriesForm.category != null}" th:classappend="${#fields.hasErrors('category') ? 'has-error' : ''}">
127127
<th>
128-
<label for="category" class="control-label" th:text="#{t_category}">
128+
<label for="category"
129+
class="control-label"
130+
th:classappend="${disabled ? '' : 'required-field'}"
131+
th:text="#{t_category}">
129132
Category
130133
</label>
131-
<span class="required_field" th:unless="${disabled}">*</span>
132134
</th>
133135
<td>
134136
<select id="category" name="category" class="form-control" required="required" th:disabled="${disabled}">
@@ -246,10 +248,12 @@ <h3 th:text="#{t_gathered_data}">
246248

247249
<tr th:classappend="${#fields.hasErrors('imageUrl') or #fields.hasErrors('downloadedImage') ? 'has-error' : ''}">
248250
<th>
249-
<label for="image-url" class="control-label" th:text="#{t_image_url}">
251+
<label for="image-url"
252+
class="control-label"
253+
th:classappend="${disabled ? '' : 'required-field'}"
254+
th:text="#{t_image_url}">
250255
Image URL
251256
</label>
252-
<span class="required_field" th:unless="${disabled}">*</span>
253257
</th>
254258
<td>
255259
<input id="image-url"

0 commit comments

Comments
 (0)