vuetify-survey v0.1.10
Vuetify Survey
This package allows you to declaratively configure surveys and questionnaires. It is similar to SurveyJS, but uses Vuetify to both render the survey and for the (optional) editor.
It provides two components:
<VuetifySurvey>: Allows end-users to fill out surveys.
<VuetifySurveyEditor>: Allows other users to configure declarative survey definitions.
Use-case
You can use <VuetifySurveyEditor> to let your users build up questionaires, then store the resulting declarative definition in a database. The stored definitions can then be loaded and displayed to other users using <VuetifySurvey>.
Example Application
https://phayes.github.io/vuetify-survey/
To view sample application locally run yarn install && yarn serve
API Reference
Component: <VuetifySurvey>
<VuetifySurvey> is responsible for rendering a SurveyDefinition.
props:
value- type:
SurveyDataobject - required: true
- example:
<VuetifySurvey v-model="survey_data">
- type:
survey- type:
SurveyDefinitionobject - required: true
- type:
slots:
before-item- binding: item of type
ItemDefinition - example:
<VuetifySurvey><template v-slot:before-item="item">{{ item.title }}</template></VuetifySurvey>
- binding: item of type
after-item- binding: item of type
ItemDefinition - example:
<VuetifySurvey><template v-slot:after-item="item">{{ item.title }}</template></VuetifySurvey>
- binding: item of type
Component: <VuetifySurveyEditor>
<VuetifySurveyEditor> is responsible for providing a UI for editing a SurveyDefinition.
props:
value- type:
SurveyDefinitionobject - required
- example:
<VuetifySurveyEditor v-model="survey_definition">
- type:
show_item_id- type:
Boolean - default:
true - description: Set to
falseto disallow the user from seeing or editing the underlying identifier for each item
- type:
allow_edit_item_class- type:
Boolean - default:
true - description: Set to
falseto disallow the user from editing the css class for each item
- type:
allow_edit_item_class- type:
Boolean - default:
true - description: Set to
falseto disallow the user from editing the css style for each item
- type:
allow_edit_item_visible- type:
Boolean - default:
true - description: Set to
falseto disallow the user from editing the visibility of the item
- type:
Data Structure: SurveyDefinition
SurveyDefinition is an object that defines a survey.
properties:
title- type:
String
- type:
instructions- type:
String
- type:
items- type:
ArrayofItemDefinition
- type:
Data Structure: ItemDefinition
ItemDefinition is an object that defines a survey item, like a text-field or a checkbox.
core properties:
id- type:
String - required
- description:
idis used as the key for storing output values inSurveyData. Items that share the sameidwill share the same data in the survey.
- type:
type- type:
String(enumerated) - required
- allowed_values:
text-field,number-field,textarea,checkbox,switch,select,radio-group,checkboxes,date,birthday,rating,mood
- type:
default_value- type:
any - description: Apply this default value to the item. When not set, a reasonable default is used.
- type:
props- type:
Object - description: key => value mapping of props that will be passed to the vuetify component. The key will be translated to kebab-case before being passed to the vuetify component.
- type:
visible- type:
String|Boolean - description: To make this item conditionally visible, use a javascript expression that evaluates to true or false. For example, if you want to show this item only if the user's age is greater than 18, use:
age > 18. You can use any of the item's values in the expression. For example, if you want to show this item only if the user's age is greater than the value of question_1, use:question_1 && age > question_1. These expressions are evaluated in a sandbox and do not have access to the DOM or other utility types such asDateorMath.
- type:
class- type:
String - description: Add this css class to the item
- type:
style- type:
String - description: Add this css style to the item
- type:
additional properties:
items- type:
ArrayofOptionDefinition - applies to:
select,radio-group,checkboxes
- type:
integer_only- type:
Boolean - applies to:
number-field
- type:
min- type:
Number - applies to:
number-field
- type:
max- type:
Number - applies to:
number-field
- type:
step- type:
Number - applies to:
number-field
- type:
maxlength- type:
Number - applies to:
text-field,textarea
- type:
rating_icon- type:
String - appies to:
rating - allowed_values:
mdi-star,mdi-cards-heart,mdi-emoticon-happy
- type:
Data Structure: OptionDefinition
For survey items that provide varios options to select (select, radio-group, checkboxes), items is set an array of OptionDefinition to define what options are available.
core properties:
value- type:
String - description: The underlying value that will be stored in the
SurveyDataobject.
- type:
text- type:
String - description: The text displayed to the user for this option.
- type:
class- type:
String - description: Add this css class to the option element.
- type:
style- type:
String - description: Add this css style to the option element.
- type:
Data Structure: SurveyData
A simple key => value object that represents the data saved by the survey. The keys in SurveyData correspond to the id field of the ItemDefinition object.