Drafts system implemented
This commit is contained in:
@@ -9,6 +9,13 @@
|
||||
(document.getElementById('packs-draft-uploads') || { textContent: '[]' }).textContent
|
||||
);
|
||||
|
||||
const draftUuidEl = document.getElementById('packs-draft-uuid');
|
||||
let draftUuid = '';
|
||||
if (draftUuidEl) {
|
||||
try { draftUuid = JSON.parse(draftUuidEl.textContent || '""'); }
|
||||
catch (e) { draftUuid = draftUuidEl.textContent; }
|
||||
}
|
||||
|
||||
const autosaveStatus = document.getElementById('autosave-status');
|
||||
const csrf = getCookie('csrftoken');
|
||||
const csrfHeader = csrf ? { 'X-CSRFToken': csrf } : {};
|
||||
@@ -50,7 +57,7 @@
|
||||
xhr.onerror = function () {
|
||||
setStatus('<i class="fas fa-exclamation-triangle"></i> Save failed', 'error');
|
||||
};
|
||||
xhr.send(JSON.stringify({ data }));
|
||||
xhr.send(JSON.stringify({ draft: draftUuid, data }));
|
||||
}
|
||||
|
||||
function initAutosave() {
|
||||
@@ -67,7 +74,7 @@
|
||||
setTimeout(() => setStatus('<i class="fas fa-check"></i> Saved just now', 'saved'), 2000);
|
||||
}
|
||||
|
||||
PacksUploads.init({ pending: pending, onReady: initAutosave });
|
||||
PacksUploads.init({ pending: pending, draftUuid: draftUuid, onReady: initAutosave });
|
||||
|
||||
function getCookie(name) {
|
||||
let cookieValue = null;
|
||||
|
||||
Reference in New Issue
Block a user