# PPS Impact Module

## Purpose
PPS Impact provides the editorial workflow for Impact Issues and their Impact Articles. The module now works with Drupal's Content Moderation instead of bypassing it with JavaScript requirement hacks.

## Editorial Workflow
- **Impact Issues** use Content Moderation (`draft` → `published`). Editors may save drafts with empty fields; publishing enforces validation.
- **Impact Articles** are managed through Inline Entity Form (IEF) within an Impact Issue. Newly created IEF articles are saved as unpublished until the parent issue publishes.

## Validation Rules (Publish Only)
Validation runs from `_pps_impact_validate_on_publish()` when the moderation state transitions to `published`.
- Required fields: `title`, `field_issue_month`, `field_issue_year`.
- Article counts: 4 `field_featured_articles`, 3 `field_departments_articles`, and 3 `field_inside_apta` entries.
- Inline article fields (when creating new articles via IEF): Title, Article Author, and Featured Image must be provided.
- Every referenced article must have a Featured Image before an issue can be published.

## Article Publish State Sync
`pps_impact_node_presave()` keeps articles in sync with the parent issue:
- New inline articles default to unpublished.
- Publishing an Impact Issue publishes all referenced articles.
- Moving an Impact Issue out of the published state unpublishes its referenced articles.

## Configuration Expectations
- Impact Issue reference fields (`field_featured_articles`, `field_departments_articles`, `field_inside_apta`) and key Impact Article fields are optional at the configuration level.
- Use Drupal configuration management to export/import the updated field definitions.

## Front-end Assets
Only `issue_form_enhancements` remains attached to Issue edit forms (to provide accordions). Obsolete validation JS/CSS has been removed.

## Troubleshooting
- Run `drush cr` after deploying config changes.
- If validation fires during drafts, confirm the moderation state value and ensure the field config is optional on the environment.
