Add note deletion
This commit is contained in:
parent
552ccf4ff7
commit
20dbd0a613
@ -13,6 +13,30 @@ class NotePostNotes extends Notes {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
del(noteid, callback) {
|
||||
super.del(noteid);
|
||||
var self = this;
|
||||
$.ajax({
|
||||
url: this.server + "/api/deletenote",
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
method: "POST",
|
||||
data: {
|
||||
id: noteid
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(self.username + ":" + self.password));
|
||||
}, success: function (val) {
|
||||
if (val.status == "OK") {
|
||||
self.notes = val.notes;
|
||||
}
|
||||
if (typeof callback == 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
add(note, callback) {
|
||||
note.norealid = true;
|
||||
super.add(note, callback);
|
||||
|
@ -36,6 +36,19 @@ class Notes {
|
||||
this.notes.push(note);
|
||||
}
|
||||
|
||||
del(noteid, callback) {
|
||||
var newnotearr = [];
|
||||
for (var i = 0; i < this.notes.length; i++) {
|
||||
if (this.notes[i].id != noteid) {
|
||||
newnotearr.push(this.notes[i]);
|
||||
}
|
||||
}
|
||||
this.notes = newnotearr;
|
||||
if (typeof callback == 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
add(note, callback) {
|
||||
this.notes.push(note);
|
||||
if (typeof callback == 'function') {
|
||||
|
@ -40,7 +40,7 @@ function saveme(callback) {
|
||||
}
|
||||
|
||||
function exiteditor() {
|
||||
if ($("note_content").val() == "" || $("note_content").val() === $("orig_content").val()) {
|
||||
if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) {
|
||||
router.back({force: true, ignoreCache: true, reload: true});
|
||||
} else {
|
||||
saveme(function () {
|
||||
|
@ -6,18 +6,18 @@
|
||||
|
||||
|
||||
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
||||
router.navigate("/home");
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
function editNote(id) {
|
||||
var note = notes.get(id);
|
||||
router.navigate("/editnote", {
|
||||
context: {
|
||||
noteid: id,
|
||||
content: note.content,
|
||||
notetitle: note.title,
|
||||
}
|
||||
});
|
||||
context: {
|
||||
noteid: id,
|
||||
content: note.content,
|
||||
notetitle: note.title,
|
||||
}
|
||||
});
|
||||
console.log("Editing " + id);
|
||||
}
|
||||
|
||||
@ -30,7 +30,11 @@ function makeList(id) {
|
||||
}
|
||||
|
||||
function deleteNote(id) {
|
||||
|
||||
app.dialog.confirm('Are you sure?', 'Delete Note', function () {
|
||||
notes.del(id, function () {
|
||||
app.ptr.refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#app").on("click", ".edit-note-btn", function () {
|
||||
@ -66,20 +70,20 @@ function openNoteActionMenu(notecard) {
|
||||
editNote(noteid);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Favorite",
|
||||
icon: '<i class="fas fa-star fa-fw"></i>',
|
||||
onClick: function () {
|
||||
favoriteNote(noteid);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "Make a List",
|
||||
icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||
onClick: function () {
|
||||
makeList(noteid);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// text: "Favorite",
|
||||
// icon: '<i class="fas fa-star fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// favoriteNote(noteid);
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// text: "Make a List",
|
||||
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||
// onClick: function () {
|
||||
// makeList(noteid);
|
||||
// }
|
||||
// },
|
||||
{
|
||||
text: "Delete",
|
||||
icon: '<i class="fas fa-trash fa-fw"></i>',
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
<div class="page-content ptr-content">
|
||||
|
||||
<textarea id="note_content" data-noteid="{{noteid}}" style="z-index: 99999999;">{{content}}</textarea>
|
||||
<textarea id="note_content" data-noteid="{{noteid}}">{{content}}</textarea>
|
||||
<textarea id="orig_content" style="display: none;">{{content}}</textarea>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user