---
title: "Update the Add Data Templates"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Update Add Data Templates}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

### Updating the Add Data Template

**This will rarely need to be done as additions / removals to ecological groups
and trophic groups are uncommon**

#### Associated Reference Data

The instructions in the upload data template need to be updated when changes to the reference data sheets occur. When the following files are updated according to
the [Developer Instructions](https://bcgov.github.io/wqbench/articles/Developer-instructions.html), those changes *may* trigger necessary updates to
the Add Data templates and instrutions:

- *trophic-groups.csv*
  - Update **trophic_group** and **ecological_group** column instructions if new groups are added or groups are removed.
    - ie if `Plant` is removed as a trophic group or `Salmonid` is removed as an ecological group.
    - Since the groups (Plant, Bacteria, Amphibian, etc) have been written into the instruction tab this is why updates to the instructions are needed if new categories are added.
  - The validation of the values is done from the *trophic-groups.csv* which means it is possible for the instructions to get out of sync with the allowed values.
  - Adding new species to the *trophic-groups.csv* does not trigger a change to the instructions.

- *lifestage-codes.csv*
  - Update **simple_lifestage** column instructions if new simple life stages categories are added or removed.
    - ie if `els` is removed as a simple life stage.
  - The validation is done off the *lifestage-codes.csv* which means it is possible for the instructions to get out of sync with the allowed values.

- *concentration-endpoints.csv*
  - Update **endpoint** column instructions if endpoints are added or removed.
  - The list of endpoints are generated by the script *scripts/concentration-endpoints.R*.
  - The validation is done off of the *concentration-endpoints.csv* so it is possible for the instructions to get out of sync with the allowed values.

#### To update the template

1. Make any required changes to the trophic groups, life stage codes or concentration endpoints reference data.
2. Edit the *inst/template/template-data-data.csv* and *inst/template/template-data-instructions.csv* files.
   - Do not edit the file *inst/template/template-data.xlsx*.
3. To regenerate the template run the script *data-raw/template.R*.
4. Review the *inst/template/template-data.xlsx* to confirm the edits came through and the template looks as expected.
   - Do not edit the file *inst/template/template-data.xlsx*.

## Push and install the pacakge

Finally, after all of the all of the updates are completed, push them
to GitHub. Install the updated package with
`devtools::install_github("bcgov/wqbench")`.
