34
34
@update:checked =" onShuffleOptionsChange" >
35
35
{{ t('forms', 'Shuffle options') }}
36
36
</NcActionCheckbox >
37
+ <NcActionButton close-after-click @click =" isOptionDialogShown = true" >
38
+ <template #icon >
39
+ <IconContentPaste :size =" 20" />
40
+ </template >
41
+ {{ t('forms', 'Add multiple options') }}
42
+ </NcActionButton >
37
43
</template >
38
44
<NcSelect
39
45
v-if =" readOnly"
47
53
label =" text"
48
54
@input =" onInput" />
49
55
50
- <ol v-if =" !readOnly" class =" question__content" >
51
- <!-- Answer text input edit -->
52
- <AnswerInput
53
- v-for =" (answer, index) in options"
54
- :key ="
55
- index /* using index to keep the same vnode after new answer creation */
56
- "
57
- ref =" input"
58
- :answer =" answer"
59
- :index =" index"
60
- :is-unique =" !isMultiple"
61
- :is-dropdown =" true"
62
- :max-option-length =" maxStringLengths.optionText"
63
- @delete =" deleteOption"
64
- @update:answer =" updateAnswer"
65
- @focus-next =" focusNextInput"
66
- @tabbed-out =" checkValidOption" />
67
-
68
- <li v-if =" !isLastEmpty || hasNoAnswer" class =" question__item" >
69
- <input
70
- ref =" pseudoInput"
71
- v-model =" inputValue"
72
- :aria-label =" t('forms', 'Add a new answer')"
73
- :placeholder =" t('forms', 'Add a new answer')"
74
- class =" question__input"
75
- :maxlength =" maxStringLengths.optionText"
76
- minlength =" 1"
77
- type =" text"
78
- @input =" addNewEntry" />
79
- </li >
80
- </ol >
56
+ <template v-else >
57
+ <div v-if =" isLoading" >
58
+ <NcLoadingIcon :size =" 64" />
59
+ </div >
60
+ <ol v-else class =" question__content" >
61
+ <!-- Answer text input edit -->
62
+ <AnswerInput
63
+ v-for =" (answer, index) in options"
64
+ :key ="
65
+ index /* using index to keep the same vnode after new answer creation */
66
+ "
67
+ ref =" input"
68
+ :answer =" answer"
69
+ :index =" index"
70
+ :is-unique =" !isMultiple"
71
+ :is-dropdown =" true"
72
+ :max-option-length =" maxStringLengths.optionText"
73
+ @delete =" deleteOption"
74
+ @update:answer =" updateAnswer"
75
+ @focus-next =" focusNextInput"
76
+ @tabbed-out =" checkValidOption" />
77
+
78
+ <li v-if =" !isLastEmpty || hasNoAnswer" class =" question__item" >
79
+ <input
80
+ ref =" pseudoInput"
81
+ v-model =" inputValue"
82
+ :aria-label =" t('forms', 'Add a new answer')"
83
+ :placeholder =" t('forms', 'Add a new answer')"
84
+ class =" question__input"
85
+ :maxlength =" maxStringLengths.optionText"
86
+ minlength =" 1"
87
+ type =" text"
88
+ @input =" addNewEntry" />
89
+ </li >
90
+ </ol >
91
+ </template >
92
+
93
+ <!-- Add multiple options modal -->
94
+ <OptionInputDialog
95
+ :open.sync =" isOptionDialogShown"
96
+ @multiple-answers =" handleMultipleOptions" />
81
97
</Question >
82
98
</template >
83
99
@@ -87,9 +103,14 @@ import { emit } from '@nextcloud/event-bus'
87
103
import { generateOcsUrl } from ' @nextcloud/router'
88
104
import axios from ' @nextcloud/axios'
89
105
import NcActionCheckbox from ' @nextcloud/vue/dist/Components/NcActionCheckbox.js'
106
+ import NcActionButton from ' @nextcloud/vue/dist/Components/NcActionButton.js'
107
+ import NcLoadingIcon from ' @nextcloud/vue/dist/Components/NcLoadingIcon.js'
90
108
import NcSelect from ' @nextcloud/vue/dist/Components/NcSelect.js'
91
109
110
+ import IconContentPaste from ' vue-material-design-icons/ContentPaste.vue'
111
+
92
112
import AnswerInput from ' ./AnswerInput.vue'
113
+ import OptionInputDialog from ' ../OptionInputDialog.vue'
93
114
import QuestionMixin from ' ../../mixins/QuestionMixin.js'
94
115
import GenRandomId from ' ../../utils/GenRandomId.js'
95
116
import logger from ' ../../utils/Logger.js'
@@ -99,8 +120,12 @@ export default {
99
120
100
121
components: {
101
122
AnswerInput,
123
+ IconContentPaste,
124
+ NcActionButton,
102
125
NcActionCheckbox,
126
+ NcLoadingIcon,
103
127
NcSelect,
128
+ OptionInputDialog,
104
129
},
105
130
106
131
mixins: [QuestionMixin],
@@ -109,6 +134,8 @@ export default {
109
134
return {
110
135
selectedOption: null ,
111
136
inputValue: ' ' ,
137
+ isOptionDialogShown: false ,
138
+ isLoading: false ,
112
139
}
113
140
},
114
141
0 commit comments