wip, testing use of "this"
This commit is contained in:
parent
1646709f7e
commit
507c22c116
@ -27,16 +27,16 @@ function new_task() {
|
||||
}
|
||||
|
||||
function new_api_key() {
|
||||
$.get("/v1/key/new", function(data, status) {
|
||||
let template = $("#api-key-template").html();
|
||||
template = $(template);
|
||||
let template = $("#api-key-template").html();
|
||||
template = $(template);
|
||||
$.get("/v1/key/new", function(data) {
|
||||
$("code", template).text(data.api_key.key);
|
||||
$("#new-api-key").before(template);
|
||||
}).fail(function(a) {
|
||||
console.log(a);
|
||||
let template = $("#api-key-template").html();
|
||||
template = $(template);
|
||||
$("code", template).text("Failure!");
|
||||
}).fail(function() {
|
||||
$("code", template)
|
||||
.css("background-color", "red")
|
||||
.css("color", "white")
|
||||
.text(this.responseJSON.errors.join(" "));
|
||||
$("#new-api-key").before(template);
|
||||
});
|
||||
}
|
||||
@ -46,5 +46,6 @@ function delete_item(e) {
|
||||
while (!e.is("li")) {
|
||||
e = e.parent();
|
||||
}
|
||||
// TODO here, grab content to delete by (for api_key), send delete request, hide element (delete on success, reappear with red on failure)
|
||||
e.remove();
|
||||
}
|
||||
|
@ -2,6 +2,11 @@ import Widget from require "lapis.html"
|
||||
|
||||
class LoggedIn extends Widget
|
||||
content: =>
|
||||
task_item = (task={}) ->
|
||||
li ->
|
||||
input type: "checkbox", id: "task-#{task.id}", onchange: "check(#{task.id});", checked: task.done
|
||||
text " #{task.content}"
|
||||
|
||||
api_key_item = (key="") ->
|
||||
li ->
|
||||
div class: "row", ->
|
||||
@ -10,18 +15,19 @@ class LoggedIn extends Widget
|
||||
div class: "column column-offset-20 column-20", ->
|
||||
button class: "delete", onclick: "delete_item(this);", "x"
|
||||
|
||||
script -> raw "var API_KEY = '#{@keys[1].key}';"
|
||||
script -> raw "var API_KEY = '#{@keys[1].key}';" -- TODO will be removed soon
|
||||
script src: "/static/index.js"
|
||||
|
||||
script id: "task-template", type: "text/x-custom-template", ->
|
||||
task_item!
|
||||
script id: "api-key-template", type: "text/x-custom-template", ->
|
||||
api_key_item!
|
||||
|
||||
ul style: "list-style: none;", ->
|
||||
if @tasks
|
||||
for task in *@tasks
|
||||
li ->
|
||||
input type: "checkbox", id: "task-#{task.id}", onchange: "check(#{task.id});", checked: task.done
|
||||
text " #{task.content}"
|
||||
task_item task
|
||||
|
||||
li id: "new-task", ->
|
||||
form {
|
||||
onsubmit: "return new_task();"
|
||||
@ -36,5 +42,6 @@ class LoggedIn extends Widget
|
||||
if @keys
|
||||
for key in *@keys
|
||||
api_key_item key.key
|
||||
|
||||
li id: "new-api-key", ->
|
||||
button onclick: "new_api_key()", "New API Key"
|
||||
|
Loading…
Reference in New Issue
Block a user