Skip to content

Commit 4877c26

Browse files
committed
Pre-select category/country on create series page.
1 parent 3708eac commit 4877c26

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

src/main/java/ru/mystamps/web/Url.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public final class Url {
4747
public static final String ACTIVATE_ACCOUNT_PAGE = "/account/activate";
4848
public static final String ACTIVATE_ACCOUNT_PAGE_WITH_KEY = "/account/activate/key/{key}";
4949

50+
// CheckStyle: ignore LineLength for next 3 lines
5051
public static final String ADD_SERIES_PAGE = "/series/add";
52+
public static final String ADD_SERIES_WITH_CATEGORY_PAGE = "/series/add/category/{id}";
53+
public static final String ADD_SERIES_WITH_COUNTRY_PAGE = "/series/add/country/{id}";
5154
public static final String INFO_SERIES_PAGE = "/series/{id}";
5255
public static final String ADD_IMAGE_SERIES_PAGE = "/series/{id}/image";
5356

@@ -112,6 +115,8 @@ public static Map<String, String> asMap(boolean serveContentFromSingleHost) {
112115
map.put("ACTIVATE_ACCOUNT_PAGE", ACTIVATE_ACCOUNT_PAGE);
113116
map.put("REGISTRATION_PAGE", REGISTRATION_PAGE);
114117
map.put("ADD_SERIES_PAGE", ADD_SERIES_PAGE);
118+
map.put("ADD_SERIES_WITH_CATEGORY_PAGE", ADD_SERIES_WITH_CATEGORY_PAGE);
119+
map.put("ADD_SERIES_WITH_COUNTRY_PAGE", ADD_SERIES_WITH_COUNTRY_PAGE);
115120
map.put("INFO_SERIES_PAGE", INFO_SERIES_PAGE);
116121
map.put("ADD_IMAGE_SERIES_PAGE", ADD_IMAGE_SERIES_PAGE);
117122
map.put("ADD_CATEGORY_PAGE", ADD_CATEGORY_PAGE);

src/main/java/ru/mystamps/web/controller/SeriesController.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@
4444
import lombok.RequiredArgsConstructor;
4545

4646
import ru.mystamps.web.Url;
47+
import ru.mystamps.web.entity.Category;
4748
import ru.mystamps.web.entity.Collection;
49+
import ru.mystamps.web.entity.Country;
50+
import ru.mystamps.web.entity.Series;
4851
import ru.mystamps.web.entity.User;
4952
import ru.mystamps.web.model.AddImageForm;
5053
import ru.mystamps.web.model.AddSeriesForm;
5154
import ru.mystamps.web.model.AddSeriesForm.ScottCatalogChecks;
5255
import ru.mystamps.web.model.AddSeriesForm.GibbonsCatalogChecks;
5356
import ru.mystamps.web.model.AddSeriesForm.MichelCatalogChecks;
5457
import ru.mystamps.web.model.AddSeriesForm.YvertCatalogChecks;
55-
import ru.mystamps.web.entity.Series;
5658
import ru.mystamps.web.service.CategoryService;
5759
import ru.mystamps.web.service.CollectionService;
5860
import ru.mystamps.web.service.CountryService;
@@ -120,6 +122,30 @@ public AddSeriesForm showForm() {
120122
return addSeriesForm;
121123
}
122124

125+
@RequestMapping(Url.ADD_SERIES_WITH_CATEGORY_PAGE)
126+
public String showFormWithCategory(@PathVariable("id") Category category, Model model) {
127+
128+
AddSeriesForm form = new AddSeriesForm();
129+
form.setPerforated(true);
130+
form.setCategory(category);
131+
132+
model.addAttribute("addSeriesForm", form);
133+
134+
return "series/add";
135+
}
136+
137+
@RequestMapping(Url.ADD_SERIES_WITH_COUNTRY_PAGE)
138+
public String showFormWithCountry(@PathVariable("id") Country country, Model model) {
139+
140+
AddSeriesForm form = new AddSeriesForm();
141+
form.setPerforated(true);
142+
form.setCountry(country);
143+
144+
model.addAttribute("addSeriesForm", form);
145+
146+
return "series/add";
147+
}
148+
123149
@RequestMapping(value = Url.ADD_SERIES_PAGE, method = RequestMethod.POST)
124150
public String processInput(
125151
@Validated({

src/main/webapp/WEB-INF/views/category/info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h3 th:text="${category.getLocalizedName(#locale)}">
5757

5858
<!--/*/
5959
<div class="row" th:if="${justAddedCategory}">
60-
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_category_just_added(@{${ADD_SERIES_PAGE}})}">
60+
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_category_just_added(@{${ADD_SERIES_WITH_CATEGORY_PAGE}(id=${category.id})})}">
6161
Category has been added.<br />
6262
Now you could <a href="../series/add.html" class="alert-link">proceed with creating series</a>.
6363
</div>

src/main/webapp/WEB-INF/views/country/info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h3 th:text="${country.getLocalizedName(#locale)}">
5757

5858
<!--/*/
5959
<div class="row" th:if="${justAddedCountry}">
60-
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_country_just_added(@{${ADD_SERIES_PAGE}})}">
60+
<div class="alert alert-success text-center col-sm-4 col-sm-offset-4" th:utext="#{t_country_just_added(@{${ADD_SERIES_WITH_COUNTRY_PAGE}(id=${country.id})})}">
6161
Country has been added.<br />
6262
Now you could <a href="../series/add.html" class="alert-link">proceed with creating series</a>.
6363
</div>

0 commit comments

Comments
 (0)