|
| 1 | +{% extends "app/app_base.html" %} |
| 2 | +{% import "bootstrap/wtf.html" as wtf %} |
| 3 | +{% import "_macros.html" as macros %} |
| 4 | + |
| 5 | +{% block title %}BrainDump{% endblock %} |
| 6 | + |
| 7 | +{% block page_content %} |
| 8 | + |
| 9 | +{% if notes %} |
| 10 | +<div class="col-sm-11"> |
| 11 | +<h1 class="top"> TODO list </h1> |
| 12 | +<hr> |
| 13 | + |
| 14 | +<p> Hi {{ current_user.username }}! Here are all your TODOs. </p> |
| 15 | + |
| 16 | +{% for note in notes %} |
| 17 | + <div id="note{{note.id}}" hidden> |
| 18 | + {{note.body_html}} |
| 19 | + </div> |
| 20 | +{% endfor %} |
| 21 | + |
| 22 | +<div class="container"> |
| 23 | + <div class="row"> |
| 24 | + <div class="col-s-12"> |
| 25 | + <div class="table-responsive"> |
| 26 | + <table class="table table-bordered table-hover"> |
| 27 | + |
| 28 | + <thead> |
| 29 | + <tr> |
| 30 | + <th>TODO</th> |
| 31 | + <th>Note</th> |
| 32 | + <th>Created</th> |
| 33 | + <th>Completed</th> |
| 34 | + </tr> |
| 35 | + </thead> |
| 36 | + |
| 37 | + <tbody> |
| 38 | + {% for note in notes|sort(attribute='created_date') %} |
| 39 | + {% for todo in note.todo_items|sort(attribute='created_date') %} |
| 40 | + <tr> |
| 41 | + <td class="col-sm-2"> |
| 42 | + {% if todo.is_checked %} |
| 43 | + <input type="checkbox" onchange="checkUncheckDirect(this,{{ note.id }},{{todo.id}},'{{todo.title}}')" checked="checked"> |
| 44 | + {{ todo.title }} |
| 45 | + {% else %} |
| 46 | + <input type="checkbox" onchange="checkUncheckDirect(this,{{ note.id }},{{todo.id}},'{{todo.title}}')" > |
| 47 | + {{ todo.title }} |
| 48 | + {% endif %} |
| 49 | + </td> |
| 50 | + <td><a href="{{ url_for('.note', id=note.id) }}"><h5>{{ note.title | truncate(100) }}</h5></a></td> |
| 51 | + <td>{{ moment(todo.created_date).format("MMMM DD, YYYY") }}</td> |
| 52 | + <td>{% if todo.checked_date %} |
| 53 | + {{ moment(todo.checked_date).format("MMMM DD, YYYY") }} |
| 54 | + {% else %} |
| 55 | + Not yet completed! |
| 56 | + {% endif %} |
| 57 | + </td> |
| 58 | + </tr> |
| 59 | + {% endfor %} |
| 60 | + {% endfor %} |
| 61 | + |
| 62 | + |
| 63 | + </tbody> |
| 64 | + |
| 65 | + </table> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | +</div> |
| 70 | +</div> |
| 71 | + |
| 72 | + |
| 73 | +</div> |
| 74 | +{% endif %} |
| 75 | +{% endblock %} |
| 76 | + |
| 77 | +{% block scripts %} |
| 78 | +{{ super() }} |
| 79 | +<script src="{{ url_for('static', filename='js/libs/marked.js') }}"></script> |
| 80 | +<script src="{{ url_for('static', filename='js/libs/bootstrap-tagsinput.js') }}"></script> |
| 81 | +<script src="{{ url_for('static', filename='js/libs/releases.js') }}"></script> |
| 82 | +<script src="{{ url_for('static', filename='js/libs/ace/ace.js') }}"></script> |
| 83 | +<script src="{{ url_for('static', filename='js/braindump.js') }}"></script> |
| 84 | +<script src="{{ url_for('static', filename='js/braindump_editor.js') }}"></script> |
| 85 | +<script> |
| 86 | + |
| 87 | + |
| 88 | + function checkUncheckDirect(checkbox, note_id, todo_item_id, todo_item){ |
| 89 | + |
| 90 | + var property; |
| 91 | + if ($(checkbox).is(':checked') == false){ |
| 92 | + $(checkbox).removeAttr("checked"); |
| 93 | + property = "uncheck"; |
| 94 | + |
| 95 | + } |
| 96 | + else{ |
| 97 | + $(checkbox).attr("checked",""); |
| 98 | + property="check"; |
| 99 | + } |
| 100 | + |
| 101 | + var temp = $("#tempdiv"+note_id); |
| 102 | + console.log("len"+ temp.length); |
| 103 | + if (temp.length == 0){ |
| 104 | + var body_html = $('#note'+note_id).text(); |
| 105 | + temp = document.createElement('div'); |
| 106 | + temp.setAttribute("id", "tempdiv"+note_id); |
| 107 | + temp.innerHTML = body_html; |
| 108 | + $('#note'+note_id).append(temp); |
| 109 | + } |
| 110 | + else{ |
| 111 | + temp = temp.html(); |
| 112 | + } |
| 113 | + var li = $('#'+todo_item_id).find("input"); |
| 114 | + if (property == "uncheck") |
| 115 | + $(li).attr('checked', false); |
| 116 | + else |
| 117 | + $(li).attr('checked', true); |
| 118 | + |
| 119 | + body_html = $("#tempdiv"+note_id).html(); |
| 120 | + console.log("id is "+todo_item_id); |
| 121 | + |
| 122 | + $.ajax({ |
| 123 | + url: "/checkuncheck/", |
| 124 | + cache: false, |
| 125 | + type: "POST", |
| 126 | + data: {note_id : note_id, property: property, body_html: body_html, todo_item: todo_item,todo_item_id:todo_item_id}, |
| 127 | + success: function(result){ |
| 128 | + console.log(result); |
| 129 | + }, |
| 130 | + error: function(result){ |
| 131 | + console.log(result); |
| 132 | + } |
| 133 | + }); |
| 134 | + |
| 135 | +} |
| 136 | +</script> |
| 137 | +{% endblock %} |
0 commit comments