- click on “add an existing …”
- Remember and search for the item using a single search bar
- select the desired item
Intro
In the following we will see how the choice ofskills to be added to an expert can be materialized through a searchable smart collection named otherSkills displayed as related data of an expert. An action applicable on the selected records of this collection will allow to associate new skills to an expert.
Data models
The data models we have been working with here (experts and skills) are the following:
Step 1: create a smart collection ‘other skills’
As we already have the skills assigned to an expert as related data when viewing an expert, we’d like to see the skills that have not been assigned and could be by the user. For this we need to create a smart collection calledotherSkills. This smart collection is defined in a file other-skills.js inside the forest folder.
Step 2: declare a smart relationship between experts and otherSkills
In order to display records from the collectionotherSkills as related data of an expert, we need to declare a smart relationship between these collections. This is done in the file experts.js of the forest folder.
Step 3: implement the logic to retrieve records from the smart relationship
We want to display as related data theskills that are not already assigned to an expert so we can add them. Therefore when implementing the route called to retrieve records from the collection otherSkills through the smart relationship, we need to add this logic. This is done in the file experts.js of the routes folder.
<aside> 💡 We’ve added the logic needed to perform searches in the snippet below.
</aside>
Step 4: create the smart action to add skills to an expert
Next step is to declare a smart action that will allow a user to select several records of theotherSkills smart collection and associate them to an expert. This action is declared in the file other-skills.js of the forest folder.
other-skills.js file of the routes folder.