Feature: circle interest for next opening#152
Conversation
Adds a UI element tied back to the CircleEntity. Anyone can increment this counter. (any number of times) The basic idea is to show interest in a possible opening for motivating the provider.
Gerviba
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
I just reviewed your code, if you need help, contact me here or in pm.
| @Column | ||
| var virGroupId: Long? = null | ||
|
|
||
| @Column |
There was a problem hiding this comment.
It requires a column definistion with '... default 0' parameter in order to make DB migration automatic
There was a problem hiding this comment.
I've found this: https://stackoverflow.com/a/42150940 as an alternative to this: https://stackoverflow.com/a/375202
I think you were mentioning the latter.
However, can you check whether the former is valid? It seems a better solution, as you already use org.hibernate.
There was a problem hiding this comment.
I've implemented the one using org.hibernate's ColumnDefault for now
|
|
||
| @PostMapping("/provider/{circle}/increaseInterest") | ||
| @ResponseBody | ||
| fun circleInterestPlusPlus(@PathVariable circle: String, model: Model, request: HttpServletRequest): String { |
There was a problem hiding this comment.
I'll pull the transactional part to service layer, as it is recommended (as I see it, and as it was pointed out here: https://stackoverflow.com/a/18637119 ).
| <div th:replace="MainLayout :: footer"></div> | ||
| <script> | ||
| function increaseInterest() { | ||
| return fetch("/api/provider/(Burgir)/increaseInterest", { // TODO hook in provider? |
There was a problem hiding this comment.
I might use sg. like:
function increaseInterest(provider) {
return fetch(`/api/provider/${provider}/increaseInterest`, {
There was a problem hiding this comment.
This gets really ugly (alias is injected as JavaScript from a template, and I do not like the sound of it :/ ). Or would it be okay? Or you had something else in mind?
For reference, this is how I understood your comment:
diff --git a/src/main/resources/templates/circleProfile.html b/src/main/resources/templates/circleProfile.html
index 7bc09ae..af6b985 100644
--- a/src/main/resources/templates/circleProfile.html
+++ b/src/main/resources/templates/circleProfile.html
@@ -58,7 +58,7 @@
<tr>
<td th:text="#{lang.profile.open}">Please open!</td>
<td>
- <button id="interest-counter" class="action-button" onclick="increaseInterest(1); return false" th:text="${selectedCircle?.interestCounter}" class="action-button">0</button>
+ <button id="interest-counter" class="action-button" th:onclick="increaseInterest(${selectedCircle.alias}); return false" th:text="${selectedCircle?.interestCounter}" class="action-button">0</button>
</td>
</tr>
<tr>
@@ -123,8 +123,8 @@
<div th:replace="MainLayout :: footer"></div>
<script>
- function increaseInterest() {
- return fetch("/api/provider/(Burgir)/increaseInterest", { // TODO hook in provider?
+ function increaseInterest(provider) {
+ return fetch(`/api/provider/${provider}/increaseInterest`, {
method: 'POST',
cache: 'no-cache',
credentials: 'same-origin',There was a problem hiding this comment.
In a normal scenario you could write sg. like:
th:onclick="|increaseInterest(${selectedCircle.alias}); return false|"
Notice the string template literal vertical bars.
But in case of th:onclick you are not able to use variables, so you have two options:
- use data atibutes: https://stackoverflow.com/a/54840163
- use inlined javascript template:
<script th:inline="javascript">
const provider = /*[[${selectedCircle.alias}]]*/ '';
</script>
There was a problem hiding this comment.
I forgot to reflect the change in the comment.
There was a problem hiding this comment.
I have used data attributes in the changes, can you check if it works?
6f1fc3c to
7db9fe2
Compare
Moves the logic inside service layer.
7db9fe2 to
ff42c59
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
|
Thank you for looking into this PR! Feel free to add nitpicks. I am not really confident with my Spring :D |








Adds a UI element tied back to the CircleEntity. Anyone can increment this counter. (any number of times)
The basic idea is to show interest in a possible opening for motivating the provider.
Note: Probably this needs migrations or other things I do not know about (: . Also I could not test the code. I am happy to help, and discuss ideas :)