Jake Vanderwerf
2025-10-20 e729f920139f0c65902be2d6b2c32466b08375e8
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;