mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 08:13:23 +00:00
Add has-many relationship from emails to processing jobs
✨ New Feature: - Add 'jobs' relationship field to emails collection - Shows all PayloadCMS jobs associated with each email - Read-only field with smart filtering by emailId - Visible in admin interface for better email tracking 🔍 Benefits: - Track job status and history for each email - Debug processing issues more easily - Monitor job queue performance per email - Complete email processing visibility
This commit is contained in:
@@ -4,7 +4,7 @@ const Emails: CollectionConfig = {
|
||||
slug: 'emails',
|
||||
admin: {
|
||||
useAsTitle: 'subject',
|
||||
defaultColumns: ['subject', 'to', 'status', 'scheduledAt', 'sentAt'],
|
||||
defaultColumns: ['subject', 'to', 'status', 'jobs', 'scheduledAt', 'sentAt'],
|
||||
group: 'Mailing',
|
||||
description: 'Email delivery and status tracking',
|
||||
},
|
||||
@@ -164,6 +164,24 @@ const Emails: CollectionConfig = {
|
||||
description: 'Email priority (1=highest, 10=lowest)',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'jobs',
|
||||
type: 'relationship',
|
||||
relationTo: 'payload-jobs',
|
||||
hasMany: true,
|
||||
admin: {
|
||||
description: 'Processing jobs associated with this email',
|
||||
allowCreate: false,
|
||||
readOnly: true,
|
||||
},
|
||||
filterOptions: ({ id }) => {
|
||||
return {
|
||||
'input.emailId': {
|
||||
equals: id,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
timestamps: true,
|
||||
// indexes: [
|
||||
|
||||
Reference in New Issue
Block a user