better fav support
This commit is contained in:
@@ -7,7 +7,7 @@ plugins {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
group = 'de.jottyfan'
|
||||
version = '1.5.8'
|
||||
version = '1.5.9'
|
||||
|
||||
description = """timetrack"""
|
||||
|
||||
|
||||
@@ -195,6 +195,13 @@ public class DoneController extends CommonController {
|
||||
return "redirect:/done/list";
|
||||
}
|
||||
|
||||
@RolesAllowed("timetrack_user")
|
||||
@GetMapping(value = "/done/unfavorize_by_id/{id}")
|
||||
public String unfavorizeById(@PathVariable("id") Integer id) {
|
||||
doneService.unfavorizeById(id);
|
||||
return "redirect:/done/list";
|
||||
}
|
||||
|
||||
@RolesAllowed("timetrack_user")
|
||||
@GetMapping(value = "/done/usefav/{id}")
|
||||
public String usefavorite(@PathVariable("id") Integer id) {
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.jooq.Record7;
|
||||
import org.jooq.Record8;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.SelectHavingStep;
|
||||
import org.jooq.SelectLimitPercentStep;
|
||||
import org.jooq.SelectSeekStep4;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.DSL;
|
||||
@@ -494,9 +494,19 @@ public class DoneGateway {
|
||||
sql.execute();
|
||||
}
|
||||
|
||||
public void unfavorizeById(Integer id) {
|
||||
DeleteConditionStep<TFavoriteRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.deleteFrom(T_FAVORITE)
|
||||
.where(T_FAVORITE.PK_FAVORITE.eq(id));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
sql.execute();
|
||||
}
|
||||
|
||||
public List<FavoriteBean> getFavorites(Integer login) {
|
||||
Name COUNT = DSL.name("cnt");
|
||||
SelectHavingStep<Record6<Integer, String, String, String, String, Integer>> sql = getJooq()
|
||||
SelectSeekStep4<Record6<Integer, String, String, String, String, Integer>, String, String, String, String> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(T_FAVORITE.PK_FAVORITE,
|
||||
V_PROJECT.NAME,
|
||||
@@ -513,7 +523,8 @@ public class DoneGateway {
|
||||
.and(T_DONE.FK_MODULE.eq(T_FAVORITE.FK_MODULE))
|
||||
.and(T_DONE.FK_JOB.eq(T_FAVORITE.FK_JOB))
|
||||
.where(T_FAVORITE.FK_LOGIN.eq(login))
|
||||
.groupBy(T_FAVORITE.PK_FAVORITE, V_PROJECT.NAME, V_MODULE.NAME, V_JOB.NAME, V_BILLING.NAME);
|
||||
.groupBy(T_FAVORITE.PK_FAVORITE, V_PROJECT.NAME, V_MODULE.NAME, V_JOB.NAME, V_BILLING.NAME)
|
||||
.orderBy(V_PROJECT.NAME, V_MODULE.NAME, V_JOB.NAME, V_BILLING.NAME);
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
List<FavoriteBean> list = new ArrayList<>();
|
||||
@@ -527,7 +538,6 @@ public class DoneGateway {
|
||||
bean.setLoad(r.get(COUNT, Integer.class));
|
||||
list.add(bean);
|
||||
}
|
||||
list.sort((o1, o2) -> o1 != null && o1.getModule() != null && o2 != null ? o1.getModule().compareTo(o2.getModule()) : 0);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,13 @@ public class DoneService {
|
||||
}
|
||||
}
|
||||
|
||||
public void unfavorizeById(Integer id) {
|
||||
try {
|
||||
new DoneGateway(dsl).unfavorizeById(id);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public List<FavoriteBean> getFavorites(String username) {
|
||||
try {
|
||||
DoneGateway gw = new DoneGateway(dsl);
|
||||
|
||||
@@ -100,14 +100,17 @@
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Favoriten</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li th:each="f : ${favorites}">
|
||||
<a class="dropdown-item" th:href="@{/done/usefav/{id}(id=${f.fkFavorite})}">
|
||||
<span class="row" style="min-width: 512px">
|
||||
<span class="col-1" th:text="${f.load}"></span>
|
||||
<span class="col-2" th:text="${f.project}"></span>
|
||||
<span class="col-3" th:text="${f.module}"></span>
|
||||
<span class="col-6" th:text="${f.job}"></span>
|
||||
</span>
|
||||
</a>
|
||||
<table>
|
||||
<tr><td><a class="text-danger" th:href="@{/done/unfavorize_by_id/{id}(id=${f.fkFavorite})}"><i class="fa fa-trash"></i></a></td>
|
||||
<td><a class="dropdown-item" th:href="@{/done/usefav/{id}(id=${f.fkFavorite})}">
|
||||
<span class="row" style="min-width: 640px">
|
||||
<span class="col-1" th:text="${f.load}"></span>
|
||||
<span class="col-2" th:text="${f.project}"></span>
|
||||
<span class="col-3" th:text="${f.module}"></span>
|
||||
<span class="col-6" th:text="${f.job}"></span>
|
||||
</span>
|
||||
</a></td></tr>
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user