Skip to content

Commit 12bf1ad

Browse files
committed
/series/import/request/{id}: hide/disable some fields for completed requests.
Fix #750
1 parent 30bf458 commit 12bf1ad

File tree

2 files changed

+51
-45
lines changed

2 files changed

+51
-45
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ <h3 th:text="${#strings.capitalize(header)}">
9191
</dl>
9292
</div>
9393

94-
<div class="col-sm-4 col-sm-offset-4" th:if="${showForm}">
94+
<div class="col-sm-4 col-sm-offset-4" th:if="${showForm}" th:with="disabled=${request.seriesId != null}">
9595
<h3 th:text="#{t_gathered_data}">
9696
Gathered data
9797
</h3>
9898

99-
<div class="hint text-center">
99+
<div class="hint text-center" th:unless="${disabled}">
100100
<small th:with="redAsterisk='&lt;span class=&quot;required_field&quot;&gt;*&lt;/span&gt;'">
101101
<span class="hint_item" th:utext="#{t_required_fields_legend(${redAsterisk})}">
102102
All fields marked by asterisk (<span class="required_field">*</span>) must be filled.
@@ -119,10 +119,10 @@ <h3 th:text="#{t_gathered_data}">
119119
<label for="category" class="control-label" th:text="#{t_category}">
120120
Category
121121
</label>
122-
<span class="required_field">*</span>
122+
<span class="required_field" th:unless="${disabled}">*</span>
123123
</th>
124124
<td>
125-
<select id="category" name="category" class="form-control" required="required">
125+
<select id="category" name="category" class="form-control" required="required" th:disabled="${disabled}">
126126
<option value="" th:text="#{t_not_chosen}">Not chosen</option>
127127
<!--/*/
128128
<th:block th:each="category : ${categories}">
@@ -164,7 +164,7 @@ <h3 th:text="#{t_gathered_data}">
164164
</label>
165165
</th>
166166
<td>
167-
<select id="country" name="country" class="form-control">
167+
<select id="country" name="country" class="form-control" th:disabled="${disabled}">
168168
<option value="" th:text="#{t_not_chosen}">Not chosen</option>
169169
<!--/*/
170170
<option th:each="country : ${countries}"
@@ -189,7 +189,7 @@ <h3 th:text="#{t_gathered_data}">
189189
</td>
190190
</tr>
191191

192-
<tr th:classappend="${#fields.hasErrors('quantity') ? 'has-error' : ''}">
192+
<tr th:unless="${disabled}" th:classappend="${#fields.hasErrors('quantity') ? 'has-error' : ''}">
193193
<th>
194194
<label for="quantity" class="control-label" th:text="#{t_quantity}">
195195
Quantity
@@ -215,7 +215,7 @@ <h3 th:text="#{t_gathered_data}">
215215
</td>
216216
</tr>
217217

218-
<tr th:classappend="${#fields.hasErrors('perforated') ? 'has-error' : ''}">
218+
<tr th:unless="${disabled}" th:classappend="${#fields.hasErrors('perforated') ? 'has-error' : ''}">
219219
<th>
220220
<label for="perforated" class="control-label" th:text="#{t_perforated}">
221221
Perforated
@@ -241,15 +241,16 @@ <h3 th:text="#{t_gathered_data}">
241241
<label for="image-url" class="control-label" th:text="#{t_image_url}">
242242
Image URL
243243
</label>
244-
<span class="required_field">*</span>
244+
<span class="required_field" th:unless="${disabled}">*</span>
245245
</th>
246246
<td>
247247
<input id="image-url"
248248
type="url"
249249
class="form-control"
250250
required="required"
251251
value="http://example.com/my-first-series.jpg"
252-
th:field="*{imageUrl}" />
252+
th:field="*{imageUrl}"
253+
th:disabled="${disabled}" />
253254
<!--/*/
254255
<span id="image-url.errors"
255256
class="help-block"
@@ -272,7 +273,7 @@ <h3 th:text="#{t_gathered_data}">
272273
</label>
273274
</th>
274275
<td>
275-
<select class="form-control" th:field="*{year}" id="year">
276+
<select class="form-control" th:field="*{year}" id="year" th:disabled="${disabled}">
276277
<option value="" th:text="#{t_year}">Year</option>
277278
<!--/*/
278279
<option th:each="year : ${years}" th:value="${year.key}" th:text="${year.value}"></option>
@@ -293,16 +294,15 @@ <h3 th:text="#{t_gathered_data}">
293294
</td>
294295
</tr>
295296

296-
<tr>
297+
<tr th:unless="${disabled}">
297298
<td></td>
298299
<td>
299300
<input
300301
id="create-series-btn"
301302
type="submit"
302303
class="btn btn-primary"
303304
value="Import"
304-
th:value="#{t_import}"
305-
th:disabled="${request.seriesId != null}" />
305+
th:value="#{t_import}" />
306306
</td>
307307
</tr>
308308
</table>

src/test/robotframework/series/import/request-logic.robot

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,46 @@ Force Tags series import-series logic
99

1010
*** Test Cases ***
1111
Import series from an external site (in English, use category, country and date locators)
12-
[Documentation] Verify import from a page in English and with different locators
13-
Input Text id=url http://127.0.0.1:8080/series/2?lang=en
14-
Submit Form id=import-series-form
15-
${requestLocation}= Get Location
16-
Should Match Regexp ${requestLocation} /series/import/request/\\d+
17-
${category}= Get Selected List Label id=category
18-
${country}= Get Selected List Label id=country
12+
[Documentation] Verify import from a page in English and with different locators
13+
Input Text id=url http://127.0.0.1:8080/series/2?lang=en
14+
Submit Form id=import-series-form
15+
${requestLocation}= Get Location
16+
Should Match Regexp ${requestLocation} /series/import/request/\\d+
17+
${category}= Get Selected List Label id=category
18+
${country}= Get Selected List Label id=country
1919
# We can't use "Textfield Value Should Be" because it causes NPE on inputs of type url/number:
2020
# https://github.com/MarkusBernhardt/robotframework-selenium2library-java/issues/92
21-
${quantity}= Get Value id=quantity
22-
${imageUrl}= Get Value id=image-url
23-
${year}= Get Selected List Label id=year
24-
Element Text Should Be id=request-url http://127.0.0.1:8080/series/2?lang=en
25-
Element Text Should Be id=request-status ParsingSucceeded
26-
Should Be Equal ${category} Prehistoric animals
27-
Should Be Equal ${country} Italy
28-
Should Be Empty ${quantity}
29-
Checkbox Should Be Selected id=perforated
30-
Should Be Equal ${imageUrl} http://127.0.0.1:8080/image/1
31-
Should Be Equal ${year} 2000
32-
Input Text id=quantity 1
33-
Submit Form id=create-series-form
34-
${seriesLocation}= Get Location
35-
Should Match Regexp ${seriesLocation} /series/\\d+
36-
Element Text Should Be id=category_name Prehistoric animals
37-
Element Text Should Be id=country_name Italy
38-
Element Text Should Be id=issue_date 2000
39-
Element Text Should Be id=quantity 1
40-
Element Text Should Be id=perforated Yes
41-
Page Should Contain Image id=series-image-1
42-
Go To ${requestLocation}
43-
Element Text Should Be id=request-status ImportSucceeded
44-
Element Should Be Disabled id=create-series-btn
45-
Page Should Contain Link link=${seriesLocation}
21+
${quantity}= Get Value id=quantity
22+
${imageUrl}= Get Value id=image-url
23+
${year}= Get Selected List Label id=year
24+
Element Text Should Be id=request-url http://127.0.0.1:8080/series/2?lang=en
25+
Element Text Should Be id=request-status ParsingSucceeded
26+
Should Be Equal ${category} Prehistoric animals
27+
Should Be Equal ${country} Italy
28+
Should Be Empty ${quantity}
29+
Checkbox Should Be Selected id=perforated
30+
Should Be Equal ${imageUrl} http://127.0.0.1:8080/image/1
31+
Should Be Equal ${year} 2000
32+
Input Text id=quantity 1
33+
Submit Form id=create-series-form
34+
${seriesLocation}= Get Location
35+
Should Match Regexp ${seriesLocation} /series/\\d+
36+
Element Text Should Be id=category_name Prehistoric animals
37+
Element Text Should Be id=country_name Italy
38+
Element Text Should Be id=issue_date 2000
39+
Element Text Should Be id=quantity 1
40+
Element Text Should Be id=perforated Yes
41+
Page Should Contain Image id=series-image-1
42+
Go To ${requestLocation}
43+
Element Text Should Be id=request-status ImportSucceeded
44+
Element Should Be Disabled id=category
45+
Element Should Be Disabled id=country
46+
Page Should Not Contain Element id=quantity
47+
Page Should Not Contain Element id=perforated
48+
Element Should Be Disabled id=image-url
49+
Element Should Be Disabled id=year
50+
Page Should Not Contain Element id=create-series-btn
51+
Page Should Contain Link link=${seriesLocation}
4652

4753
Import series from an external site (in Russian, use description locator)
4854
[Documentation] Verify import from a page in Russian and shared locator

0 commit comments

Comments
 (0)