Step 4. Watching Features
Step duration ~28 min
Last updated
Step duration ~28 min
Last updated
Set the default role not authorised
for every new user (object from WebUser
) and create a simple scenario:
Add two data structures.
ConfirmRequest
with the following fields:
user_id
— link to WebUser
code
— type of string
Fields for sync result processing
is_success
type of boolean
result_title
type of string
result_text
type of string.
CodeRequest
with the following fields:
user_id
— link to WebUser
Fields for sync result processing:
is_success
type of boolean
result_title
type of string
result_text
type of string.
Create a new web page called 'Watch features' and add two conditional sections:
The first section is visible only for users with the not confirmed
role and includes two forms:
Form for submitting ConfirmRequest
Form for submitting CodeRequest
The second section is visible only for users with the confirmed
role.
The 'CodeRequest'
form triggers a scenario in sync mode, which generates and sends a code to the user. The code is then saved in theWebUser
object.
The 'ConfirmRequest
' form compares the provided code with the one saved in the the 'WebUser'
object. If they match, the role 'not confirmed'
is removed, and the role 'confirmed'
is added to the 'role'
field in the 'WebUser'
object.
Create a new data structure called 'WatchRequest' with the following fields:
'user_id' – a link to 'WebUser.'
'feature_id' – a link to 'features.'
'type' – a string type to store 'watch' or 'unwatch'."
Add a new field 'users_watching_ids' with the type 'arrayLink' to the 'Features' data structure.
Create a new API-endpoint and a new web-page named 'Watch features.' In the endpoint, set a filter 'users_watching_ids arrayContainsAny {{id}}' to select only the features where the user's ID is in 'users_watching_ids.'
Now, add two actions:
'Watch' on the 'Upvote features' web-page.
'Unwatch' on the 'Watch features' web-page.
Scenario for processing WatchRequest (can be either synchronous or regular)
Next, create a new scenario triggered by changes in the development_status and request_status fields of the feature object. This scenario sends objects from the users_watching_ids to the 'Notify users' scenario, passing the feature_id as a parameter (context variable).
That is it! Thank you for using Directual. You can find the Open Development Roadmap app among our free templates.