- Read Tutorial
- Watch Guide Video
In this section we're going to build out a key component of the application: the approval workflow. This is an important feature because the wrong workflow can ruin the application. Whereas a well constructed workflow will help the entire app run smoothly.
Usually, when I have to resolve a tough feature, I sit back and make a plan. Which is exactly what I'm going to do now.
Let's see what we have now. We have a few different objects called posts
, which are time entries made by employees. Then, we have two types of users - regular
users who create posts. And then we have admin users, who are essentially managers. This admin user will not create posts, rather they'll be the ones who will approve or reject them.
This is what we already have. Now, we have to see how the workflow should function when it comes to managing approvals.
The logical steps should be:
1. A regular user will enter a post
2. An Admin user will review the post
3. An Admin user can approve or reject the post
4. If an admin user approves a post, then we should lock or freeze the record since we don't want an employee to add more time or manipulate the system.
5. If the post is rejected, then we should send it back to the user who created it.
To implement this workflow, let's create a to-do list.
1. Create a new attribute called status
inside the posts
table.
2. Make status
a required attribute.
3. Have a default value for statuses
4. Implement approval stages
5. Locking the records
I think we have a good blue print to start.