Skip to content

Commit b3f7e25

Browse files
admin: TaxZone2Zone delete
1 parent c03bfda commit b3f7e25

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

src/main/java/org/woehlke/greenshop/admin/AdminLocationTaxesController.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,26 @@ public String taxZoneInsertSave(@PathVariable long taxZoneId,
285285
}
286286
}
287287

288+
@RequestMapping(value = "/admin/taxZone/{taxZoneId}/zone/{zoneId}/delete", method = RequestMethod.GET)
289+
public String taxZoneWithZoneIdDeleteForm(@PathVariable long taxZoneId, @PathVariable long zoneId,Model model){
290+
int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();
291+
model.addAttribute("menuCategory",menuCategory);
292+
TaxZone thisTaxZone = adminService.findTaxZoneById(taxZoneId);
293+
model.addAttribute("thisTaxZone",thisTaxZone);
294+
List<TaxZone2Zone> zones = adminService.findZonesByTaxZone(thisTaxZone);
295+
model.addAttribute("zones",zones);
296+
TaxZone2Zone thisZone = adminService.findTaxZone2ZoneById(zoneId);
297+
model.addAttribute("thisZone",thisZone);
298+
return "admin/taxZoneDeleteForm";
299+
}
300+
301+
@RequestMapping(value = "/admin/taxZone/{taxZoneId}/zone/{zoneId}/delete", method = RequestMethod.POST)
302+
public String taxZoneWithZoneIdDeletePerform(@PathVariable long taxZoneId, @PathVariable long zoneId,Model model){
303+
TaxZone2Zone thisZone = adminService.findTaxZone2ZoneById(zoneId);
304+
adminService.deleteTaxZone2Zone(thisZone);
305+
return "redirect:/admin/taxZone/"+taxZoneId;
306+
}
307+
288308
@RequestMapping(value = "/admin/taxClasses", method = RequestMethod.GET)
289309
public String taxClasses(Model model){
290310
int menuCategory = AdminMenuCategory.LOCATION_TAXES.ordinal();

src/main/java/org/woehlke/greenshop/admin/AdminService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,6 @@ public interface AdminService extends UserDetailsService {
8585
void updateTaxZone(TaxZone thisTaxZone);
8686

8787
void createTaxZone2Zone(TaxZone2Zone newTaxZone2Zone);
88+
89+
void deleteTaxZone2Zone(TaxZone2Zone thisZone);
8890
}

src/main/java/org/woehlke/greenshop/admin/AdminServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,10 @@ public void updateTaxZone(TaxZone thisTaxZone) {
356356
public void createTaxZone2Zone(TaxZone2Zone newTaxZone2Zone) {
357357
taxZone2ZoneRepository.save(newTaxZone2Zone);
358358
}
359+
360+
@Override
361+
@Transactional(readOnly=false,propagation=Propagation.REQUIRES_NEW)
362+
public void deleteTaxZone2Zone(TaxZone2Zone thisZone) {
363+
taxZone2ZoneRepository.delete(thisZone);
364+
}
359365
}
Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,82 @@
11
<%@ include file="/WEB-INF/layout/taglibs.jsp"%>
2-
<h1>Delete</h1>
2+
<table border="0" width="100%" cellspacing="0" cellpadding="2">
3+
<tr>
4+
<td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
5+
<tr>
6+
<td class="pageHeading">Tax Zones</td>
7+
<td class="pageHeading" align="right"><img src="resources/admin/images/pixel_trans.gif" border="0" alt="" width="57" height="40" /></td>
8+
</tr>
9+
</table></td>
10+
</tr>
11+
<tr>
12+
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
13+
<tr>
14+
<td valign="top">
15+
<table border="0" width="100%" cellspacing="0" cellpadding="2">
16+
<c:forEach items="${zones}" var="zone">
17+
<c:if test="${zone.id == thisZone.id}">
18+
<tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='<c:url value="/admin/taxZone/${thisTaxZone.id}/zone/${zone.id}"/>'">
19+
<td class="dataTableContent">${zone.zoneCountry.name}</td>
20+
<c:choose>
21+
<c:when test="${zone.zone == null}">
22+
<td class="dataTableContent">All Zones</td>
23+
</c:when>
24+
<c:otherwise>
25+
<td class="dataTableContent"><c:out value="${zone.zone.name}"/></td>
26+
</c:otherwise>
27+
</c:choose>
28+
<td class="dataTableContent" align="right"><img src="resources/admin/images/icon_arrow_right.gif" border="0" alt="" />&nbsp;</td>
29+
</tr>
30+
</c:if>
31+
<c:if test="${zone.id != thisZone.id}">
32+
<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href='<c:url value="/admin/taxZone/${thisTaxZone.id}/zone/${zone.id}"/>'">
33+
<td class="dataTableContent">${zone.zoneCountry.name}</td>
34+
<c:choose>
35+
<c:when test="${zone.zone == null}">
36+
<td class="dataTableContent">All Zones</td>
37+
</c:when>
38+
<c:otherwise>
39+
<td class="dataTableContent"><c:out value="${zone.zone.name}"/></td>
40+
</c:otherwise>
41+
</c:choose>
42+
<td class="dataTableContent" align="right"><a href="<c:url value="/admin/taxZone/${thisTaxZone.id}/zone/${zone.id}"/>"><img src="resources/admin/images/icon_info.gif" border="0" alt="Info" title="Info" /></a>&nbsp;</td>
43+
</tr>
44+
</c:if>
45+
</c:forEach>
46+
<tr>
47+
<td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
48+
<tr>
49+
<td class="smallText" valign="top">Displaying <strong>1</strong> to <strong>5</strong> (of <strong>5</strong> countries)</td>
50+
<td class="smallText" align="right">Page 1 of 1</td>
51+
</tr>
52+
</table></td>
53+
</tr>
54+
<tr>
55+
<td class="smallText" align="right" colspan="3"></td>
56+
</tr>
57+
</table>
58+
</td>
59+
<td width="25%" valign="top">
60+
<table border="0" width="100%" cellspacing="0" cellpadding="2">
61+
<tr class="infoBoxHeading">
62+
<td class="infoBoxHeading"><strong>Delete Sub Zone</strong></td>
63+
</tr>
64+
</table>
65+
<form:form method="post">
66+
<table border="0" width="100%" cellspacing="0" cellpadding="2">
67+
<tr>
68+
<td class="infoBoxContent">Are you sure you want to delete this sub zone?</td>
69+
</tr>
70+
<tr>
71+
<td class="infoBoxContent"><br /><strong>${thisZone.zoneCountry.name}</strong></td>
72+
</tr>
73+
<tr>
74+
<td align="center" class="infoBoxContent"><br /><span class="tdbLink"><button id="tdb1" type="submit">Delete</button></span><script type="text/javascript">$("#tdb1").button({icons:{primary:"ui-icon-trash"}}).addClass("ui-priority-primary").parent().removeClass("tdbLink");</script><span class="tdbLink"><a id="tdb2" href="<c:url value="/admin/taxZone/${thisTaxZone.id}/zone/${thisZone.id}"/>">Cancel</a></span><script type="text/javascript">$("#tdb2").button({icons:{primary:"ui-icon-close"}}).addClass("ui-priority-secondary").parent().removeClass("tdbLink");</script></td>
75+
</tr>
76+
</table>
77+
</form:form>
78+
</td>
79+
</tr>
80+
</table></td>
81+
</tr>
82+
</table>

0 commit comments

Comments
 (0)