I have an Angular application that manipulates data in sets. My users can perform actions on each record. They also want to be able to perform actions on the entire set. But the business rules state that some actions cannot be performed on certain data.
I want to create a generic method that will loop through the data and perform the action only if the data meets the criteria for that action. I can do this easily enough. My issue is where to store this action-to-criteria mapping. I can create a table and have it retrieved through a web service. I can store it in the web app in a JSON file. But these seem more complicated than necessary when we consider that retrieving this data will be asynchronous and will need to be stored somewhere in memory. But I obviously don't want to hard-code it either. The business rules would almost never change, and if they did, it would be adding new actions.
This table shows a very simplified version of what I need to accomplish. If the user is working on a list of 100 records and clicks on the "Archive All" button, I want to scan the records and only archive the records that are in the completed phase. I want to be able to reuse this method for the other buttons as well. What is the best practice for storing something like this?
| Phase | Save All | Send All | Archive All |
|---|---|---|---|
| New | Y | N | N |
| In Progress | Y | Y | N |
| Completed | Y | Y | Y |