index page cannot be deleted

This commit is contained in:
Ro 2020-06-16 13:34:54 -07:00
parent 54c7690e26
commit eeeb4f9af6

View file

@ -22,10 +22,14 @@ export default class PostEditor {
this.post = []; this.post = [];
this.postID = null; this.postID = null;
this.postUUID = null; this.postUUID = null;
this.postLayout = null;
api.authStatus(); api.authStatus();
if (document.getElementById('post-edit-index').getAttribute('data-index')) { if (document.getElementById('post-edit-index').getAttribute('data-index')) {
this.postID = document.getElementById('post-edit-index').getAttribute('data-index'); this.postID = document.getElementById('post-edit-index').getAttribute('data-index');
this.postUUID = document.getElementById('post-edit-index').getAttribute('data-uuid'); this.postUUID = document.getElementById('post-edit-index').getAttribute('data-uuid');
this.postLayout = document
.getElementById('post-edit-index')
.getAttribute('data-layout');
} }
if (document.getElementById('edit-post-text')) { if (document.getElementById('edit-post-text')) {
this.editor = new TextEditor( this.editor = new TextEditor(
@ -163,6 +167,10 @@ export default class PostEditor {
}); });
break; break;
case EditorEvent.EDITOR_DELETE: case EditorEvent.EDITOR_DELETE:
if (this.postLayout === 'index') {
notify.alert('Index cannot be deleted', false);
return;
}
if (confirm("AYE! You know you're deleting this post, right?")) { if (confirm("AYE! You know you're deleting this post, right?")) {
let id = { id: this.postUUID }; let id = { id: this.postUUID };
api.request( api.request(