request accept/remove added

This commit is contained in:
Michael Wain 2024-07-08 04:26:38 +03:00
parent c68a35ef82
commit 2712fa915e
5 changed files with 43 additions and 8 deletions

View File

@ -196,6 +196,20 @@ public class DatabaseController {
return "ok";
}
@PostMapping("/api/accept_script_request")
public String accept_script_request(@RequestParam Map<String, String> params) {
long entry_id = Long.parseLong(params.get("entry_id"));
ActionScriptRequest req = actionRequestService.getActionScriptById(entry_id);
String scriptBody = req.getScriptBody();
String name_text = req.getTextName();
TextDataVal t1 = textDataValService.save(new TextDataVal(name_text));
String desc_text = req.getTextDesc();
TextDataVal t2 = textDataValService.save(new TextDataVal(desc_text));
actionService.saveScript(new ActionScript(t1.getId(), t2.getId(), scriptBody));
actionRequestService.removeById(entry_id);
return "ok";
}
@PostMapping("/public/api/add_entry_request")
public String add_entry_request(@RequestParam Map<String, String> params) {
saveActionRequest(params);
@ -213,6 +227,7 @@ public class DatabaseController {
case "heal" -> healthService.removeById(entry_id);
case "prof" -> workService.removeById(entry_id);
case "actions" -> actionService.removeById(entry_id);
case "script_request" -> actionRequestService.removeById(entry_id);
default -> disasterService.removeById(entry_id);
}
return "ok";

View File

@ -68,4 +68,5 @@ scrieditti=Script editor
scrieditde=Below you can write a script for Bunker's action card. On the left side you will find code snippets, that will help with it. Happy coding!
edditaddbtn=Edit/Add
edditreq=Send request
scrireqq=Script requests
scrireqq=Script requests
acceptbtnreq=Accept

View File

@ -68,4 +68,5 @@ scrieditti=Редактор скриптов (карточек действий)
scrieditde=Ниже в вашем распоряжении редактор скриптов для карт действий игры Бункер. Слева вы найдете готовые куски кода, которые вам помогут. Удачи!
edditaddbtn=Изменить/Добавить
edditreq=Отправить запрос
scrireqq=Запросы на скрипты
scrireqq=Запросы на скрипты
acceptbtnreq=Принять

View File

@ -170,6 +170,12 @@ function get_text_api(tid, cb) {
});
}
function accept_script_request(obj) {
$.post("/api/accept_script_request", "entry_id="+($(obj).attr("data-id")), function(data, status) {
window.location.reload();
});
}
function remove_entry(obj) {
$.post("/api/remove_entry", "section="+new URL(window.location.href).searchParams.get("section")+"&entry_id="+($(obj).attr("data-id")), function(data, status) {
window.location.reload();

View File

@ -86,9 +86,15 @@
<li th:text="${ll}"></li>
</ul>
</p>
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="" class="btn btn-primary" th:text="#{eddittsynn}"></a>
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
<th:block th:unless="${section == 'script_request'}">
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="" class="btn btn-primary" th:text="#{eddittsynn}"></a>
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
</th:block>
<th:block th:if="${section == 'script_request'}">
<a href="#" th:data-id="${cc.id}" onclick="accept_script_request(this)" class="btn btn-success" th:text="#{acceptbtnreq}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
</th:block>
</div>
</div>
</th:block>
@ -117,9 +123,15 @@
<li th:text="${ll}"></li>
</ul>
</p>
<a th:unless="${section == 'actions'}" href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="show_synergies_modal(this)" class="btn btn-primary" th:text="#{eddittsynn}"></a>
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
<th:block th:unless="${section == 'script_request'}">
<a th:unless="${section == 'actions'}" href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="show_synergies_modal(this)" class="btn btn-primary" th:text="#{eddittsynn}"></a>
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
</th:block>
<th:block th:if="${section == 'script_request'}">
<a href="#" th:data-id="${cc.id}" onclick="accept_script_request(this)" class="btn btn-success" th:text="#{acceptbtnreq}"></a>
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
</th:block>
</div>
</div>
</div>