import { Component , Input , Output , EventEmitter } from "@angular/core" ; import * as SurveyKo from "survey-knockout" ; import * as SurveyCreator from "survey-creator" ; import * as widgets from "surveyjs-widgets" ; import { init as initCustomWidget } from "./customwidget" ; widgets . icheck ( SurveyKo ) ; widgets . select2 ( SurveyKo ) ; widgets . inputmask ( SurveyKo ) ; widgets . jquerybarrating ( SurveyKo ) ; widgets . jqueryuidatepicker ( SurveyKo ) ; widgets . nouislider ( SurveyKo ) ; widgets . select2tagbox ( SurveyKo ) ; widgets . sortablejs ( SurveyKo ) ; widgets . ckeditor ( SurveyKo ) ; widgets . autocomplete ( SurveyKo ) ; widgets . bootstrapslider ( SurveyKo ) ; initCustomWidget ( SurveyKo ) ; SurveyCreator . StylesManager . applyTheme ( "default" ) ; @ Component ( { selector : "survey-creator" , template : `
    <div id="surveyCreatorContainer"></div>
  ` } ) export class SurveyCreatorComponent { surveyCreator : SurveyCreator . SurveyCreator ; @ Input ( ) json : any ; @ Output ( ) surveySaved : EventEmitter < Object > = new EventEmitter ( ) ; ngOnInit ( ) { SurveyKo . JsonObject . metaData . addProperty ( "questionbase" , "popupdescription:text" ) ; SurveyKo . JsonObject . metaData . addProperty ( "page" , "popupdescription:text" ) ; let options = { showEmbededSurveyTab : true , generateValidJSON : true } ; this . surveyCreator = new SurveyCreator . SurveyCreator ( "surveyCreatorContainer" , options ) ; this . surveyCreator . text = JSON . stringify ( this . json ) ; this . surveyCreator . saveSurveyFunc = this . saveMySurvey ; } saveMySurvey = ( ) => { console . log ( JSON . stringify ( this . surveyCreator . text ) ) ; this . surveySaved . emit ( JSON . parse ( this . surveyCreator . text ) ) ; } ; }