2019-05-14 01:15:45 +02:00
|
|
|
<!--
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @author Nick Gallo
|
|
|
|
-
|
|
|
|
- @license GNU AGPL version 3 or any later version
|
|
|
|
-
|
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
|
|
|
-
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU Affero General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<li>
|
|
|
|
<div>{{ question.text }}</div>
|
|
|
|
<div>
|
2020-02-26 13:39:50 +01:00
|
|
|
<input v-show="(question.type != 'text') && (question.type != 'comment')"
|
2020-03-30 13:48:14 +02:00
|
|
|
v-model="newOption"
|
2020-02-26 13:39:50 +01:00
|
|
|
style="height:30px;"
|
2020-03-30 13:48:14 +02:00
|
|
|
:placeholder=" t('forms', 'Add Option')"
|
|
|
|
@keyup.enter="emitNewOption(question)">
|
2019-05-14 01:15:45 +02:00
|
|
|
<transitionGroup
|
|
|
|
id="form-list"
|
|
|
|
name="list"
|
|
|
|
tag="ul"
|
2020-02-26 13:39:50 +01:00
|
|
|
class="form-table">
|
2020-03-27 10:29:30 +01:00
|
|
|
<TextFormItem
|
2020-03-30 13:48:14 +02:00
|
|
|
v-for="(opt, index) in options"
|
|
|
|
:key="opt.id"
|
|
|
|
:option="opt"
|
|
|
|
@remove="emitRemoveOption(question, opt, index)" />
|
2019-05-14 01:15:45 +02:00
|
|
|
</transitionGroup>
|
|
|
|
</div>
|
|
|
|
<div>
|
2020-03-27 10:29:30 +01:00
|
|
|
<a class="icon icon-delete svg delete-form" @click="$emit('deleteQuestion')" />
|
2019-05-14 01:15:45 +02:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-02-26 14:00:27 +01:00
|
|
|
import TextFormItem from './textFormItem'
|
2019-05-14 01:15:45 +02:00
|
|
|
export default {
|
|
|
|
components: {
|
2020-02-26 13:39:50 +01:00
|
|
|
TextFormItem,
|
2019-05-14 01:15:45 +02:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
question: {
|
|
|
|
type: Object,
|
|
|
|
default: undefined,
|
2020-02-26 13:39:50 +01:00
|
|
|
},
|
2019-05-14 01:15:45 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-03-30 13:48:14 +02:00
|
|
|
nextOptionId: 1,
|
|
|
|
newOption: '',
|
2020-02-26 13:39:50 +01:00
|
|
|
type: '',
|
2019-05-14 01:15:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-03-27 10:29:30 +01:00
|
|
|
computed: {
|
2020-03-30 13:48:14 +02:00
|
|
|
options() {
|
|
|
|
return this.question.options || []
|
2020-03-27 10:29:30 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-05-14 01:15:45 +02:00
|
|
|
methods: {
|
2020-03-30 13:48:14 +02:00
|
|
|
emitNewOption(question) {
|
|
|
|
this.$emit('addOption', this, question)
|
2019-05-14 01:15:45 +02:00
|
|
|
},
|
|
|
|
|
2020-03-30 13:48:14 +02:00
|
|
|
emitRemoveOption(question, option, index) {
|
|
|
|
this.$emit('deleteOption', question, option, index)
|
2020-02-26 13:39:50 +01:00
|
|
|
},
|
|
|
|
},
|
2019-05-14 01:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|