/
App.js
284 lines (273 loc) · 8.07 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import React, { Component } from "react";
import * as Survey from "survey-react";
import "survey-react/survey.css";
import SurveyEditor from "./SurveyEditor";
import logo from "./logo.svg";
import "./App.css";
import "bootstrap/dist/css/bootstrap.css";
import "jquery-ui/themes/base/all.css";
import "nouislider/distribute/nouislider.css";
import "select2/dist/css/select2.css";
import "bootstrap-slider/dist/css/bootstrap-slider.css";
import "jquery-bar-rating/dist/themes/css-stars.css";
import $ from "jquery";
import "jquery-ui/ui/widgets/datepicker.js";
import "select2/dist/js/select2.js";
import "jquery-bar-rating";
import * as widgets from "surveyjs-widgets";
widgets.icheck(Survey, $);
widgets.select2(Survey, $);
widgets.inputmask(Survey);
widgets.jquerybarrating(Survey, $);
widgets.jqueryuidatepicker(Survey, $);
widgets.nouislider(Survey);
widgets.select2tagbox(Survey, $);
widgets.signaturepad(Survey);
widgets.sortablejs(Survey);
widgets.ckeditor(Survey);
widgets.autocomplete(Survey, $);
widgets.bootstrapslider(Survey);
class App extends Component {
json = {
title: "Product Feedback Survey Example",
showProgressBar: "top",
pages: [
{
elements: [
{
type: "barrating",
name: "barrating1",
ratingTheme: "css-stars",
title: "Please rate the movie you've just watched",
choices: ["1", "2", "3", "4", "5"]
},
{
type: "imagepicker",
name: "choosepicture",
title: "What animal would you like to see first ?",
choices: [
{
value: "lion",
imageLink:
"https://surveyjs.io/Content/Images/examples/image-picker/lion.jpg"
},
{
value: "giraffe",
imageLink:
"https://surveyjs.io/Content/Images/examples/image-picker/giraffe.jpg"
},
{
value: "panda",
imageLink:
"https://surveyjs.io/Content/Images/examples/image-picker/panda.jpg"
},
{
value: "camel",
imageLink:
"https://surveyjs.io/Content/Images/examples/image-picker/camel.jpg"
}
]
},
{
type: "bootstrapslider",
name: "bootstrapslider"
},
{
type: "dropdown",
renderAs: "select2",
choicesByUrl: {
url: "https://restcountries.eu/rest/v1/all"
},
name: "countries",
title: "Please select the country you have arrived from:"
},
{
type: "signaturepad",
name: "sign",
title: "Please enter your signature"
},
{
type: "sortablelist",
name: "lifepriopity",
title: "Life Priorities ",
isRequired: true,
colCount: 0,
choices: ["family", "work", "pets", "travels", "games"]
},
{
name: "date",
type: "datepicker",
inputType: "date",
title: "Your favorite date:",
dateFormat: "mm/dd/yy",
isRequired: true
}
]
},
{
questions: [
{
type: "signaturepad",
width: "500px",
name: "Signature Pad - you can enter your signature here:"
},
{
type: "matrix",
name: "Quality",
title:
"Please indicate if you agree or disagree with the following statements",
columns: [
{
value: 1,
text: "Strongly Disagree"
},
{
value: 2,
text: "Disagree"
},
{
value: 3,
text: "Neutral"
},
{
value: 4,
text: "Agree"
},
{
value: 5,
text: "Strongly Agree"
}
],
rows: [
{
value: "affordable",
text: "Product is affordable"
},
{
value: "does what it claims",
text: "Product does what it claims"
},
{
value: "better then others",
text: "Product is better than other products on the market"
},
{
value: "easy to use",
text: "Product is easy to use"
}
]
},
{
type: "rating",
name: "satisfaction",
title: "How satisfied are you with the Product?",
mininumRateDescription: "Not Satisfied",
maximumRateDescription: "Completely satisfied"
},
{
type: "rating",
name: "recommend friends",
visibleIf: "{satisfaction} > 3",
title:
"How likely are you to recommend the Product to a friend or co-worker?",
mininumRateDescription: "Will not recommend",
maximumRateDescription: "I will recommend"
},
{
type: "comment",
name: "suggestions",
title: "What would make you more satisfied with the Product?"
}
]
},
{
questions: [
{
type: "radiogroup",
name: "price to competitors",
title: "Compared to our competitors, do you feel the Product is",
choices: [
"Less expensive",
"Priced about the same",
"More expensive",
"Not sure"
]
},
{
type: "radiogroup",
name: "price",
title: "Do you feel our current price is merited by our product?",
choices: [
"correct|Yes, the price is about right",
"low|No, the price is too low for your product",
"high|No, the price is too high for your product"
]
},
{
type: "multipletext",
name: "pricelimit",
title: "What is the... ",
items: [
{
name: "mostamount",
title: "Most amount you would every pay for a product like ours"
},
{
name: "leastamount",
title: "The least amount you would feel comfortable paying"
}
]
}
]
},
{
questions: [
{
type: "text",
name: "email",
title:
'Thank you for taking our survey. Please enter your email address, then press the "Submit" button.'
}
]
}
]
};
componentWillMount() {
import("icheck");
window["$"] = window["jQuery"] = $;
}
onValueChanged(result) {
console.log("value changed!");
}
onComplete(result) {
console.log("Complete! " + result);
}
render() {
Survey.Survey.cssType = "bootstrap";
var model = new Survey.Model(this.json);
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React with SurveyJS</h2>
</div>
<div className="surveyjs">
{/*If you want to show survey, uncomment the line below*/}
<h1>SurveyJS library in action:</h1>
<Survey.Survey
model={model}
onComplete={this.onComplete}
onValueChanged={this.onValueChanged}
/>
{/*If you want to show survey editor, uncomment the line below*/}
<h1>SurveyJS Editor in action:</h1>
<SurveyEditor />
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
export default App;