From b0194e10a87e16797a568d8a30d53ebecd27d8a4 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 18 Oct 2025 15:04:51 +0000
Subject: [PATCH] =DataStore.js and UploaderManager.js overhaul
---
assets/js/dash/CRUD.js | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/assets/js/dash/CRUD.js b/assets/js/dash/CRUD.js
index 7bd4d50..e9f39d7 100644
--- a/assets/js/dash/CRUD.js
+++ b/assets/js/dash/CRUD.js
@@ -18,16 +18,23 @@
// Initialize components
this.store = new window.jvbStore({
name: this.content,
+ storeName: this.content,
endpoint: 'content',
headers: {
'action_nonce': jvbSettings.dash,
},
+ indexes: [
+ { name: 'status', keyPath: 'post_status'},
+ { name: 'modified', keyPath: 'modified'},
+ ],
filters: {
content: this.content,
user: jvbSettings.currentUser,
page: 1,
status: 'all'
- }
+ },
+ TTL: 3600000,
+ cacheDOM: true
});
this.status = 'all';
@@ -209,6 +216,14 @@
// Load initial data
this.store.fetch();
+ this.queue.subscribe((event, data) => {
+ switch (event) {
+ case 'operation-status':
+ //update items?
+ break;
+ }
+ });
+
this.initialized = true;
}
@@ -238,7 +253,7 @@
};
window.fade(actionBtn.closest('.item'), false);
this.savePosts(changes, `Sending ${this.singular} to trash...`);
- this.store.deleteItem(id);
+ this.store.delete(id);
}
break;
case 'trash':
@@ -268,17 +283,17 @@
case 'bulk-delete':
const toDelete = Array.from(this.viewController.selectedItems);
if (toDelete.length > 0 && confirm(`Delete ${toDelete.length} items?`)) {
- toDelete.forEach(id => this.store.deleteItem(id));
+ toDelete.forEach(id => this.store.delete(id));
this.viewController.clearSelection();
}
break;
case 'sync':
- this.store.syncQueue();
+ // this.store.syncQueue();
break;
case 'refresh':
- this.store.fetchFromServer(this.store.filters);
+ this.store.fetch();
break;
}
}
@@ -469,7 +484,7 @@
window.removeChildren(container);
for (let selected of this.viewController.selectedItems) {
console.log(selected);
- let item = this.store.getItem(selected);
+ let item = this.store.get(selected);
console.log(item);
const img = window.getTemplate('bulkItem');
if (!img) return;
@@ -502,7 +517,7 @@
}
populateEditForm(itemID) {
- let item = this.store.getItem(itemID);
+ let item = this.store.get(itemID);
console.log(item);
if (item) {
this.ui.modals.edit.dataset.itemID = itemID;
--
Gitblit v1.10.0