Compare commits

...
Author SHA1 Message Date
StephanRichter 767e918aa5 gui improvements
Build Docker Image / Docker-Build (push) Successful in 2m52s
Build Docker Image / Clean-Registry (push) Successful in 6s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-27 08:40:37 +02:00
StephanRichter f2ff18f19b implemented search on in stock locations
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-23 13:30:06 +02:00
StephanRichter c148800e72 preparing location search 2026-07-23 08:47:50 +02:00
StephanRichter 75927c4395 changed dependency (de.srsoftware:tools.jdbc:2.0.7→2.0.8) – bugfix!
Build Docker Image / Docker-Build (push) Successful in 2m30s
Build Docker Image / Clean-Registry (push) Successful in 6s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-22 21:38:51 +02:00
StephanRichter 6b93cb747b added alternative path for referencing stock items
Build Docker Image / Clean-Registry (push) Canceled after 0s
Build Docker Image / Docker-Build (push) Canceled after 58s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-22 19:59:26 +02:00
StephanRichter 1a79924821 implemented button to make document positions optional
Build Docker Image / Docker-Build (push) Successful in 2m25s
Build Docker Image / Clean-Registry (push) Successful in 6s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-21 21:27:42 +02:00
StephanRichter defb5e3d7b added translations for document type "offer"
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-21 21:27:18 +02:00
StephanRichter d9f28e3b6c improced commit-rollback behaviour on multi-step transactions
Build Docker Image / Docker-Build (push) Successful in 2m56s
Build Docker Image / Clean-Registry (push) Successful in 8s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-07-20 00:22:06 +02:00
22 changed files with 199 additions and 29 deletions
@@ -124,13 +124,16 @@ public class SqliteDb extends BaseDb implements AccountDb {
db.setAutoCommit(false);
Query.delete().from(TABLE_TAGS_TRANSACTIONS).where(TRANSACTION_ID,equal(transaction.id())).execute(db);
Query.delete().from(TABLE_TRANSACTIONS).where(ID,equal(transaction.id())).execute(db);
db.setAutoCommit(true);
return transaction;
} catch (SQLException e){
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToDropObject(transaction);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ subprojects {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
implementation("de.srsoftware:configuration.api:1.0.2")
implementation("de.srsoftware:tools.jdbc:2.0.7")
implementation("de.srsoftware:tools.jdbc:2.0.8")
implementation("de.srsoftware:tools.http:6.0.5")
implementation("de.srsoftware:tools.mime:1.1.4")
implementation("de.srsoftware:tools.logging:1.3.2")
@@ -67,9 +67,16 @@ public class SqliteDb extends BaseDb implements ContactDb{
db.setAutoCommit(false);
Query.delete().from(TABLE_CONTACTS).where(ID,equal(contact.id())).execute(db);
Query.delete().from(TABLE_CONTACTS_USERS).where(CONTACT_ID,equal(contact.id())).execute(db);
db.setAutoCommit(true);
} catch (SQLException e){
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToDropObject(t(CONTACT_WITH_ID, ID,contact.id())).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -69,9 +69,15 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
update(table).set(STATUS).where(STATUS,equal(20)).prepare(db).apply(40).execute();
update(table).set(STATUS).where(STATUS,equal(10)).prepare(db).apply(20).execute();
update(table).set(STATUS).where(STATUS,equal(0)).prepare(db).apply(10).execute();
db.setAutoCommit(true);
} catch (SQLException e) {
try {
db.rollback();
} catch (SQLException ignored) {}
throw new RuntimeException(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
}
@@ -198,11 +198,17 @@ CREATE TABLE IF NOT EXISTS {0} (
rs.close();
delete().from(TABLE_POSITIONS).where(DOCUMENT_ID,equal(docId)).execute(db);
delete().from(TABLE_DOCUMENTS).where(ID,equal(docId)).execute(db);
db.setAutoCommit(true);
if (number != null) return number;
throw failedToDropObject(t(DOCUMENT_WITH_ID, ID,docId));
} catch (SQLException e){
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToDropObject(t(DOCUMENT_WITH_ID, ID,docId)).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -217,10 +223,16 @@ CREATE TABLE IF NOT EXISTS {0} (
stmt.setLong(2,pos);
stmt.execute();
stmt.close();
db.setAutoCommit(true);
return pos;
} catch (SQLException e) {
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToDropObjectFromObject(POSITION,pos,t(Text.DOCUMENT),docId).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -582,9 +594,15 @@ CREATE TABLE IF NOT EXISTS {0} (
update(TABLE_POSITIONS).set(POS).where(DOCUMENT_ID,equal(docId)).where(POS,equal(pair.left())).prepare(db).apply(-pair.right()).close();
update(TABLE_POSITIONS).set(POS).where(DOCUMENT_ID,equal(docId)).where(POS,equal(pair.right())).prepare(db).apply(pair.left()).close();
update(TABLE_POSITIONS).set(POS).where(DOCUMENT_ID,equal(docId)).where(POS,equal(-pair.right())).prepare(db).apply(pair.right()).close();
db.setAutoCommit(true);
} catch (SQLException e) {
try {
db.rollback();
} catch (SQLException ignored){};
throw databaseException(FAILED_TO_SWITCH_POSITIONS,"a",pair.left(),"b",pair.right(),docId).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
return pair;
}
+1
View File
@@ -122,6 +122,7 @@
<Route path="/stock/location/:location_id" component={Stock} />
<Route path="/stock/:item_id/view" component={Stock} />
<Route path="/stock/:owner/:owner_id/item/:owner_number" component={Stock} />
<Route path="/stock/:owner/:owner_id/item/:owner_number/view" component={Stock} />
<Route path="/tags" component={TagList} />
<Route path="/tags/use/:tag" component={TagUses} />
<Route path="/task" component={TaskList} />
+7 -1
View File
@@ -1,6 +1,7 @@
<script>
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { t } from '../../translations.svelte';
import LineEditor from '../../Components/LineEditor.svelte';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
@@ -23,13 +24,17 @@
function movedown(){
movePos(pos.number,1);
}
async function toggleOptional(ev){
const ok = await submit(`${prefix}.optional`,!pos.optional);
if (ok) pos.optional = !pos.optional;
}
</script>
<style>
.move{
vertical-align: middle;
}
tr > *:nth-child(1){
text-align: right;
}
@@ -66,6 +71,7 @@
<span onclick={moveup}>⏫</span>
{/if}
<span onclick={() => drop(pos.number)}>❌</span>
<span class="symbol" onclick={toggleOptional} title={t(pos.optional?'optional position':'fixed position')}>{pos.optional?'':''}</span>
<span onclick={movedown}>⏬</span>
{/if}
</td>
+15 -1
View File
@@ -265,8 +265,10 @@
<legend>
{t('stock')}
</legend>
{#if Object.keys(stock.items).length }
{t('items')}
<ul>
{#each Object.values(stock) as item}
{#each Object.values(stock.items) as item}
<li>
<a href="/stock/{item.owner.type}/{item.owner.id}/item/{item.owner_number}" {onclick} >
{item.name} [{t('code')}: <span class="code">{item.code}</span>]
@@ -275,6 +277,18 @@
</li>
{/each}
</ul>
{/if}
{#if Object.keys(stock.locations).length}
{t('locations')}
<ul>
{#each Object.values(stock.locations) as loc (loc.id)}
<li>
<a href="/stock/location/{loc.id}">{loc.name}</a>
<br/> {@html loc.description.rendered}
</li>
{/each}
</ul>
{/if}
</fieldset>
{/if}
{#if times}
+1 -1
View File
@@ -102,7 +102,7 @@
<ul>
{#each locations as location}
<li onclick={e => toggleChildren(e, location)}
class="{location.locations?'expanded':'collapsed'} {location.highlight?'highlight':null}"
class="{location.locations?'expanded':'collapsed'} {location.highlight?'highlight':null} {selected && selected.id == location.id?'selected':null}"
draggable={true}
ondragover={e => drag_over(e,location)}
ondrop={e => onDrop(e,location)}
@@ -63,10 +63,16 @@ public class SqliteDb extends BaseDb implements StockDb {
rs.close();
if (propertyId == null || propertyId == 0) throw failedToStoreObject(t(PROPERTY));
insertInto(TABLE_ITEM_PROPERTIES,ITEM_ID,PROPERTY_ID,VALUE).values(itemId,propertyId,value).execute(db).close();
db.setAutoCommit(true);
return new Property(propertyId,name,value,unit);
} catch (SQLException e) {
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToStoreObject(t(PROPERTY)).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -126,7 +132,7 @@ public class SqliteDb extends BaseDb implements StockDb {
private void createItemsTable() {
try {
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255) NOT NULL, {3} TEXT, {4} VARCHAR(255))";
sql = format(sql, TABLE_ITEMS, ID, Field.CODE, NAME, LOCATION_ID);
sql = format(sql, TABLE_ITEMS, ID, Field.CODE, NAME, LOCATION_ID);
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw failedToCreateTable(TABLE_ITEMS).causedBy(e);
@@ -136,7 +142,7 @@ public class SqliteDb extends BaseDb implements StockDb {
private void createItemPropsTable() {
try {
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} INT NOT NULL, {2} INT NOT NULL, {3} VARCHAR(255) NOT NULL, PRIMARY KEY({1}, {2}))";
sql = format(sql, TABLE_ITEM_PROPERTIES, ITEM_ID, PROPERTY_ID,VALUE);
sql = format(sql, TABLE_ITEM_PROPERTIES, ITEM_ID, PROPERTY_ID,VALUE);
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw failedToCreateTable(TABLE_ITEM_PROPERTIES).causedBy(e);
@@ -146,7 +152,7 @@ public class SqliteDb extends BaseDb implements StockDb {
private void createLocationsTable() {
try {
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255) DEFAULT NULL, {3} VARCHAR(255) NOT NULL, {4} TEXT)";
sql = format(sql, TABLE_LOCATIONS, ID, LOCATION_ID, NAME, DESCRIPTION);
sql = format(sql, TABLE_LOCATIONS, ID, LOCATION_ID, NAME, DESCRIPTION);
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw failedToCreateTable(TABLE_LOCATIONS).causedBy(e);
@@ -156,7 +162,7 @@ public class SqliteDb extends BaseDb implements StockDb {
private void createPropertiesTable() {
try {
var sql = "CREATE TABLE IF NOT EXISTS {0} ( {1} INTEGER PRIMARY KEY, {2} VARCHAR(255) NOT NULL, {3} INT NOT NULL, {4} VARCHAR(255))";
sql = format(sql, TABLE_PROPERTIES, ID, NAME, TYPE, UNIT);
sql = format(sql, TABLE_PROPERTIES, ID, NAME, TYPE, UNIT);
db.prepareStatement(sql).execute();
} catch (SQLException e) {
throw failedToCreateTable(TABLE_PROPERTIES).causedBy(e);
@@ -201,18 +207,18 @@ public class SqliteDb extends BaseDb implements StockDb {
}
@Override
public Map<Long, Item> find(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
public Map<Long, Item> findItems(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
try {
var items = new HashMap<Long,Item>();
var ownerCodes = owners.stream().map(Owner::dbCode).toArray();
var query = select(ALL).from(TABLE_ITEMS).where(OWNER, in(ownerCodes));
var query = select(ALL).from(TABLE_ITEMS).where(OWNER, in(ownerCodes));
if (fulltext) {
query.leftJoin(ID,TABLE_ITEM_PROPERTIES,ITEM_ID);
for (var key : keys) query.where(format("CONCAT({0},\" \",{1},\" \",{2})", NAME, DESCRIPTION,VALUE),like("%"+key+"%"));
} else {
for (var key : keys) query.where(NAME,like("%"+key+"%"));
}
var rs = query.exec(db);
var rs = query.exec(db);
var items = new HashMap<Long,Item>();
while (rs.next()){
var item = Item.of(rs);
items.put(item.id(),item);
@@ -224,10 +230,33 @@ public class SqliteDb extends BaseDb implements StockDb {
}
}
@Override
public Map<Long, Location> findLocations(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
try {
var ownerCodes = owners.stream().map(Owner::dbCode).toArray();
var query = select(ALL).from(TABLE_LOCATIONS).where(OWNER, in(ownerCodes));
if (fulltext) {
for (var key : keys) query.where(format("CONCAT({0},\" \",{1})", NAME, DESCRIPTION), like("%" + key + "%"));
} else {
for (var key : keys) query.where(NAME, like("%" + key + "%"));
}
var rs = query.exec(db);
var locations = new HashMap<Long, Location>();
while (rs.next()) {
var location = DbLocation.of(rs);
locations.put(location.id(), location);
}
rs.close();
return locations;
} catch (SQLException e){
throw databaseException(FAILED_TO_LIST_ENTITIES, TYPE,t(LOCATIONS)).causedBy(e);
}
}
@Override
public Collection<DbLocation> listChildLocations(long parentId) {
try {
var rs = select(ALL).from(TABLE_LOCATIONS).where(PARENT_LOCATION_ID,equal(parentId)).exec(db);
var rs = select(ALL).from(TABLE_LOCATIONS).where(PARENT_LOCATION_ID,equal(parentId)).exec(db);
var list = new ArrayList<DbLocation>();
while (rs.next()) list.add(DbLocation.of(rs));
rs.close();
@@ -240,7 +269,7 @@ public class SqliteDb extends BaseDb implements StockDb {
@Override
public Collection<DbLocation> listCompanyLocations(Company company) {
try {
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(company.dbCode())).where(PARENT_LOCATION_ID,isNull()).exec(db);
var rs = select(ALL).from(TABLE_LOCATIONS).where(OWNER,equal(company.dbCode())).where(PARENT_LOCATION_ID,isNull()).exec(db);
var list = new ArrayList<DbLocation>();
while (rs.next()) list.add(DbLocation.of(rs));
rs.close();
@@ -601,13 +630,16 @@ public class SqliteDb extends BaseDb implements StockDb {
replaceLocationsTable();
replaceItemsTable();
replaceItemPropsTable();
db.setAutoCommit(true);
} catch (Exception e) {
try {
db.rollback();
} catch (SQLException ignored) {
}
throw databaseException(FAILED_TO_UPDATE_OBJECT, OBJECT, t(TABLE_WITH_NAME,NAME,TABLE_LOCATIONS)).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -10,7 +10,8 @@ import java.util.Map;
public interface StockDb {
Property addNewProperty(long itemId, String name, Object value, String unit);
Location delete(DbLocation location);
Map<Long, Item> find(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
Map<Long, Item> findItems(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
Map<Long, Location> findLocations(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
Collection<DbLocation> listChildLocations(long parentId);
Collection<DbLocation> listCompanyLocations(Company company);
Collection<Item> listItemsAt(Location location);
@@ -459,12 +459,13 @@ public class StockModule extends BaseHandler implements StockService {
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
var json = json(ex);
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingField(KEY);
var keys = Arrays.asList(key.split(" "));
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
var keys = Arrays.asList(key.split(" "));
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
Set<Owner> owners = new HashSet<>(companyService().listCompaniesOf(user).values());
owners.add(user);
var items = stockDb.find(owners,keys,fulltext);
return sendContent(ex,mapValues(items));
var items = stockDb.findItems(owners,keys,fulltext);
var locations = stockDb.findLocations(owners,keys,fulltext);
return sendContent(ex,Map.of("items",mapValues(items),"locations",mapValues(locations)));
}
@Override
@@ -340,7 +340,6 @@ CREATE TABLE IF NOT EXISTS {0} (
var addQuery = replaceInto(TABLE_TASK_DEPENDENCIES, TASK_ID, REQUIRED_TASK_ID);
for (var reqId : task.requiredTasksIds()) addQuery.values(task.id(), reqId);
addQuery.execute(db).close();
db.setAutoCommit(true);
}
task.clean(REQUIRED_TASKS_IDS);
@@ -354,7 +353,14 @@ CREATE TABLE IF NOT EXISTS {0} (
}
return task;
} catch (SQLException e){
try {
db.rollback();
} catch (SQLException ignored){};
throw failedToStoreObject(task.name()).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
@@ -84,10 +84,16 @@ CREATE TABLE IF NOT EXISTS {0} (
db.setAutoCommit(false);
Query.delete().from(TABLE_TASK_TIMES).where(TIME_ID,equal(timeId)).execute(db);
Query.delete().from(TABLE_TIMES).where(ID,equal(timeId)).execute(db);
db.setAutoCommit(false);
return timeId;
} catch (SQLException e) {
try {
db.rollback();
} catch (SQLException ignored) {}
throw failedToDropObject(t(TIME_WITH_ID, ID,timeId)).causedBy(e);
} finally {
try {
db.setAutoCommit(true);
} catch (SQLException ignored){};
}
}
+3
View File
@@ -167,6 +167,7 @@
"filter": "Filter",
"filter by tags": "Nach Tags filtern",
"first_transaction": "erste Transaktion",
"fixed position": "fester Posten",
"footer": "Fuß-Text",
"foreign_id": "externe Kennung",
"forgot_pass" : "Password vergessen?",
@@ -278,7 +279,9 @@
"oidc_Login" : "Anmeldung mit OIDC",
"old_password": "altes Passwort",
"offer": "Angebot",
"option": "Option",
"optional position": "optionaler Posten",
"options": "Optionen",
"organization": "Organisation",
"other party": "Gegenseite",
+3
View File
@@ -167,6 +167,7 @@
"filter": "filter",
"filter by tags": "filter by tags",
"first_transaction": "first transaction",
"fixed position": "fixed position",
"footer": "footer",
"foreign_id": "external ID",
"forgot_pass" : "forgot password?",
@@ -278,7 +279,9 @@
"oidc_Login" : "Login via OIDC",
"old_password": "old password",
"offer": "offer",
"option": "option",
"optional position": "optional position",
"options": "options",
"organization": "organization",
"other party": "other party",
@@ -341,6 +341,18 @@ tr:hover .taglist .tag button {
color: yellow;
}
.positions tr:nth-child(2n){
border-bottom-color: red;
}
.positions tbody tr:last-child{
border-top-color: red;
}
.locations .selected span{
background: brown;
color: yellow;
}
@media screen and (max-width: 900px) {
#app nav a{
background: black;
@@ -390,6 +390,7 @@ span.timetracking {
table{
min-width: 30vw;
border-collapse: collapse;
}
.start_end{
@@ -485,6 +486,14 @@ select.autocomplete{
width: calc(100% - 50px);
}
.positions tr:nth-child(2n){
border-bottom: 1px solid;
}
.positions tbody tr:last-child{
border-top: 3px solid;
}
@media screen and (min-width: 900px) {
#app nav > button.symbol{
display: none;
@@ -337,6 +337,18 @@ code,
color: black;
}
.positions tr:nth-child(2n){
border-bottom-color: gold;
}
.positions tbody tr:last-child{
border-top-color: gold;
}
.locations .selected span{
background: gold;
color: black;
}
@media screen and (max-width: 900px) {
#app nav a{
background: black;
@@ -484,6 +484,7 @@ span.timetracking {
table{
min-width: 30vw;
border-collapse: collapse;
}
.start_end{
@@ -589,6 +590,14 @@ select.autocomplete{
width: calc(100% - 50px);
}
.positions tr:nth-child(2n){
border-bottom: 1px solid;
}
.positions tbody tr:last-child{
border-top: 3px solid;
}
@media screen and (min-width: 900px) {
#app nav > button.symbol{
display: none;
@@ -288,6 +288,18 @@ tr:hover .taglist .tag button {
background: cyan;
}
.positions tr:nth-child(2n){
border-bottom-color: blue;
}
.positions tbody tr:last-child{
border-top-color: blue;
}
.locations .selected span{
background: #afffff;
color: black;
}
@media screen and (max-width: 900px) {
#app nav a{
background: white;
@@ -483,6 +483,7 @@ span.timetracking {
table{
min-width: 30vw;
border-collapse: collapse;
}
.start_end{
@@ -578,6 +579,14 @@ select.autocomplete{
width: calc(100% - 50px);
}
.positions tr:nth-child(2n){
border-bottom: 1px solid;
}
.positions tbody tr:last-child{
border-top: 3px solid;
}
@media screen and (min-width: 900px) {
#app nav > button.symbol{
display: none;