keep filter on table wide inserts

This commit is contained in:
Jottyfan 2022-10-22 16:13:35 +02:00
parent 230cbc5d00
commit 71cc5d8565
3 changed files with 24 additions and 6 deletions

View File

@ -18,7 +18,7 @@ apply plugin: 'war'
apply plugin: 'application'
group = 'de.jottyfan.camporganizer'
version = '0.0.7'
version = '0.0.8'
sourceCompatibility = 17
mainClassName = "de.jottyfan.camporganizer.Main"

View File

@ -3,6 +3,8 @@ package de.jottyfan.camporganizer.module.business.bookings;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@ -10,10 +12,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import de.jottyfan.camporganizer.module.business.bookings.impl.AddPaymentBean;
import de.jottyfan.camporganizer.module.business.bookings.impl.BookerBean;
import de.jottyfan.camporganizer.module.business.business.IBusinessService;
import de.jottyfan.camporganizer.module.business.bookings.impl.AddPaymentBean;
/**
*
@ -22,6 +25,7 @@ import de.jottyfan.camporganizer.module.business.bookings.impl.AddPaymentBean;
*/
@Controller
public class BookingsController {
private static final Logger LOGGER = LogManager.getLogger(BookingsController.class);
@Autowired
private HttpServletRequest request;
@ -55,9 +59,11 @@ public class BookingsController {
@PostMapping("/business/bookings/payment/{id}")
@RolesAllowed({"business_booking"})
public String addBooking(Model model, @ModelAttribute AddPaymentBean bean, @PathVariable Integer id) {
public String addBooking(Model model, @ModelAttribute AddPaymentBean bean, @PathVariable Integer id, @RequestParam String search) {
Double payment = bean.getPayment();
bookingsService.addPayment(id, payment);
LOGGER.debug("search is {}", search);
model.addAttribute("search", search);
return getBookings(model);
}
}

View File

@ -37,6 +37,7 @@
<td class="middled" th:text="${b.role}"></td>
<td class="middled">
<form action="#" th:action="@{'/business/bookings/payment/' + ${b.pk}}" th:object="${addBean}" method="post">
<input th:id="'searchfield' + ${b.pk}" type="text" th:name="search" />
<div class="container">
<div class="row">
<div class="col-sm-4" style="text-align: right">
@ -46,7 +47,7 @@
<input type="number" step="0.01" class="form-control" th:field="*{payment}" />
</div>
<div class="col-sm-4">
<input type="submit" class="btn btn-outline-primary" style="padding: 4px" value="einzahlen" />
<input type="submit" class="btn btn-outline-primary" th:onclick="'setSearchField(' + ${b.pk} + ')'" style="padding: 4px" value="einzahlen" />
</div>
</div>
</div>
@ -58,12 +59,23 @@
</th:block>
</tbody>
</table>
<script>
<script th:inline="javascript">
/*<![CDATA[*/
var searchValue = /*[[${search}]]*/ '';
$(document).ready(function() {
$("#bookers").DataTable({
language : locale_de
language : locale_de,
search : {
search : searchValue
}
});
});
function setSearchField(x) {
$("#searchfield" + x).val($("#bookers").DataTable().search());
}
/*]]>*/
</script>
</div>
</div>