| | |
| | | this.error = window.jvbError; |
| | | this.populate = window.jvbPopulate; |
| | | this.cache = new window.jvbCache(this.content); |
| | | this.uploadedFields = new Set(); //tracks which upload fields are currently uploading; so don't send any of these changes to server |
| | | |
| | | this.activeItem = null; |
| | | this.isTimeline = false; |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (event === 'sent-to-queue' && data.field) { |
| | | const fieldName = data.field.config.name; |
| | | const itemId = data.field.config.itemID; |
| | | if (itemId && fieldName) { |
| | | this.uploadedFields.add(`${itemId}_${fieldName}`); |
| | | if (this.changes.has(itemId)) { |
| | | delete this.changes.get(itemId)[fieldName]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (event === 'upload_complete') { |
| | | this.uploadedFields.delete(`${data['item_id']}_${data['field']}`); |
| | | } |
| | | }); |
| | | } |
| | | initModals() { |
| | |
| | | && data.status === 'completed') { |
| | | this.store.clearCache(); |
| | | } |
| | | console.log('CRUD.js queue subscription'); |
| | | console.log(event, data); |
| | | |
| | | |
| | | if (event === 'operation-status' |
| | | && data.status === 'completed' |
| | | && data.endpoint === 'uploads/groups') { |
| | | console.log('Grouped Uploads completed'); |
| | | if (data.result && data.result.group_mappings) { |
| | | this.handleGroupMappings(data.result.group_mappings); |
| | | } |
| | | console.log('Cleared local cache. Refresh to see changes'); |
| | | this.store.clearCache(); |
| | | } |
| | | if (event === 'operation-status' |
| | | && data.status === 'completed' |
| | | && data.type === 'content_update') { |
| | | console.log('Cleared local cache. Refresh to see changes'); |
| | | this.store.clearCache(); |
| | | |
| | | // Check for result data (from ContentExecutor) |
| | |
| | | } |
| | | this.changes.get(itemId)[name] = value; |
| | | |
| | | for (const key of this.uploadedFields) { |
| | | const [itemId, fieldName] = key.split('_'); |
| | | if (this.changes.has(itemId)) { |
| | | delete this.changes.get(itemId)[fieldName]; |
| | | } |
| | | } |
| | | |
| | | // Don't schedule if only base keys remain |
| | | const change = this.changes.get(itemId); |
| | | const realKeys = Object.keys(change).filter(k => k !== 'id' && k !== 'content'); |
| | | if (realKeys.length === 0) { |
| | | this.changes.delete(itemId); |
| | | return; |
| | | } |
| | | |
| | | this.scheduleBackup(); |
| | | //Only send actual itemIds to server. If this is a recently uploaded item, just store changes for now |
| | | if (typeof itemId === 'number' || !itemId.includes('group')) { |
| | |
| | | await this.handleBackup(); |
| | | } |
| | | const changes = await this.changesStore.getAll(); |
| | | console.log('Saving Changes: ', changes); |
| | | if (changes.length === 0) return; |
| | | |
| | | if (title === '') { |
| | |
| | | |
| | | changes.forEach(change => { |
| | | let itemId = change.id; |
| | | const { id, content, ...fields } = change; |
| | | |
| | | // Create a new object without the id field (don't mutate original!) |
| | | const { id, ...changeWithoutId } = change; |
| | | allChanges[itemId] = changeWithoutId; |
| | | // Filter out uploaded fields |
| | | for (const key of this.uploadedFields) { |
| | | const [uid, fieldName] = key.split('_'); |
| | | if (uid === itemId) delete fields[fieldName]; |
| | | } |
| | | |
| | | if (Object.keys(fields).length > 0) { |
| | | allChanges[itemId] = { content, ...fields }; |
| | | } |
| | | |
| | | if (change.post_status && this.shouldRemoveItemUI(change.post_status)) { |
| | | remove.push(itemId); |
| | |
| | | let uploader = window.jvbUploads; |
| | | let field = uploader.fields.get(fieldId); |
| | | |
| | | |
| | | console.log(posts); |
| | | console.log(field); |
| | | |
| | | let added = []; |
| | | posts.forEach(post => { |
| | | const placeholderPost = { |
| | |
| | | } |
| | | |
| | | handleGroupMappings(mappings) { |
| | | console.log('[CRUD] Applying group mappings:', mappings); |
| | | // mappings = { "group_abc123": 456, "group_def456": 789 } |
| | | |
| | | for (const [groupId, postId] of Object.entries(mappings)) { |