forked from surveyjs/surveyjs_angular_cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
survey.creator.component.ts
54 lines (50 loc) · 1.63 KB
/
survey.creator.component.ts
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
import { Component, Input, Output, EventEmitter } from "@angular/core";
import * as Survey from "survey-core";
// import * as SurveyKo from "survey-knockout-ui";
import { SurveyCreator } from "survey-creator-knockout";
import * as widgets from "surveyjs-widgets";
import { init as initCustomWidget } from "./customwidget";
widgets.icheck(Survey);
widgets.select2(Survey);
widgets.inputmask(Survey);
widgets.jquerybarrating(Survey);
widgets.jqueryuidatepicker(Survey);
widgets.nouislider(Survey);
widgets.select2tagbox(Survey);
//widgets.signaturepad(SurveyKo);
widgets.sortablejs(Survey);
widgets.ckeditor(Survey);
widgets.autocomplete(Survey);
widgets.bootstrapslider(Survey);
//widgets.emotionsratings(SurveyKo);
initCustomWidget(Survey);
@Component({
selector: "survey-creator",
template: `
<div id="surveyCreatorContainer"></div>
`,
styles: [`
#surveyCreatorContainer {
height: calc(100vh - 125px);
width: 100vw;
}
`]
})
export class SurveyCreatorComponent {
creator: SurveyCreator;
@Input() json: any;
@Output() surveySaved: EventEmitter<Object> = new EventEmitter();
ngOnInit() {
Survey.Serializer.addProperty("questionbase", "popupdescription:text");
Survey.Serializer.addProperty("page", "popupdescription:text");
const options = { showPreviewTab: true, showLogicTab: true };
this.creator = new SurveyCreator(options);
this.creator.JSON = this.json;
this.creator.saveSurveyFunc = this.saveMySurvey;
this.creator.render("surveyCreatorContainer");
}
saveMySurvey = () => {
console.log(JSON.stringify(this.creator.text));
this.surveySaved.emit(JSON.parse(this.creator.text));
};
}