add date question

add datetime question
This commit is contained in:
Simon Vieille 2020-09-15 18:31:36 +02:00
parent 688c73ebac
commit eaed2c7ac7
7 changed files with 174 additions and 1 deletions

View file

@ -29,6 +29,8 @@
@include icon-black-white('answer-dropdown', 'forms', 1);
@include icon-black-white('answer-short', 'forms', 1);
@include icon-black-white('answer-long', 'forms', 1);
@include icon-black-white('answer-date', 'forms', 1);
@include icon-black-white('answer-datetime', 'forms', 1);
@include icon-black-white('drag-handle', 'forms', 1);
.icon-yes {

5
img/answer-date.svg Normal file
View file

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<rect style="marker:none" width="11.678" height="11.469" x="2.161" y="2.266" ry="0" rx="0" color="#000" overflow="visible" fill="none" stroke="#000" stroke-width="1.358" stroke-linecap="square" paint-order="fill markers stroke"/>
<path style="marker:none" color="#000" overflow="visible" stroke="#000" stroke-width=".351" stroke-linecap="square" paint-order="stroke markers fill" d="M9.837 9.978h2.209v2.169H9.837z"/>
<rect style="marker:none" width="11.873" height="2.124" x="2.064" y="2.168" ry="0" rx="0" color="#000" overflow="visible" stroke="#000" stroke-width="1.163" stroke-linecap="square" paint-order="fill markers stroke"/>
</svg>

After

Width:  |  Height:  |  Size: 712 B

4
img/answer-datetime.svg Normal file
View file

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<rect style="marker:none" width="11.678" height="11.469" x="2.161" y="2.266" ry="5.734" rx="5.734" color="#000" overflow="visible" fill="none" stroke="#000" stroke-width="1.358" stroke-linecap="square" paint-order="fill markers stroke"/>
<path d="M6.893 4.811l.822 3.516 3.795 2.023" fill="none" stroke="#000"/>
</svg>

After

Width:  |  Height:  |  Size: 387 B

View file

@ -53,7 +53,9 @@ class Question extends Entity {
'long',
'multiple',
'multiple_unique',
'dropdown'
'dropdown',
'date',
'datetime',
];
public function __construct() {

View file

@ -0,0 +1,68 @@
<!--
- @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com>
-
- @author Simon Vieille <contact@deblan.fr>
-
- @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>
<Question
v-bind.sync="$attrs"
:text="text"
:mandatory="mandatory"
:edit.sync="edit"
:read-only="readOnly"
:max-question-length="maxStringLengths.questionText"
:title-placeholder="answerType.titlePlaceholder"
:warning-invalid="answerType.warningInvalid"
@update:text="onTitleChange"
@update:mandatory="onMandatoryChange"
@delete="onDelete">
<div v-if="readOnly" class="question__content">
<DatetimePicker
v-model="time" />
</div>
</Question>
</template>
<script>
import QuestionShort from './QuestionShort'
import DatetimePicker from '@nextcloud/vue/dist/Components/DatetimePicker'
export default {
name: 'QuestionDate',
components: {
DatetimePicker,
},
mixins: [QuestionShort],
data() {
return {
time: null,
}
},
watch: {
time(value) {
this.$emit('update:values', [value])
}
},
}
</script>

View file

@ -0,0 +1,69 @@
<!--
- @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com>
-
- @author Simon Vieille <contact@deblan.fr>
-
- @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>
<Question
v-bind.sync="$attrs"
:text="text"
:mandatory="mandatory"
:edit.sync="edit"
:read-only="readOnly"
:max-question-length="maxStringLengths.questionText"
:title-placeholder="answerType.titlePlaceholder"
:warning-invalid="answerType.warningInvalid"
@update:text="onTitleChange"
@update:mandatory="onMandatoryChange"
@delete="onDelete">
<div v-if="readOnly" class="question__content">
<DatetimePicker
v-model="time"
type="datetime" />
</div>
</Question>
</template>
<script>
import QuestionShort from './QuestionShort'
import DatetimePicker from '@nextcloud/vue/dist/Components/DatetimePicker'
export default {
name: 'QuestionDatetime',
components: {
DatetimePicker,
},
mixins: [QuestionShort],
data() {
return {
time: null,
}
},
watch: {
time(value) {
this.$emit('update:values', [value])
}
},
}
</script>

View file

@ -24,6 +24,8 @@ import QuestionMultiple from '../components/Questions/QuestionMultiple'
import QuestionDropdown from '../components/Questions/QuestionDropdown'
import QuestionShort from '../components/Questions/QuestionShort'
import QuestionLong from '../components/Questions/QuestionLong'
import QuestionDate from '../components/Questions/QuestionDate'
import QuestionDatetime from '../components/Questions/QuestionDatetime'
/**
* @typedef {Object} AnswerTypes
@ -105,4 +107,25 @@ export default {
warningInvalid: t('forms', 'This question needs a title!'),
},
date: {
component: QuestionDate,
icon: 'icon-answer-date',
label: t('forms', 'Date'),
titlePlaceholder: t('forms', 'Date question title'),
createPlaceholder: t('forms', ''),
submitPlaceholder: t('forms', 'Enter a date'),
warningInvalid: t('forms', 'This question needs a title!'),
},
datetime: {
component: QuestionDatetime,
icon: 'icon-answer-datetime',
label: t('forms', 'Datetime'),
titlePlaceholder: t('forms', 'Datetime question title'),
createPlaceholder: t('forms', ''),
submitPlaceholder: t('forms', 'Enter a date'),
warningInvalid: t('forms', 'This question needs a title!'),
},
}