Add note deletion
This commit is contained in:
parent
552ccf4ff7
commit
20dbd0a613
@ -13,6 +13,30 @@ class NotePostNotes extends Notes {
|
|||||||
this.password = password;
|
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) {
|
add(note, callback) {
|
||||||
note.norealid = true;
|
note.norealid = true;
|
||||||
super.add(note, callback);
|
super.add(note, callback);
|
||||||
|
@ -36,6 +36,19 @@ class Notes {
|
|||||||
this.notes.push(note);
|
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) {
|
add(note, callback) {
|
||||||
this.notes.push(note);
|
this.notes.push(note);
|
||||||
if (typeof callback == 'function') {
|
if (typeof callback == 'function') {
|
||||||
|
@ -40,7 +40,7 @@ function saveme(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exiteditor() {
|
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});
|
router.back({force: true, ignoreCache: true, reload: true});
|
||||||
} else {
|
} else {
|
||||||
saveme(function () {
|
saveme(function () {
|
||||||
|
@ -6,18 +6,18 @@
|
|||||||
|
|
||||||
|
|
||||||
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
||||||
router.navigate("/home");
|
restartApplication();
|
||||||
});
|
});
|
||||||
|
|
||||||
function editNote(id) {
|
function editNote(id) {
|
||||||
var note = notes.get(id);
|
var note = notes.get(id);
|
||||||
router.navigate("/editnote", {
|
router.navigate("/editnote", {
|
||||||
context: {
|
context: {
|
||||||
noteid: id,
|
noteid: id,
|
||||||
content: note.content,
|
content: note.content,
|
||||||
notetitle: note.title,
|
notetitle: note.title,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("Editing " + id);
|
console.log("Editing " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,11 @@ function makeList(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteNote(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 () {
|
$("#app").on("click", ".edit-note-btn", function () {
|
||||||
@ -66,20 +70,20 @@ function openNoteActionMenu(notecard) {
|
|||||||
editNote(noteid);
|
editNote(noteid);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
text: "Favorite",
|
// text: "Favorite",
|
||||||
icon: '<i class="fas fa-star fa-fw"></i>',
|
// icon: '<i class="fas fa-star fa-fw"></i>',
|
||||||
onClick: function () {
|
// onClick: function () {
|
||||||
favoriteNote(noteid);
|
// favoriteNote(noteid);
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
text: "Make a List",
|
// text: "Make a List",
|
||||||
icon: '<i class="fas fa-tasks fa-fw"></i>',
|
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
||||||
onClick: function () {
|
// onClick: function () {
|
||||||
makeList(noteid);
|
// makeList(noteid);
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
text: "Delete",
|
text: "Delete",
|
||||||
icon: '<i class="fas fa-trash fa-fw"></i>',
|
icon: '<i class="fas fa-trash fa-fw"></i>',
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<div class="page-content ptr-content">
|
<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>
|
<textarea id="orig_content" style="display: none;">{{content}}</textarea>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user