deleting tasks should be possible
This commit is contained in:
parent
75d4236522
commit
b79d46efee
@ -72,6 +72,13 @@ class API extends Application
|
||||
|
||||
return json: { success: true, :task }
|
||||
|
||||
[delete: "/delete"]: api_request =>
|
||||
get_task(@)
|
||||
if @task\delete!
|
||||
return json: { success: true }
|
||||
else
|
||||
abort 500, "Error deleting task."
|
||||
|
||||
[random: "/random"]: api_request =>
|
||||
assert_valid @params, {
|
||||
{"count", exists: true, is_integer: true, optional: true, "Count is not an integer."}
|
||||
|
@ -39,4 +39,7 @@ make_migrations {
|
||||
|
||||
[1524607145]: =>
|
||||
settings.set "simplex.key-increment", 100 -- I had been accidentally deleting this key over and over again
|
||||
|
||||
-- technically there should be a migration here to wipe out the api_keys table
|
||||
-- due to a strange bug with how adding an id to api_keys works (I think)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ function new_task() {
|
||||
let template;
|
||||
$.post("/v1/new", {content: input.val()}, function(data) {
|
||||
template = get_template("#task-template");
|
||||
let input = $("input", template);
|
||||
let input = $("input:checkbox", template);
|
||||
input.prop("id", "task-" + data.task.id);
|
||||
input.change(function() {
|
||||
check(data.task.id);
|
||||
@ -84,13 +84,21 @@ function delete_item(e) {
|
||||
|
||||
checkbox = $("input:checkbox", e);
|
||||
if (checkbox.length) {
|
||||
// TODO find task id, send delete request, hide item
|
||||
// success? delete item, failure? add_error to item and unhide it (how? display: block;)
|
||||
e.css("display", "hidden");
|
||||
let id = checkbox.prop("id");
|
||||
id = Number(id.slice(id.lastIndexOf("-") + 1, id.length))
|
||||
$.post("/v1/delete", {id: id}, function(data) {
|
||||
e.remove();
|
||||
})
|
||||
.fail(function(request) {
|
||||
add_error($(".row", e));
|
||||
e.css("display", "block");
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
code = $("code", e);
|
||||
if (code) {
|
||||
if (code.length) {
|
||||
e.css("display", "hidden"); // hide it
|
||||
$.post("/v1/key/delete", {key: code.text()}, function(data) {
|
||||
e.remove();
|
||||
|
@ -4,7 +4,6 @@ class LoggedIn extends Widget
|
||||
content: =>
|
||||
task_item = (task) ->
|
||||
li ->
|
||||
-- input type: "hidden", class: "task-id", value: task and task.id or nil
|
||||
div class: "row", ->
|
||||
div class: "column column-80", ->
|
||||
if task
|
||||
|
Loading…
Reference in New Issue
Block a user