Compare commits
5
Commits
072ba5d4e5
...
1553546f66
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1553546f66 | ||
|
|
d2d534cb14 | ||
|
|
e41932cb9f | ||
|
|
d95f4359f0 | ||
|
|
75814a86eb |
@@ -139,6 +139,7 @@ public class Field {
|
||||
|
||||
public static final String RECEIVERS = "receivers";
|
||||
public static final String REDIRECT = "redirect";
|
||||
public static final String RENDER = "render";
|
||||
public static final String RENDERED = "rendered";
|
||||
public static final String REQUIRED_TASKS_IDS = "required_tasks_ids";
|
||||
|
||||
|
||||
@@ -118,8 +118,7 @@ public class Project extends UmbrellaObject {
|
||||
return tagColors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
public Map<String, Object> toMap(boolean renderMarkdown){
|
||||
var memberMap = new HashMap<Long,Map<String,Object>>();
|
||||
if (members != null) for (var entry : members.entrySet()){
|
||||
memberMap.put(entry.getKey(),entry.getValue().toMap());
|
||||
@@ -128,7 +127,7 @@ public class Project extends UmbrellaObject {
|
||||
for (var state : allowedStates) stateMap.put(state.code(),state.name());
|
||||
return super.map(
|
||||
NAME,name,
|
||||
DESCRIPTION,mapMarkdown(description),
|
||||
DESCRIPTION, renderMarkdown ? mapMarkdown(description) : Map.of(SOURCE,description),
|
||||
STATUS,status,
|
||||
COMPANY_ID,companyId,
|
||||
SHOW_CLOSED,showClosed,
|
||||
@@ -137,6 +136,11 @@ public class Project extends UmbrellaObject {
|
||||
TAG_COLORS,tagColors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return toMap(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
let selected = $state(null);
|
||||
let candidates = $state([]);
|
||||
let timer = null;
|
||||
let list_elem;
|
||||
let input, list_elem;
|
||||
|
||||
async function dummyGetCandidates(text){
|
||||
console.warn(`getCandidates(${text}) not overridden!`);
|
||||
@@ -117,6 +117,7 @@
|
||||
function select(index){
|
||||
candidate = candidates[index];
|
||||
disableDropdown();
|
||||
input.focus();
|
||||
onSelect(candidate);
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@
|
||||
</style>
|
||||
|
||||
<span class="autocomplete">
|
||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} disabled={!enabled} />
|
||||
<input bind:this={input} type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} disabled={!enabled} />
|
||||
{#if candidates && candidates.length > 0}
|
||||
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
||||
{#each candidates as candidate,i}
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
const url = api('task/list');
|
||||
selector.show_closed = true;
|
||||
selector.no_index = true;
|
||||
selector.rendered = false;
|
||||
selector.render = false;
|
||||
var resp = await post(url,selector);
|
||||
if (resp.ok){
|
||||
var json = await resp.json();
|
||||
|
||||
@@ -108,13 +108,10 @@
|
||||
const url = api('task/list');
|
||||
const data = {
|
||||
project_id:+id,
|
||||
show_closed:project.show_closed
|
||||
show_closed:project.show_closed,
|
||||
render: false
|
||||
}
|
||||
const resp = await fetch(url,{
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(data)
|
||||
});
|
||||
const resp = await post(url,data);
|
||||
if (resp.ok){
|
||||
tasks = {};
|
||||
est_time.sum = 0;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
}
|
||||
|
||||
async function loadProject(pid){
|
||||
const url = api(`project/${pid}`);
|
||||
const url = api(`project/${pid}?render=false`);
|
||||
const resp = await get(url);
|
||||
if (resp.ok){
|
||||
projects[pid] = await resp.json();
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
|
||||
async function load(){
|
||||
const url = api(`task?offset=${bounds.offset}&limit=${bounds.limit}`);
|
||||
const url = api(`task?offset=${bounds.offset}&limit=${bounds.limit}&render=false`);
|
||||
const resp = await get(url);
|
||||
if (resp.ok){
|
||||
let newTasks = await resp.json();
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
const url = api('task/list');
|
||||
const data = {
|
||||
parent_task_id : +task.id,
|
||||
show_closed : show_closed
|
||||
show_closed : show_closed,
|
||||
render : false
|
||||
};
|
||||
if (task.show_closed) data.show_closed = true;
|
||||
const resp = await post(url,data);
|
||||
|
||||
@@ -144,9 +144,11 @@ public class ProjectModule extends BaseHandler implements ProjectService {
|
||||
}
|
||||
|
||||
private boolean getProject(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException, UmbrellaException {
|
||||
var params = queryParam(ex);
|
||||
var render = !(params.get(RENDER) instanceof String r) || r.equals("true");
|
||||
var project = loadMembers(projectDb.load(projectId));
|
||||
if (!project.hasMember(user)) throw notAmember(t(PROJECT_WITH_ID,ID,project.name()));
|
||||
var map = project.toMap();
|
||||
var map = project.toMap(render);
|
||||
project.companyId().map(companyService()::get).map(Company::toMap).ifPresent(data -> map.put(Field.COMPANY,data));
|
||||
return sendContent(ex,map);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ public class TagModule extends BaseHandler implements TagService {
|
||||
tagDb.deleteEntity(module,entityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEntity(String module, long entityId, long userId) {
|
||||
tagDb.deleteEntity(module,entityId,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
@@ -137,9 +142,11 @@ public class TagModule extends BaseHandler implements TagService {
|
||||
return sendContent(ex,tuples.map(t -> Map.of(TAG,t.a,COUNT,t.b)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEntity(String module, long entityId, long userId) {
|
||||
tagDb.deleteEntity(module,entityId,userId);
|
||||
private String modifyCase(String entry, String key, String lKey) {
|
||||
if (entry.toLowerCase().startsWith(lKey)) return key + entry.substring(key.length());
|
||||
var pos = entry.toLowerCase().indexOf(" "+lKey);
|
||||
if (pos >= 0) entry = entry.substring(0,pos+1)+key+entry.substring(pos+key.length()+1);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,8 +165,10 @@ public class TagModule extends BaseHandler implements TagService {
|
||||
return tagDb.search(key, user);
|
||||
}
|
||||
|
||||
private boolean searchTags(HttpExchange ex, String head, UmbrellaUser user) throws IOException {
|
||||
return sendContent(ex, search(head, user));
|
||||
private boolean searchTags(HttpExchange ex, String key, UmbrellaUser user) throws IOException {
|
||||
var tags = search(key, user);
|
||||
var lKey = key.toLowerCase();
|
||||
return sendContent(ex, tags.stream().map(entry -> modifyCase(entry, key, lKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -280,8 +280,9 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
} catch (NumberFormatException e) {
|
||||
throw invalidField(LIMIT, t(Text.NUMBER));
|
||||
}
|
||||
var render = !(params.get(RENDER) instanceof String r) || r.equals("true");
|
||||
var tasks = taskDb.listUserTasks(user.id(), limit, offset, false);
|
||||
var mapped = loadMembers(tasks).stream().map(Task::toMap);
|
||||
var mapped = loadMembers(tasks).stream().map(t -> t.toMap(render));
|
||||
return sendContent(ex, mapped);
|
||||
}
|
||||
|
||||
@@ -474,24 +475,26 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
var noIndex = json.has(NO_INDEX) && json.get(NO_INDEX) instanceof Boolean bool ? bool : false;
|
||||
var projectId = json.has(PROJECT_ID) && json.get(PROJECT_ID) instanceof Number number ? number.longValue() : null;
|
||||
var parentTaskId = json.has(PARENT_TASK_ID) && json.get(PARENT_TASK_ID) instanceof Number number ? number.longValue() : null;
|
||||
var markdown = !json.has(RENDERED) || !(json.get(RENDERED) instanceof Boolean render) || render;
|
||||
var render = !json.has(RENDER) || !(json.get(RENDER) instanceof Boolean bool) || bool;
|
||||
if (isSet(projectId)) {
|
||||
if (parentTaskId == null) {
|
||||
var list = taskDb.listRootTasks(projectId, user, showClosed);
|
||||
return sendContent(ex, mapTasks(list,markdown));
|
||||
return sendContent(ex, mapTasks(list,render));
|
||||
}
|
||||
var projectTasks = taskDb.listProjectTasks(projectId, parentTaskId, noIndex);
|
||||
loadMembers(projectTasks.values());
|
||||
var tags = tagService().getTags(TASK,projectTasks.keySet(),user);
|
||||
|
||||
projectTasks = addTags(projectTasks, tags);
|
||||
return sendContent(ex, mapTasks(projectTasks, markdown));
|
||||
return sendContent(ex, mapTasks(projectTasks, render));
|
||||
}
|
||||
if (isSet(parentTaskId)) return sendContent(ex, mapValues(taskDb.listChildrenOf(parentTaskId, user, showClosed)));
|
||||
var taskIds = json.has(IDS) && json.get(IDS) instanceof JSONArray ids ? ids.toList().stream().map(Object::toString).map(Long::parseLong).toList() : null;
|
||||
var tasks = taskDb.load(taskIds);
|
||||
if (isSet(taskIds)) return sendContent(ex, mapTasks(tasks,markdown));
|
||||
return sendEmptyResponse(HTTP_NOT_IMPLEMENTED, ex);
|
||||
Map<Long, Task> tasks;
|
||||
if (!isSet(parentTaskId)) {
|
||||
var taskIds = json.has(IDS) && json.get(IDS) instanceof JSONArray ids ? ids.toList().stream().map(Object::toString).map(Long::parseLong).toList() : null;
|
||||
if (!isSet(taskIds)) return sendEmptyResponse(HTTP_NOT_IMPLEMENTED,ex);
|
||||
tasks = taskDb.load(taskIds);
|
||||
} else tasks = taskDb.listChildrenOf(parentTaskId,user,showClosed);
|
||||
return sendContent(ex, mapTasks(tasks,render));
|
||||
}
|
||||
|
||||
private Map<Long, Task> addTags(Map<Long, Task> taskList, Map<Long, ? extends Collection<String>> tags) {
|
||||
|
||||
Reference in New Issue
Block a user