-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the happy-heron ("H2") wiki! This is where we put developer-focused documentation.
State machine diagrams for collections and works live in the application repository:
To keep these up to date, run the following command and commit the resulting changes whenever the state machines change:
$ bin/rake state_machines:draw CLASS=Work,Collection FORMAT=svg
Completing a deposit of a work or a collection in H2 requires SDR integration, which we don't have when doing development locally. (We could add sdr-api in docker-compose.yml, but then we need dor-services-app, workflow-service, fedora, etc. etc., so it would very quickly become heavier than we want.) It's still useful to simulate completion of deposits. Here's how to do that:
# Make sure to have the object ID (the database ID, an integer), e.g.:
id = 123
# Make up a druid too, e.g.:
druid = 'druid:bc123df4567'
# This simulates what's done in the DepositStatusJob when we receive a response from sdr-api
object = Work.find(id) # or Collection.find(id)
object.druid = druid
object.add_purl_to_citation # if it's a Work
object.deposit_complete!
You may wish to check the latest definition of DepositStatusJob#complete_deposit
to confirm this documentation hasn't gotten stale. If it has, please update it.
- Naming conventions (from snake_case Rails models to kebab-case in Stimulus-land), documenting that we take whatever Rails gives us, translate it to Stimulus (also relates to controller naming)
- For doing name translation, there is a helper method declared in the works controller called
normalize_key
, make sure your field is normalized here (you may only need to do this if the field on the Rails side contains an underscore)
- For doing name translation, there is a helper method declared in the works controller called
- Where to declare validations in the app (forms, models, how to decide). Presence validation in the forms. Format validation in the models. Why? Allow drafts to be saved without required fields for deposit, but don't allow garbage values.
- Validations are run on the server side and if not valid, errors are returned to the client in JSON form, which is built here: https://github.com/sul-dlss/happy-heron/pull/488/files#diff-942a894d5927e2ff25efe573323ff07a2a8a556c989b9fbd188a1f5b73cebf15R3-R6
- Stimulus 101 (controllers, targets, actions)
- Adding the expected error hook to controllers to handle remote form validation
- Remote forms 101 (submitting via XHR, + using stimulus hooks to retrieve and parse responses)
- Add field target corresponding to controller to allow dispatching of errors
- In your field controller (which is nested in the edit-deposit controller), make sure to add a data-action that handles the error event and runs your field controller's
error()
function - ... and a data-target for your field within the edit-deposit controller (e.g.,
edit-deposit.embargo-dateField
for embargo date work, making sure to use Stimulus/JavaScript naming conventions, see above)
- Example PRs: