When I added the User Rating Scorecard to my Generic Feedback Widget, I only wanted to show it when appropriate, so I added an ng-show attribute to the snh-rating element:
<snh-rating ng-show="data.includeRating" snh-values="data.ratingValues"></snh-rating>
I did the same thing to the snh-form-field element for the rating entry for the very same reason:
<snh-form-field
ng-show="data.includeRating"
snh-model="data.rating"
snh-name="rating"
snh-type="rating"
snh-label="Rate this {{data.tableLabel}}"/>
Providing a rating and viewing the cumulative results of ratings was something that I wanted to be optional, as including a rating in feedback is not always appropriate depending on the use case. To populate the data.includeRating variable with the desired alternative, I created a widget option, which I defined with the following JSON option schema:
[{
"hint": "Set to TRUE if you want to include a rating with the text feedback",
"name": "include_rating",
"default_value": "false",
"label": "Include Rating?",
"type": "boolean"
}]
Once the option schema has been established, editing the widget instance in the Service Portal Page Designer will pop open a modal dialog where you can check a box to indicate that you would like ratings to be included for this instance of the widget.
In the server side script, I look for this option and use it to determine the value of the data.includeRating variable.
data.includeRating = false;
if (options && options.include_rating) {
data.includeRating = true;
}
This makes the widget a little more flexible, as you can check the box for one circumstance and leave it unchecked (the default) for others. Checking the box will get you the rating score card, user ratings under each user comment heading, and the ability to rate the item when you provide feedback. Without the box checked, all of those items are removed from view.