Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/components/Questions/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
v-html="computedDescription" />
<!-- eslint-enable vue/no-v-html -->
</div>
<NcNoteCard v-if="hasError" :id="errorId" type="error">
{{ errorMessage }}
</NcNoteCard>
</div>

<!-- Question content -->
Expand All @@ -160,6 +163,7 @@
import NcActionInput from '@nextcloud/vue/components/NcActionInput'
import NcActions from '@nextcloud/vue/components/NcActions'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import IconAlertCircleOutline from 'vue-material-design-icons/AlertCircleOutline.vue'
import IconArrowDown from 'vue-material-design-icons/ArrowDown.vue'
import IconArrowUp from 'vue-material-design-icons/ArrowUp.vue'
Expand Down Expand Up @@ -191,6 +195,7 @@
NcActionCheckbox,
NcActionInput,
NcButton,
NcNoteCard,
},

inject: ['$markdownit'],
Expand Down Expand Up @@ -243,7 +248,7 @@

contentValid: {
type: Boolean,
default: true,

Check warning on line 251 in src/components/Questions/Question.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Boolean prop should only be defaulted to false
},

warningInvalid: {
Expand All @@ -260,6 +265,11 @@
type: Boolean,
default: false,
},

errorMessage: {
type: String,
default: null,
},
},

emits: [
Expand Down Expand Up @@ -314,6 +324,14 @@
hasDescription() {
return this.description !== ''
},

hasError() {
return !!this.errorMessage
},

errorId() {
return `q${this.index}_error`
},
},

// Ensure description is sized correctly on initial render
Expand Down
16 changes: 1 addition & 15 deletions src/components/Questions/QuestionFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
v-bind="questionProps"
:titlePlaceholder="answerType.titlePlaceholder"
:warningInvalid="answerType.warningInvalid"
:errorMessage="errorMessage"
v-on="commonListeners">
<template #actions>
<template v-if="!allowedFileTypesDialogOpened">
Expand Down Expand Up @@ -78,10 +79,6 @@
</template>
</template>

<NcNoteCard v-if="hasError" :id="errorId" type="error">
{{ errorMessage }}
</NcNoteCard>

<div class="question__content">
<ul>
<NcListItem
Expand Down Expand Up @@ -160,7 +157,6 @@ import NcActionSeparator from '@nextcloud/vue/components/NcActionSeparator'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcListItem from '@nextcloud/vue/components/NcListItem'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import IconChevronLeft from 'vue-material-design-icons/ChevronLeft.vue'
import IconFileDocumentAlert from 'vue-material-design-icons/FileDocumentAlertOutline.vue'
import IconFile from 'vue-material-design-icons/FileOutline.vue'
Expand Down Expand Up @@ -205,7 +201,6 @@ export default {
NcButton,
NcListItem,
NcLoadingIcon,
NcNoteCard,
Question,
},

Expand All @@ -215,7 +210,6 @@ export default {
data() {
return {
fileTypes,
errorMessage: null,
fileLoading: false,
maxFileSizeUnit: Object.keys(FILE_SIZE_UNITS)[0],
maxFileSizeValue: '',
Expand Down Expand Up @@ -254,14 +248,6 @@ export default {

return t('forms', 'All file types are allowed.')
},

hasError() {
return !!this.errorMessage
},

errorId() {
return `q${this.index}_error`
},
},

mounted() {
Expand Down
20 changes: 1 addition & 19 deletions src/components/Questions/QuestionGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
:warningInvalid="answerType.warningInvalid"
:contentValid="contentValid"
:shiftDragHandle="shiftDragHandle"
:errorMessage="errorMessage"
v-on="commonListeners">
<template v-if="readOnly">
<fieldset
:name="name || undefined"
:aria-labelledby="titleId"
:aria-describedby="description ? descriptionId : undefined">
<NcNoteCard v-if="hasError" :id="errorId" type="error">
{{ errorMessage }}
</NcNoteCard>

<table class="answer-grid">
<thead>
<tr>
Expand Down Expand Up @@ -116,7 +113,7 @@
<AnswerInput
v-for="(answer, index) in columns"
:key="answer.local ? 'option-local' : answer.id"
ref="input"

Check warning on line 116 in src/components/Questions/QuestionGrid.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'input' is defined as ref, but never used
:answer="answer"
:formId="formId"
:index="index"
Expand Down Expand Up @@ -154,7 +151,7 @@
<AnswerInput
v-for="(answer, index) in rows"
:key="answer.local ? 'option-local' : answer.id"
ref="input"

Check warning on line 154 in src/components/Questions/QuestionGrid.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'input' is defined as ref, but never used
:answer="answer"
:formId="formId"
:index="index"
Expand All @@ -181,7 +178,6 @@
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
import NcInputField from '@nextcloud/vue/components/NcInputField'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import AnswerInput from './AnswerInput.vue'
import Question from './Question.vue'
import QuestionMixin from '../../mixins/QuestionMixin.js'
Expand All @@ -197,7 +193,6 @@
NcCheckboxRadioSwitch,
NcInputField,
NcLoadingIcon,
NcNoteCard,
Question,
},

Expand All @@ -206,11 +201,6 @@

data() {
return {
/**
* The shown error message
*/
errorMessage: null,

isDragging: false,
isLoading: false,
questionTypes: [
Expand All @@ -227,18 +217,10 @@
return this.answerType.unique === true
},

hasError() {
return !!this.errorMessage
},

shiftDragHandle() {
return !this.readOnly && this.options.length !== 0 && !this.isLastEmpty
},

errorId() {
return `q${this.index}_error`
},

questionType() {
return this.extraSettings?.questionType ?? GridCellType.Radio
},
Expand Down
18 changes: 1 addition & 17 deletions src/components/Questions/QuestionMultiple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:warningInvalid="answerType.warningInvalid"
:contentValid="contentValid"
:shiftDragHandle="shiftDragHandle"
:errorMessage="errorMessage"
v-on="commonListeners">
<template #actions>
<NcActionCheckbox
Expand Down Expand Up @@ -72,9 +73,6 @@
:name="name || undefined"
:aria-labelledby="titleId"
:aria-describedby="description ? descriptionId : undefined">
<NcNoteCard v-if="hasError" :id="errorId" type="error">
{{ errorMessage }}
</NcNoteCard>
<NcCheckboxRadioSwitch
v-for="answer in choices"
:key="answer.id"
Expand Down Expand Up @@ -137,7 +135,7 @@
<AnswerInput
v-for="(answer, index) in choices"
:key="answer.local ? 'option-local' : answer.id"
ref="input"

Check warning on line 138 in src/components/Questions/QuestionMultiple.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'input' is defined as ref, but never used
:answer="answer"
:formId="formId"
:index="index"
Expand Down Expand Up @@ -186,7 +184,6 @@
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
import NcInputField from '@nextcloud/vue/components/NcInputField'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import IconCheckboxBlankOutline from 'vue-material-design-icons/CheckboxBlankOutline.vue'
import IconContentPaste from 'vue-material-design-icons/ContentPaste.vue'
import IconRadioboxBlank from 'vue-material-design-icons/RadioboxBlank.vue'
Expand Down Expand Up @@ -215,7 +212,6 @@
NcCheckboxRadioSwitch,
NcInputField,
NcLoadingIcon,
NcNoteCard,
OptionInputDialog,
Question,
},
Expand All @@ -225,10 +221,6 @@

data() {
return {
/**
* The shown error message
*/
errorMessage: null,
/**
* This is used to cache the "other" answer, meaning if the user:
* checks "other" types text, unchecks "other" and then re-check "other" the typed text is preserved
Expand All @@ -249,10 +241,6 @@
return this.answerType.unique === true
},

hasError() {
return !!this.errorMessage
},

shiftDragHandle() {
return !this.readOnly && this.options.length !== 0 && !this.isLastEmpty
},
Expand All @@ -272,10 +260,6 @@
return this.isUnique ? this.values?.[0] : this.values
},

errorId() {
return `q${this.index}_error`
},

allowOtherAnswer() {
return this.extraSettings?.allowOtherAnswer ?? false
},
Expand Down
17 changes: 17 additions & 0 deletions src/mixins/QuestionMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ export default {
Question,
},

data() {
return {
/**
* The shown error message
*/
errorMessage: null,
}
},

computed: {
questionProps() {
const props = { ...this.$props }
Expand All @@ -204,6 +213,14 @@ export default {
return 'q' + this.index + '_desc'
},

hasError() {
return !!this.errorMessage
},

errorId() {
return 'q' + this.index + '_error'
},

/**
* Listeners for all questions to forward
*/
Expand Down
Loading