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.
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>
.
https://phayes.github.io/vuetify-survey/
To view sample application locally run yarn install && yarn serve
<VuetifySurvey>
is responsible for rendering a SurveyDefinition
.
-
value
- type:
SurveyData
object - required: true
- example:
<VuetifySurvey v-model="survey_data">
- type:
-
survey
- type:
SurveyDefinition
object - required: true
- type:
-
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
<VuetifySurveyEditor>
is responsible for providing a UI for editing a SurveyDefinition
.
-
value
- type:
SurveyDefinition
object - required
- example:
<VuetifySurveyEditor v-model="survey_definition">
- type:
-
show_item_id
- type:
Boolean
- default:
true
- description: Set to
false
to 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
false
to disallow the user from editing the css class for each item
- type:
-
allow_edit_item_class
- type:
Boolean
- default:
true
- description: Set to
false
to disallow the user from editing the css style for each item
- type:
-
allow_edit_item_visible
- type:
Boolean
- default:
true
- description: Set to
false
to disallow the user from editing the visibility of the item
- type:
SurveyDefinition
is an object that defines a survey.
-
title
- type:
String
- type:
-
instructions
- type:
String
- type:
-
items
- type:
Array
ofItemDefinition
- type:
ItemDefinition
is an object that defines a survey item, like a text-field or a checkbox.
-
id
- type:
String
- required
- description:
id
is used as the key for storing output values inSurveyData
. Items that share the sameid
will 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 asDate
orMath
.
- 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:
-
items
- type:
Array
ofOptionDefinition
- 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:
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.
-
value
- type:
String
- description: The underlying value that will be stored in the
SurveyData
object.
- 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:
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.