This is a test list
+ assert_eq!(note.to_html(), r#"This is a test list
Kan de lijsten niet laden!
" + @@ -44,100 +44,100 @@ function initLists() { }); } -function getListElem(listId) { - return $('.list[data-list-id="' + listId + '"]'); +function getNoteElem(noteId) { + return $('.note[data-note-id="' + noteId + '"]'); } -function selectList(listId) { - if (listId) { - console.debug("Selecting list " + listId); - lists.forEach(function(list) { - var listElem = getListElem(list.id); - if (list.id == listId) { - listElem.show(200); +function selectNote(noteId) { + if (noteId) { + console.debug("Selecting note " + noteId); + notes.forEach(function(note) { + var noteElem = getNoteElem(note.id); + if (note.id == noteId) { + noteElem.show(200); } else { - listElem.hide(200); + noteElem.hide(200); } }); } else { - console.debug("Showing all lists"); - lists.forEach(function(list) { - var listElem = getListElem(list.id); - listElem.show(200); + console.debug("Showing all notes"); + notes.forEach(function(note) { + var noteElem = getNoteElem(note.id); + noteElem.show(200); }); } $("#navbarNav").collapse('hide'); } -function updateList(list) { - var listElem = $('.list[data-list-id="' + list.id + '"]'); - listElem.addClass("bg-" + bgColors[list.index]) - .addClass("text-" + textColors[list.index]); - $('.list-name', listElem).text(list.name); - mtime = new Date(list.mtime.secs_since_epoch * 1000); - $('.list-updated-at', listElem).text('Laatste aanpassing op ' + +function updateNote(note) { + var noteElem = $('.note[data-note-id="' + note.id + '"]'); + noteElem.addClass("bg-" + bgColors[note.index]) + .addClass("text-" + textColors[note.index]); + $('.note-name', noteElem).text(note.name); + mtime = new Date(note.mtime.secs_since_epoch * 1000); + $('.note-updated-at', noteElem).text('Laatste aanpassing op ' + mtime.toLocaleDateString("nl") + ' om ' + mtime.toLocaleTimeString("nl")); - $('.list-data', listElem).val(list.data); + $('.note-data', noteElem).val(note.data); - updateListHTML(listElem); + updateNoteHTML(noteElem); - disableListEditMode(listElem); + disableNoteEditMode(noteElem); } -function updateListHTML(listElem) { - var listId = listElem.data("list-id"); - var listHtmlElem = $('.list-html', listElem) +function updateNoteHTML(noteElem) { + var noteId = noteElem.data("note-id"); + var noteHtmlElem = $('.note-html', noteElem) $.ajax({ - url: '/lists/' + listId, + url: '/notes/' + noteId, headers: { 'Accept': 'text/html' } }).done(function(html) { - listHtmlElem.html(html); - $("ul > li", listHtmlElem).has('input[type="checkbox"]') + noteHtmlElem.html(html); + $("ul > li", noteHtmlElem).has('input[type="checkbox"]') .parent() - .addClass("tasklist"); - if (listHtmlElem.find('hr').length) { - listHtmlElem.find('hr') + .addClass("tasknote"); + if (noteHtmlElem.find('hr').length) { + noteHtmlElem.find('hr') .nextAll() - .wrapAll('') - listHtmlElem.append('(Technische foutmelding: " + error + " (" + textMsg + "))
"); }); } -function saveListChanges(listElem) { - var listId = listElem.data("list-id"); - var list = lists.find(function(list) { return list.id == listId }); - var old_data = list.data; - list.data = $('.list-data', listElem).val(); +function saveNoteChanges(noteElem) { + var noteId = noteElem.data("note-id"); + var note = notes.find(function(note) { return note.id == noteId }); + var old_data = note.data; + note.data = $('.note-data', noteElem).val(); $.ajax({ method: 'PUT', - url: '/lists/' + listId, + url: '/notes/' + noteId, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, - data: JSON.stringify(list) - }).done(updateList) + data: JSON.stringify(note) + }).done(updateNote) .fail(function(jqXHR, textMsg, error) { - list.data = old_data; + note.data = old_data; showErrorDialog("Opslaan mislukt!", "Kan de lijst niet opslaan! Probeer later nog eens of " + "annuleer de bewerking.
" + @@ -147,35 +147,35 @@ function saveListChanges(listElem) { }); } -function revertListChanges(listElem) { - var listId = listElem.data("list-id"); - var list = lists.find(function(list) { return list.id == listId }); +function revertNoteChanges(noteElem) { + var noteId = noteElem.data("note-id"); + var note = notes.find(function(note) { return note.id == noteId }); - disableListEditMode(listElem); + disableNoteEditMode(noteElem); - $('.list-data', listElem).val(list.data); + $('.note-data', noteElem).val(note.data); } -function disableListEditMode(listElem) { - $('.list-data', listElem).hide(200) +function disableNoteEditMode(noteElem) { + $('.note-data', noteElem).hide(200) .popover('hide'); - $('.list-html', listElem).show(200); - $('.list-edit-buttons', listElem).hide(200); - $('.list-edit-mode-buttons', listElem).show(200); - $('.list-edit-help', listElem).removeClass('active') + $('.note-html', noteElem).show(200); + $('.note-edit-buttons', noteElem).hide(200); + $('.note-edit-mode-buttons', noteElem).show(200); + $('.note-edit-help', noteElem).removeClass('active') .popover('hide'); } -function enableListEditMode(listElem) { - $('.list-data', listElem).show(200); - $('.list-html', listElem).hide(200); - $('.list-edit-mode-buttons', listElem).hide(200); - $('.list-edit-buttons', listElem).show(200); +function enableNoteEditMode(noteElem) { + $('.note-data', noteElem).show(200); + $('.note-html', noteElem).hide(200); + $('.note-edit-mode-buttons', noteElem).hide(200); + $('.note-edit-buttons', noteElem).show(200); } $(function() { - $('.lists-refresh').on('click', function() { - if ($(".list-data:visible").length) { + $('.notes-refresh').on('click', function() { + if ($(".note-data:visible").length) { showErrorDialog("Kan niet verversen tijdens bewerken!", "Het is niet mogelijk om de lijsten te verversen als er " + "op dit moment een lijst bewerkt wordt.
" + @@ -183,41 +183,41 @@ $(function() { "bewerking.", true); } else { - initLists(); + initNotes(); } }); - $('.list-cancel-button').on('click', function() { - var listElem = $(this).parents(".list"); - console.debug("Cancelling the edit of list " + listElem.data("list-id")); - revertListChanges(listElem); + $('.note-cancel-button').on('click', function() { + var noteElem = $(this).parents(".note"); + console.debug("Cancelling the edit of note " + noteElem.data("note-id")); + revertNoteChanges(noteElem); }); - $('.list-edit-button').on('click', function() { - var listElem = $(this).parents(".list"); - console.debug("Going to edit list " + listElem.data("list-id")); - enableListEditMode(listElem); + $('.note-edit-button').on('click', function() { + var noteElem = $(this).parents(".note"); + console.debug("Going to edit note " + noteElem.data("note-id")); + enableNoteEditMode(noteElem); }); - $('.list-edit-help').on('click', function() { - var listElem = $(this).parents(".list"); - var listDataElem = $('.list-data', listElem); + $('.note-edit-help').on('click', function() { + var noteElem = $(this).parents(".note"); + var noteDataElem = $('.note-data', noteElem); $(this).toggleClass('active') - listDataElem.popover('toggle'); + noteDataElem.popover('toggle'); }); - $('.list-save-button').on('click', function() { - var listElem = $(this).parents(".list"); - console.debug("Saving the changes for list " + listElem.data("list-id")); - saveListChanges(listElem); + $('.note-save-button').on('click', function() { + var noteElem = $(this).parents(".note"); + console.debug("Saving the changes for note " + noteElem.data("note-id")); + saveNoteChanges(noteElem); }); - $('.list-select').on('click', function() { - listId = $(this).data('list-id'); - selectList(listId); + $('.note-select').on('click', function() { + noteId = $(this).data('note-id'); + selectNote(noteId); }); - initLists(); + initNotes(); $('textarea').popover({ html: true, trigger: 'manual' diff --git a/static/scss/pinboard.scss b/static/scss/pinboard.scss index 48c4c2e..4c15399 100644 --- a/static/scss/pinboard.scss +++ b/static/scss/pinboard.scss @@ -21,14 +21,14 @@ footer { line-height: 24px; } -// Reduce the large padding for lists -.list-html ul, -.list-html ol { +// Reduce the large padding for notes +.note-html ul, +.note-html ol { padding-left: 1.2rem; } -.list-html ul.tasklist { - list-style-type: none; +.note-html ul.tasknote { + note-style-type: none; padding-left: 0; } diff --git a/templates/_layout.html.tera b/templates/_layout.html.tera index 6b8c246..40fc1da 100644 --- a/templates/_layout.html.tera +++ b/templates/_layout.html.tera @@ -34,7 +34,7 @@ {% block body %}