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