working on tag module
This commit is contained in:
@@ -20,6 +20,7 @@ dependencies{
|
||||
implementation(project(":markdown"))
|
||||
implementation(project(":messages"))
|
||||
implementation(project(":project"))
|
||||
implementation(project(":tags"))
|
||||
implementation(project(":task"))
|
||||
implementation(project(":time"))
|
||||
implementation(project(":translations"))
|
||||
|
||||
@@ -18,6 +18,7 @@ import de.srsoftware.umbrella.markdown.MarkdownApi;
|
||||
import de.srsoftware.umbrella.message.MessageApi;
|
||||
import de.srsoftware.umbrella.message.MessageSystem;
|
||||
import de.srsoftware.umbrella.project.ProjectModule;
|
||||
import de.srsoftware.umbrella.tags.TagModule;
|
||||
import de.srsoftware.umbrella.task.TaskModule;
|
||||
import de.srsoftware.umbrella.time.TimeModule;
|
||||
import de.srsoftware.umbrella.translations.Translations;
|
||||
@@ -66,6 +67,7 @@ public class Application {
|
||||
var markdownApi = new MarkdownApi(userModule);
|
||||
var messageApi = new MessageApi(messageSystem);
|
||||
var projectModule = new ProjectModule(config,companyModule);
|
||||
var tagModule = new TagModule(config,userModule);
|
||||
var taskModule = new TaskModule(config,projectModule);
|
||||
var timeModule = new TimeModule(config,taskModule);
|
||||
var webHandler = new WebHandler();
|
||||
@@ -76,6 +78,7 @@ public class Application {
|
||||
markdownApi .bindPath("/api/markdown") .on(server);
|
||||
messageApi .bindPath("/api/messages") .on(server);
|
||||
projectModule .bindPath("/api/project") .on(server);
|
||||
tagModule .bindPath("/api/tags") .on(server);
|
||||
taskModule .bindPath("/api/task") .on(server);
|
||||
timeModule .bindPath("/api/times") .on(server);
|
||||
translationModule.bindPath("/api/translations").on(server);
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
|
||||
public abstract class BaseHandler extends PathHandler {
|
||||
|
||||
public record Page(String mime, byte[] bytes){}
|
||||
|
||||
public HttpExchange addCors(HttpExchange ex){
|
||||
var headers = ex.getRequestHeaders();
|
||||
var origin = nullable(headers.get("Origin")).orElse(List.of()).stream().filter(url -> url.contains("://localhost")||url.contains("://127.0.0.1")).findAny();
|
||||
@@ -32,8 +34,6 @@ public abstract class BaseHandler extends PathHandler {
|
||||
return ex;
|
||||
}
|
||||
|
||||
public record Page(String mime, byte[] bytes){}
|
||||
|
||||
public boolean load(Path path, HttpExchange ex) throws IOException {
|
||||
try {
|
||||
var doc = load(path.toString());
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
public interface TagService {
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package de.srsoftware.umbrella.core.model;
|
||||
import static de.srsoftware.tools.Optionals.nullable;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
|
||||
import static de.srsoftware.umbrella.core.Util.markdown;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
@@ -9,12 +9,11 @@ import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFi
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Task implements Mappable {
|
||||
public static final System.Logger LOG = System.getLogger(Task.class.getSimpleName());
|
||||
|
||||
1033
doc/relation tags - bookmarks - notes.dia
Normal file
1033
doc/relation tags - bookmarks - notes.dia
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,6 @@ import static de.srsoftware.tools.jdbc.Condition.in;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.documents.Constants.*;
|
||||
import static de.srsoftware.umbrella.documents.model.Document.DEFAULT_THOUSANDS_SEPARATOR;
|
||||
|
||||
@@ -4,7 +4,6 @@ package de.srsoftware.umbrella.documents.model;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
|
||||
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
|
||||
import static de.srsoftware.umbrella.core.Util.markdown;
|
||||
import static de.srsoftware.umbrella.documents.Constants.*;
|
||||
import static de.srsoftware.umbrella.documents.Constants.FIELD_CUSTOMER;
|
||||
import static java.util.Optional.empty;
|
||||
|
||||
@@ -4,7 +4,6 @@ package de.srsoftware.umbrella.documents.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
|
||||
import static de.srsoftware.umbrella.core.Util.markdown;
|
||||
import static de.srsoftware.umbrella.documents.Constants.*;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
|
||||
85
frontend/src/routes/tags/TagList.svelte
Normal file
85
frontend/src/routes/tags/TagList.svelte
Normal file
@@ -0,0 +1,85 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
import {api} from '../../urls.svelte.js';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
import {user} from '../../user.svelte.js'
|
||||
|
||||
import Editor from '../../Components/LineEditor.svelte';
|
||||
|
||||
let { module, id, user_list = [] } = $props();
|
||||
let error = $state(null);
|
||||
let newTag = $state('');
|
||||
let tags = $state([]);
|
||||
|
||||
async function addTag(tag){
|
||||
const url = api(`tags/${module}/${id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'POST',
|
||||
body: JSON.stringify({tag:tag,user_list:user_list})
|
||||
});
|
||||
if (resp.ok){
|
||||
tag = await resp.text();
|
||||
tags.push(tag);
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function drop(tag){
|
||||
const url = api(`tags/${module}/${id}`);
|
||||
const resp = await fetch(url,{
|
||||
credentials:'include',
|
||||
method:'DELETE',
|
||||
body: tag
|
||||
});
|
||||
if (resp.ok){
|
||||
tag = await resp.text();
|
||||
tags = tags.filter(item => item !== tag);
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function loadTags(){
|
||||
const url = api(`tags/${module}/${id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok) {
|
||||
tags = await resp.json();
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadTags);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tag {
|
||||
border: 1px solid orange;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
.editor span {
|
||||
min-width: 100px;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
|
||||
<div class="taglist">
|
||||
{#each tags as tag,idx}
|
||||
<span class="tag">
|
||||
{tag}
|
||||
<button onclick={() => drop(tag)} class="symbol"></button>
|
||||
</span>
|
||||
{/each}
|
||||
<span class="tag editor">
|
||||
<Editor editable="true" bind:value={newTag} onSet={addTag} type="span" />
|
||||
</span>
|
||||
</div>
|
||||
@@ -9,6 +9,7 @@
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import MemberEditor from '../../Components/MemberEditor.svelte';
|
||||
import StateSelector from '../../Components/StateSelector.svelte';
|
||||
import TagList from '../tags/TagList.svelte';
|
||||
import TaskList from './TaskList.svelte';
|
||||
|
||||
const router = useTinyRouter();
|
||||
@@ -284,6 +285,14 @@
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('tags')}
|
||||
</th>
|
||||
<td class="tags">
|
||||
<TagList module="task", {id} user_list={Object.keys(task.members).map(id => +id)} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
@@ -4,7 +4,6 @@ package de.srsoftware.umbrella.items;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.CODE;
|
||||
import static de.srsoftware.umbrella.core.Util.mapMarkdown;
|
||||
import static de.srsoftware.umbrella.core.Util.markdown;
|
||||
import static de.srsoftware.umbrella.items.Constants.*;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
|
||||
@@ -5,7 +5,6 @@ import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.tools.jdbc.Query.select;
|
||||
import static de.srsoftware.umbrella.core.Constants.COMPANY_ID;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||
import static de.srsoftware.umbrella.items.Constants.TABLE_ITEMS;
|
||||
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
|
||||
@@ -6,7 +6,6 @@ import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.TABLE_SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||
import static de.srsoftware.umbrella.core.model.Status.COMPLETE;
|
||||
import static de.srsoftware.umbrella.core.model.Status.OPEN;
|
||||
import static de.srsoftware.umbrella.project.Constants.*;
|
||||
|
||||
@@ -10,6 +10,7 @@ include("items")
|
||||
include("messages")
|
||||
include("markdown")
|
||||
include("project")
|
||||
include("tags")
|
||||
include("task")
|
||||
include("time")
|
||||
include("translations")
|
||||
|
||||
6
tags/build.gradle.kts
Normal file
6
tags/build.gradle.kts
Normal file
@@ -0,0 +1,6 @@
|
||||
description = "Umbrella : Tags"
|
||||
|
||||
dependencies{
|
||||
implementation(project(":core"))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.tags;
|
||||
|
||||
public class Constants {
|
||||
private Constants(){}
|
||||
|
||||
public static final String CONFIG_DATABASE = "umbrella.modules.tags.database";
|
||||
public static final String DB_VERSION = "project_db_version";
|
||||
public static final String MODULE = "module";
|
||||
public static final String TABLE_TAGS = "tags";
|
||||
public static final String TAG = "tag";
|
||||
}
|
||||
129
tags/src/main/java/de/srsoftware/umbrella/tags/SqliteDb.java
Normal file
129
tags/src/main/java/de/srsoftware/umbrella/tags/SqliteDb.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.tags;
|
||||
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
|
||||
import static de.srsoftware.umbrella.core.Constants.USER_ID;
|
||||
import static de.srsoftware.umbrella.tags.Constants.*;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.lang.System.Logger.Level.INFO;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.tools.jdbc.Query;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SqliteDb implements TagDB{
|
||||
private static final int INITIAL_DB_VERSION = 1;
|
||||
private static final System.Logger LOG = System.getLogger("TagDB");
|
||||
private final Connection db;
|
||||
|
||||
public SqliteDb(Connection conn) {
|
||||
this.db = conn;
|
||||
init();
|
||||
}
|
||||
|
||||
private int createTables() {
|
||||
createTagTables();
|
||||
return createSettingsTable();
|
||||
}
|
||||
|
||||
private int createSettingsTable() {
|
||||
var createTable = """
|
||||
CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255) NOT NULL);
|
||||
""";
|
||||
try {
|
||||
var stmt = db.prepareStatement(format(createTable,TABLE_SETTINGS, KEY, VALUE));
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_SETTINGS,e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Integer version = null;
|
||||
try {
|
||||
var rs = select(VALUE).from(TABLE_SETTINGS).where(KEY, equal(DB_VERSION)).exec(db);
|
||||
if (rs.next()) version = rs.getInt(VALUE);
|
||||
rs.close();
|
||||
if (version == null) {
|
||||
version = INITIAL_DB_VERSION;
|
||||
insertInto(TABLE_SETTINGS, KEY, VALUE).values(DB_VERSION,version).execute(db).close();
|
||||
}
|
||||
|
||||
return version;
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_READ_TABLE,DB_VERSION,TABLE_SETTINGS,e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createTagTables() {
|
||||
var createTable = """
|
||||
CREATE TABLE IF NOT EXISTS "{0}" (
|
||||
{1} VARCHAR(255) NOT NULL,
|
||||
{2} VARCHAR(20) NOT NULL,
|
||||
{3} INTEGER NOT NULL,
|
||||
{4} INTEGER NOT NULL,
|
||||
PRIMARY KEY ({1}, {2}, {3}, {4})
|
||||
)""";
|
||||
try {
|
||||
var stmt = db.prepareStatement(format(createTable,TABLE_TAGS, TAG, MODULE, ID, USER_ID));
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_TAGS,e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String delete(long userId, String module, long entityId, String tag) {
|
||||
try {
|
||||
Query.delete().from(TABLE_TAGS)
|
||||
.where(TAG,equal(tag)).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,equal(userId))
|
||||
.execute(db);
|
||||
return tag;
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Failed to save tag {0}",tag);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(){
|
||||
var version = createTables();
|
||||
LOG.log(INFO,"Updated task db to version {0}",version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> list(long userId, String module, long entityId) {
|
||||
try {
|
||||
var tags = new HashSet<String>();
|
||||
var rs = select(TAG).from(TABLE_TAGS).where(MODULE,equal(module)).where(ID,equal(entityId)).where(USER_ID,equal(userId)).exec(db);
|
||||
while (rs.next()) tags.add(rs.getString(1));
|
||||
rs.close();
|
||||
return tags;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load tags");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String save(Collection<Long> userIds, String module, long entityId, String tag) {
|
||||
try {
|
||||
var query = replaceInto(TABLE_TAGS,USER_ID,MODULE,ID,TAG);
|
||||
for (var userId : userIds) query.values(userId,module,entityId,tag);
|
||||
query.execute(db).close();
|
||||
return tag;
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Failed to save tag {0}",tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
tags/src/main/java/de/srsoftware/umbrella/tags/TagDB.java
Normal file
13
tags/src/main/java/de/srsoftware/umbrella/tags/TagDB.java
Normal file
@@ -0,0 +1,13 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.tags;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public interface TagDB {
|
||||
Object delete(long userId, String module, long entityId, String tag);
|
||||
|
||||
Set<String> list(long id, String module, long entityId);
|
||||
|
||||
String save(Collection<Long> userIds, String module, long entityId, String tag);
|
||||
}
|
||||
112
tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
Normal file
112
tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.tags;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
|
||||
import static de.srsoftware.umbrella.tags.Constants.CONFIG_DATABASE;
|
||||
import static de.srsoftware.umbrella.tags.Constants.TAG;
|
||||
import static java.net.HttpURLConnection.HTTP_OK;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.tools.SessionToken;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.api.TagService;
|
||||
import de.srsoftware.umbrella.core.api.UserService;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Token;
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class TagModule extends BaseHandler implements TagService {
|
||||
private final SqliteDb tagDb;
|
||||
private final UserService users;
|
||||
|
||||
public TagModule(Configuration config, UserService userService) {
|
||||
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
|
||||
tagDb = new SqliteDb(connect(dbFile));
|
||||
users = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
try {
|
||||
Optional<Token> token = SessionToken.from(ex).map(Token::of);
|
||||
var user = users.loadUser(token);
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var module = path.pop();
|
||||
if (module == null) throw unprocessable("Module missing in path.");
|
||||
var head = path.pop();
|
||||
long entityId = Long.parseLong(head);
|
||||
var tag = tagDb.delete(user.get().id(),module,entityId,body(ex));
|
||||
return sendContent(ex, tag);
|
||||
} catch (NumberFormatException e){
|
||||
return sendContent(ex,HTTP_UNPROCESSABLE,"Entity id missing in path.");
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGet(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
try {
|
||||
Optional<Token> token = SessionToken.from(ex).map(Token::of);
|
||||
var user = users.loadUser(token);
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var module = path.pop();
|
||||
if (module == null) throw unprocessable("Module missing in path.");
|
||||
var head = path.pop();
|
||||
long entityId = Long.parseLong(head);
|
||||
var tags = tagDb.list(user.get().id(),module,entityId);
|
||||
return sendContent(ex, tags);
|
||||
} catch (NumberFormatException e){
|
||||
return sendContent(ex,HTTP_UNPROCESSABLE,"Entity id missing in path.");
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
return sendEmptyResponse(HTTP_OK,ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPost(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
try {
|
||||
Optional<Token> token = SessionToken.from(ex).map(Token::of);
|
||||
var user = users.loadUser(token);
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var module = path.pop();
|
||||
if (module == null) throw unprocessable("Module missing in path.");
|
||||
var head = path.pop();
|
||||
long entityId = Long.parseLong(head);
|
||||
var json = json(ex);
|
||||
if (!(json.has(TAG) && json.get(TAG) instanceof String tag)) throw missingFieldException(TAG);
|
||||
List<Long> userList = json.has(USER_LIST) && json.get(USER_LIST) instanceof JSONArray arr ?
|
||||
arr.toList().stream().filter(elem -> elem instanceof Number).map(elem -> (Number) elem).map(Number::longValue).toList()
|
||||
: List.of(user.get().id());
|
||||
if (userList.isEmpty()) throw missingFieldException(USER_LIST);
|
||||
tag = tagDb.save(userList, module, entityId, tag);
|
||||
return sendContent(ex, tag);
|
||||
} catch (NumberFormatException e) {
|
||||
return sendContent(ex, HTTP_UNPROCESSABLE, "Entity id missing in path.");
|
||||
} catch (UmbrellaException e) {
|
||||
return send(ex, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,8 +6,6 @@ import static de.srsoftware.tools.jdbc.Condition.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_NOT_IMPLEMENTED;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||
import static de.srsoftware.umbrella.core.model.Status.OPEN;
|
||||
import static de.srsoftware.umbrella.project.Constants.*;
|
||||
import static de.srsoftware.umbrella.task.Constants.*;
|
||||
@@ -19,7 +17,6 @@ import de.srsoftware.tools.jdbc.Query;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
package de.srsoftware.umbrella.task;
|
||||
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Permission;
|
||||
import de.srsoftware.umbrella.core.model.Task;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -30,10 +30,9 @@ import de.srsoftware.umbrella.core.model.*;
|
||||
import de.srsoftware.umbrella.core.model.Task;
|
||||
import de.srsoftware.umbrella.core.model.Token;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class TaskModule extends BaseHandler implements TaskService {
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@
|
||||
"subject": "Betreff",
|
||||
"subtasks": "Unteraufgaben",
|
||||
|
||||
"tags": "Tags",
|
||||
"task": "Aufgabe",
|
||||
"tasks": "Aufgaben",
|
||||
"tax_id": "Steuernummer",
|
||||
|
||||
@@ -5,7 +5,6 @@ import static de.srsoftware.tools.jdbc.Condition.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||
import static de.srsoftware.umbrella.user.Constants.*;
|
||||
import static de.srsoftware.umbrella.user.model.DbUser.ADMIN_PERMISSIONS;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
@@ -195,3 +195,15 @@ textarea{
|
||||
display: block;
|
||||
margin: 5px 0 5px auto;
|
||||
}
|
||||
|
||||
.taglist .editor > span{
|
||||
display: inline-block;
|
||||
min-width: 150px;
|
||||
min-height: 1.3em;
|
||||
}
|
||||
|
||||
.taglist .tag button{
|
||||
background: transparent;
|
||||
color: orange;
|
||||
border: 0 none;
|
||||
}
|
||||
Reference in New Issue
Block a user