Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
quiz_audit_management
/
resources
/
js
/
components
/
Admin
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
JsonTree.vue
| Size :
4.27
KB
Copy
<template> <div class="jsonTree" id="jsonTree"> <workflow-chart v-if="finishedGettingData" :style="size" :transitions="transitions" :states="states" :orientation="'horizontal'" @state-click="onLabelClicked('state',$event)" @transition-click="onLabelClicked('transition', $event)" @size-change="sizeChanged" v-drag /> </div> </template> <script> import WorkflowChart from 'vue-workflow-chart'; import drag from '@branu-jp/v-drag' export default { name: "App", components: { WorkflowChart, }, directives: { drag }, data: () => ({ treeData:{}, states: [], finishedGettingData: false, transitions: [], stateSemantics: [{ "classname": "delete", "id":"static_state_deleted", }], size: { width: '0px', height: '0px' }, }), created() { this.generateJson(); this.$nextTick( () => { // window.addEventListener('scroll', event => { // window.scrollTo(0, 0) // this.scrollFunction() // }) }); }, beforeRouteLeave (to, from , next) { window.removeEventListener('scroll', event => { }) next(); }, methods: { scrollFunction(event){ console.log('zoooom'); var tree = document.getElementById('jsonTree') }, onLabelClicked(type, id) { let {questions} = this.treeData console.log(questions[id.replace('question_','')]) let array_answers = Object.values(questions[id.replace('question_','')].answers).map(question => { console.log(question) return ' - ' + question.title; }) alert(array_answers.join('\n')); }, sizeChanged(size) { this.size = { width: `${size.width}px`, height: `${size.height}px`, }; }, generateJson(){ axios.get('getQuiz').then((response) => { this.treeData = JSON.parse(response.data.json); this.states = Object.keys(this.treeData.questions).map( (key) => { let question = this.treeData.questions[key]; let shouldNotInclude = ['loader','calculations','thanks','previous_thanks']; if(!shouldNotInclude.includes(question.step_type)){ if(Object.values(question.next_step).length>0){ question.next_step.map((value, key2)=>{ this.transitions.push({ "id": "Dz2un1r"+key + key2, "question": key, "answer": key2, "label": value.condition, "target": "question_"+value.destination, "source": "question_"+key, }) }) } return { "id": 'question_'+key, "label": question.title[0].title + ` (Intrebare ${key})`, } }else{ return { "id": 'question_'+key, "label": question.step_type, } } }) this.$root.$emit('doneLoading'); this.finishedGettingData = true; }) }, }, }; </script> <style lang="scss"> @import '~vue-workflow-chart/dist/vue-workflow-chart.css'; </style>
Back