editing inline in table by direct request
This commit is contained in:
@ -7,7 +7,7 @@ plugins {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
group = 'de.jottyfan'
|
||||
version = '1.5.2'
|
||||
version = '1.5.3'
|
||||
|
||||
description = """timetrack"""
|
||||
|
||||
|
@ -24,6 +24,7 @@ import de.jottyfan.timetrack.modules.done.model.SlotBean;
|
||||
import de.jottyfan.timetrack.modules.done.model.SlotRangeBean;
|
||||
import de.jottyfan.timetrack.modules.done.model.SummaryBean;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.websocket.server.PathParam;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -82,6 +83,13 @@ public class DoneController extends CommonController {
|
||||
return getList(model, doneModel);
|
||||
}
|
||||
|
||||
@RolesAllowed("timetrack_user")
|
||||
@GetMapping("/done/update/{id}")
|
||||
public String updateField(@PathVariable("id") Integer fkDone, @PathParam("field") String field, @PathParam("value") Integer value) {
|
||||
doneService.updateField(fkDone, field, value);
|
||||
return "redirect:/done/list";
|
||||
}
|
||||
|
||||
@RolesAllowed("timetrack_user")
|
||||
@GetMapping("/done/abort/{day}")
|
||||
public String abort(@PathVariable("day") String day, Model model) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_DONE;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_OVERTIME;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_REQUIRED_WORKTIME;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_DAY;
|
||||
@ -32,12 +33,14 @@ import org.jooq.Row4;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.SelectHavingStep;
|
||||
import org.jooq.SelectSeekStep1;
|
||||
import org.jooq.TableField;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.types.YearToSecond;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TOvertimeRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TRequiredWorktimeRecord;
|
||||
import de.jottyfan.timetrack.modules.done.model.DaysumBean;
|
||||
@ -295,4 +298,22 @@ public class DoneRepository {
|
||||
LOGGER.trace(sql);
|
||||
sql.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* update the field only
|
||||
*
|
||||
* @param fkDone the ID
|
||||
* @param value the value
|
||||
* @param tableField the field
|
||||
*/
|
||||
public void updateField(Integer fkDone, Integer value, TableField<TDoneRecord, Integer> tableField) {
|
||||
UpdateConditionStep<TDoneRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.update(T_DONE)
|
||||
.set(tableField, value)
|
||||
.where(T_DONE.PK.eq(fkDone));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_DONE;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@ -327,4 +329,16 @@ public class DoneService {
|
||||
}
|
||||
repository.addSlotRange(minutes, username, reason, days);
|
||||
}
|
||||
|
||||
public void updateField(Integer fkDone, String field, Integer value) {
|
||||
if ("project".equals(field)) {
|
||||
repository.updateField(fkDone, value, T_DONE.FK_PROJECT);
|
||||
} else if ("module".equals(field)) {
|
||||
repository.updateField(fkDone, value, T_DONE.FK_MODULE);
|
||||
} else if ("job".equals(field)) {
|
||||
repository.updateField(fkDone, value, T_DONE.FK_JOB);
|
||||
} else {
|
||||
LOGGER.error("field {} not supported yet", field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,17 @@
|
||||
</ul>
|
||||
<div class="tabdivblurred tab-content">
|
||||
<div id="div_list" class="tab-pane active tab-pane-table">
|
||||
<script th:inline="javascript">
|
||||
function submitDropdown(field) {
|
||||
const value = field.value;
|
||||
const id = field.getAttribute("data-id");
|
||||
const fld = field.getAttribute("data-field");
|
||||
|
||||
const url_prefix = /*[[@{/done/update/}]]*/ "#";
|
||||
const url = url_prefix + id + "?field=" + fld + "&value=" + value;
|
||||
window.location.href = url;
|
||||
}
|
||||
</script>
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -108,15 +119,24 @@
|
||||
<td><a class="hoverlink" th:href="@{/done/edit/{id}(id=${done.pk})}">
|
||||
<span th:text="${done.timeDiff}"></span>
|
||||
</a></td>
|
||||
<td><a class="hoverlink" th:href="@{/done/edit/{id}(id=${done.pk})}">
|
||||
<span class="boldtext" th:text="${done.project?.name}"></span>
|
||||
</a></td>
|
||||
<td><a class="hoverlink" th:href="@{/done/edit/{id}(id=${done.pk})}">
|
||||
<span class="boldtext" th:text="${done.module?.name}"></span>
|
||||
</a></td>
|
||||
<td><a class="hoverlink" th:href="@{/done/edit/{id}(id=${done.pk})}">
|
||||
<span class="boldtext" th:text="${done.activity?.name}"></span>
|
||||
</a></td>
|
||||
<td>
|
||||
<select onchange="submitDropdown(this)" th:data-id="${done.pk}" data-field="project">
|
||||
<option value="">---</option>
|
||||
<option th:each="p : ${projectList}" th:value="${p.pk}" th:text="${p.name}" th:selected="${done.project?.name == p.name ? 'selected' : 'false'}"></option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select onchange="submitDropdown(this)" th:data-id="${done.pk}" data-field="module">
|
||||
<option value="">---</option>
|
||||
<option th:each="m : ${moduleList}" th:value="${m.pk}" th:text="${m.name}" th:selected="${done.module?.name == m.name ? 'selected' : 'false'}"></option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select onchange="submitDropdown(this)" th:data-id="${done.pk}" data-field="job">
|
||||
<option value="">---</option>
|
||||
<option th:each="j : ${jobList}" th:value="${j.pk}" th:text="${j.name}" th:selected="${done.activity?.name == j.name ? 'selected' : 'false'}"></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><span th:text="${done.billing.shortcut}" th:class="'billing ' + ${done.billing.csskey}" th:if="${done.billing != null}"></span></td>
|
||||
<td><a class="btn-list" th:href="@{/done/copy/{id}(id=${done.pk})}" title="Aufgabe neu beginnen"><i class="fa fa-copy"></i></a>
|
||||
<a class="btn-list" th:href="@{/done/edit/{id}(id=${done.pk})}" title="Eintrag bearbeiten"><i class="fa fa-edit"></i></a>
|
||||
|
Reference in New Issue
Block a user