From f91b5dec945bec71dac28047d7135c724be56c0d Mon Sep 17 00:00:00 2001 From: wakashi1 Date: Tue, 17 May 2022 22:50:59 +0900 Subject: [PATCH 01/14] newtabquestions --- src/assets/mdi.ts | 9 +- .../NewQuestionnaire/AddQuestionButtons.vue | 11 ++- .../NewQuestionnaire/Forms/ChoiceElement.vue | 17 ++-- .../NewQuestionnaire/Forms/ChoiceForm.vue | 59 ++++++++--- .../Forms/LinearScaleForm.vue | 4 +- .../NewQuestionnaire/Forms/QuestionForm.vue | 57 ++++++----- .../NewQuestionnaire/Forms/QuestionTitle.vue | 56 +++++++++++ .../Forms/Questiondispose.vue | 46 +++++++++ .../NewQuestionnaire/Forms/Questionupdown.vue | 60 ++++++++++++ .../NewQuestionnaire/Forms/TextForm.vue | 18 +++- ...estionTitle.vue => QuestionnaireTitle.vue} | 0 src/components/NewQuestionnaire/Questions.vue | 97 +++++++++++++------ src/components/NewQuestionnaire/use/utils.ts | 44 ++++++--- src/components/UI/QuestionInput.vue | 10 +- src/components/UI/QuestionTextarea.vue | 9 +- src/pages/NewQuestionnaire.vue | 12 ++- 16 files changed, 393 insertions(+), 116 deletions(-) create mode 100644 src/components/NewQuestionnaire/Forms/QuestionTitle.vue create mode 100644 src/components/NewQuestionnaire/Forms/Questiondispose.vue create mode 100644 src/components/NewQuestionnaire/Forms/Questionupdown.vue rename src/components/NewQuestionnaire/{QuestionTitle.vue => QuestionnaireTitle.vue} (100%) diff --git a/src/assets/mdi.ts b/src/assets/mdi.ts index 67affef4..37424c21 100644 --- a/src/assets/mdi.ts +++ b/src/assets/mdi.ts @@ -1,6 +1,7 @@ import { mdiChevronDown, mdiChevronUp, + mdiChevronRight, mdiMagnify, mdiOpenInNew, mdiHelpCircleOutline, @@ -14,18 +15,19 @@ import { mdiCheck, mdiLoading, mdiTrashCanOutline, - mdiAlertOutline + mdiAlertOutline, + mdiPlusCircleOutline } from '@mdi/js' const mdi = new Map([ ['chevron-down', mdiChevronDown], ['chevron-up', mdiChevronUp], + ['chevron-right', mdiChevronRight], ['magnify', mdiMagnify], ['open-in-new', mdiOpenInNew], ['help-circle-outline', mdiHelpCircleOutline], ['menu', mdiMenu], ['close', mdiClose], - ['chevron-down', mdiChevronDown], ['eye-closed', mdiEyeOff], ['eye', mdiEye], ['clipboard', mdiClipboard], @@ -34,7 +36,8 @@ const mdi = new Map([ ['check', mdiCheck], ['loading', mdiLoading], ['trash-can-outline', mdiTrashCanOutline], - ['alert', mdiAlertOutline] + ['alert', mdiAlertOutline], + ['plus-circle-outline', mdiPlusCircleOutline] ]) export default mdi diff --git a/src/components/NewQuestionnaire/AddQuestionButtons.vue b/src/components/NewQuestionnaire/AddQuestionButtons.vue index 1a537907..4451372b 100644 --- a/src/components/NewQuestionnaire/AddQuestionButtons.vue +++ b/src/components/NewQuestionnaire/AddQuestionButtons.vue @@ -1,9 +1,10 @@ + + diff --git a/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue b/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue index 6d609caa..16dc10a7 100644 --- a/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue +++ b/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue @@ -38,8 +38,8 @@ export default defineComponent({ name: 'ChoiceForm', components: { QuestionForm, - QuestionInput, - Select + Select, + QuestionInput }, props: { index: { diff --git a/src/components/NewQuestionnaire/Forms/QuestionForm.vue b/src/components/NewQuestionnaire/Forms/QuestionForm.vue index a281c905..b395b5b0 100644 --- a/src/components/NewQuestionnaire/Forms/QuestionForm.vue +++ b/src/components/NewQuestionnaire/Forms/QuestionForm.vue @@ -1,37 +1,24 @@ + + diff --git a/src/components/NewQuestionnaire/Forms/QuestionTitle.vue b/src/components/NewQuestionnaire/Forms/QuestionTitle.vue new file mode 100644 index 00000000..e251a64a --- /dev/null +++ b/src/components/NewQuestionnaire/Forms/QuestionTitle.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/components/NewQuestionnaire/Forms/Questiondispose.vue b/src/components/NewQuestionnaire/Forms/Questiondispose.vue new file mode 100644 index 00000000..8f1888b2 --- /dev/null +++ b/src/components/NewQuestionnaire/Forms/Questiondispose.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/components/NewQuestionnaire/Forms/Questionupdown.vue b/src/components/NewQuestionnaire/Forms/Questionupdown.vue new file mode 100644 index 00000000..ccbb5b04 --- /dev/null +++ b/src/components/NewQuestionnaire/Forms/Questionupdown.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/src/components/NewQuestionnaire/Forms/TextForm.vue b/src/components/NewQuestionnaire/Forms/TextForm.vue index 31a2be3a..8858e084 100644 --- a/src/components/NewQuestionnaire/Forms/TextForm.vue +++ b/src/components/NewQuestionnaire/Forms/TextForm.vue @@ -6,7 +6,17 @@ @update:required="updateQuestionRequired" >
- + +
@@ -14,6 +24,7 @@ - + From 316b3f398a9ec35115fb80c459d313c68c9fea3f Mon Sep 17 00:00:00 2001 From: wakashi1 Date: Sun, 22 May 2022 23:45:01 +0900 Subject: [PATCH 06/14] =?UTF-8?q?=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewQuestionnaire/Forms/ChoiceForm.vue | 22 +++++-------------- .../NewQuestionnaire/Forms/Questionupdown.vue | 8 +++---- src/components/NewQuestionnaire/Questions.vue | 22 ++++++------------- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue index d8f793d9..f5c74852 100644 --- a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue +++ b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue @@ -10,8 +10,7 @@ { - ;[ChoiceQuestions.value[index], ChoiceQuestions.value[index - 1]] = [ - ChoiceQuestions.value[index - 1], - ChoiceQuestions.value[index] - ] - updateChoiceQuestionData('options', ChoiceQuestions.value) - } - const downChoice = (index: number) => { - ;[ChoiceQuestions.value[index], ChoiceQuestions.value[index + 1]] = [ - ChoiceQuestions.value[index + 1], - ChoiceQuestions.value[index] - ] + const swapChoice = (index: number, parameter: number) => { + const tmp = ChoiceQuestions.value[index] + ChoiceQuestions.value[index] = ChoiceQuestions.value[index + parameter] + ChoiceQuestions.value[index + parameter] = tmp updateChoiceQuestionData('options', ChoiceQuestions.value) } @@ -116,8 +107,7 @@ export default defineComponent({ updateChoice, deleteChoice, addChoice, - upChoice, - downChoice + swapChoice } } }) diff --git a/src/components/NewQuestionnaire/Forms/Questionupdown.vue b/src/components/NewQuestionnaire/Forms/Questionupdown.vue index 1168b1cd..97ef0e9b 100644 --- a/src/components/NewQuestionnaire/Forms/Questionupdown.vue +++ b/src/components/NewQuestionnaire/Forms/Questionupdown.vue @@ -36,16 +36,14 @@ export default defineComponent({ }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars - up: (index: number) => true, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - down: (index: number) => true + swap: (i: number, parameter: number) => true }, setup(props, context) { const upQuestion = () => { - context.emit('up', props.index) + context.emit('swap', props.index, -1) } const downQuestion = () => { - context.emit('down', props.index) + context.emit('swap', props.index, +1) } return { upQuestion, downQuestion } } diff --git a/src/components/NewQuestionnaire/Questions.vue b/src/components/NewQuestionnaire/Questions.vue index 1bbde0de..b39a38e7 100644 --- a/src/components/NewQuestionnaire/Questions.vue +++ b/src/components/NewQuestionnaire/Questions.vue @@ -12,8 +12,7 @@ { questions.value.splice(index, 1) } - const upQuestion = (index: number) => { - ;[questions.value[index], questions.value[index - 1]] = [ - questions.value[index - 1], - questions.value[index] - ] - } - const downQuestion = (index: number) => { - ;[questions.value[index], questions.value[index + 1]] = [ - questions.value[index + 1], - questions.value[index] - ] + + const swapQuestions = (index: number, parameter: number) => { + const tmp = questions.value[index] + questions.value[index] = questions.value[index + parameter] + questions.value[index + parameter] = tmp } return { QuestionType, @@ -113,8 +106,7 @@ export default defineComponent({ isTextForm, isChoiceForm, isLinearScaleForm, - upQuestion, - downQuestion + swapQuestions } } }) From 4bd9dbde9a15bb9432eba57412ffdd43af6152c9 Mon Sep 17 00:00:00 2001 From: wakashi1 Date: Mon, 23 May 2022 10:52:54 +0900 Subject: [PATCH 07/14] =?UTF-8?q?index=E3=81=AE=E4=BE=9D=E5=AD=98=E6=80=A7?= =?UTF-8?q?=E6=B6=88=E5=8E=BB=E3=81=A8swap=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewQuestionnaire/Forms/ChoiceForm.vue | 14 +++----- .../Forms/LinearScaleForm.vue | 6 +--- .../NewQuestionnaire/Forms/QuestionUpdown.vue | 6 ++-- .../NewQuestionnaire/Forms/TextForm.vue | 6 +--- src/components/NewQuestionnaire/Questions.vue | 32 ++++++++++++------- .../use/updateQuestionData.ts | 5 ++- 6 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue index f5c74852..3dde8e56 100644 --- a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue +++ b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue @@ -48,10 +48,6 @@ export default defineComponent({ Icon }, props: { - index: { - type: Number, - required: true - }, questionData: { type: Object as PropType, required: true @@ -63,7 +59,7 @@ export default defineComponent({ }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars - update: (question: CheckboxQuestion, index: number) => true + update: (question: CheckboxQuestion) => true }, setup(props, context) { const ChoiceQuestions = ref(props.questionData.options) @@ -93,10 +89,10 @@ export default defineComponent({ updateChoiceQuestionData('options', ChoiceQuestions.value) } - const swapChoice = (index: number, parameter: number) => { - const tmp = ChoiceQuestions.value[index] - ChoiceQuestions.value[index] = ChoiceQuestions.value[index + parameter] - ChoiceQuestions.value[index + parameter] = tmp + const swapChoice = (index1: number, index2: number) => { + const tmp = ChoiceQuestions.value[index1] + ChoiceQuestions.value[index1] = ChoiceQuestions.value[index2] + ChoiceQuestions.value[index2] = tmp updateChoiceQuestionData('options', ChoiceQuestions.value) } diff --git a/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue b/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue index 16dc10a7..a08e5d23 100644 --- a/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue +++ b/src/components/NewQuestionnaire/Forms/LinearScaleForm.vue @@ -42,10 +42,6 @@ export default defineComponent({ QuestionInput }, props: { - index: { - type: Number, - required: true - }, questionData: { type: Object as PropType, required: true @@ -53,7 +49,7 @@ export default defineComponent({ }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars - update: (question: LinearScaleQuestion, index: number) => true + update: (question: LinearScaleQuestion) => true }, setup(props, context) { const updateLinearScaleQuestionData = diff --git a/src/components/NewQuestionnaire/Forms/QuestionUpdown.vue b/src/components/NewQuestionnaire/Forms/QuestionUpdown.vue index 97ef0e9b..2a386a77 100644 --- a/src/components/NewQuestionnaire/Forms/QuestionUpdown.vue +++ b/src/components/NewQuestionnaire/Forms/QuestionUpdown.vue @@ -36,14 +36,14 @@ export default defineComponent({ }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars - swap: (i: number, parameter: number) => true + swap: (index1: number, index2: number) => true }, setup(props, context) { const upQuestion = () => { - context.emit('swap', props.index, -1) + context.emit('swap', props.index, props.index - 1) } const downQuestion = () => { - context.emit('swap', props.index, +1) + context.emit('swap', props.index, props.index + 1) } return { upQuestion, downQuestion } } diff --git a/src/components/NewQuestionnaire/Forms/TextForm.vue b/src/components/NewQuestionnaire/Forms/TextForm.vue index 8858e084..b66f5fda 100644 --- a/src/components/NewQuestionnaire/Forms/TextForm.vue +++ b/src/components/NewQuestionnaire/Forms/TextForm.vue @@ -37,10 +37,6 @@ export default defineComponent({ QuestionForm }, props: { - index: { - type: Number, - required: true - }, questionData: { type: Object as PropType, required: true @@ -48,7 +44,7 @@ export default defineComponent({ }, emits: { // eslint-disable-next-line @typescript-eslint/no-unused-vars - update: (question: TextQuestion, index: number) => true + update: (question: TextQuestion) => true }, setup(props, context) { const updateTextQuestionData = updateQuestionData( diff --git a/src/components/NewQuestionnaire/Questions.vue b/src/components/NewQuestionnaire/Questions.vue index b39a38e7..5476f606 100644 --- a/src/components/NewQuestionnaire/Questions.vue +++ b/src/components/NewQuestionnaire/Questions.vue @@ -17,22 +17,31 @@ @@ -73,8 +82,7 @@ export default defineComponent({ const question = createNewQuestion(type) questions.value.push(question) } - - const updateQuestions = (newData: QuestionData, index: number) => { + const updateQuestions = (index: number) => (newData: QuestionData) => { questions.value[index] = newData } @@ -92,10 +100,10 @@ export default defineComponent({ questions.value.splice(index, 1) } - const swapQuestions = (index: number, parameter: number) => { - const tmp = questions.value[index] - questions.value[index] = questions.value[index + parameter] - questions.value[index + parameter] = tmp + const swapQuestions = (index1: number, index2: number) => { + const tmp = questions.value[index1] + questions.value[index1] = questions.value[index2] + questions.value[index2] = tmp } return { QuestionType, diff --git a/src/components/NewQuestionnaire/use/updateQuestionData.ts b/src/components/NewQuestionnaire/use/updateQuestionData.ts index d291bcc2..8307baa6 100644 --- a/src/components/NewQuestionnaire/use/updateQuestionData.ts +++ b/src/components/NewQuestionnaire/use/updateQuestionData.ts @@ -5,14 +5,13 @@ export const updateQuestionData = ( props: { questionData: T - index: number }, context: SetupContext<{ - update: (question: T, index: number) => true + update: (question: T) => true }> ) => (key: keyof T, value: T[keyof T]): void => { const newData = { ...props.questionData } newData[key] = value - context.emit('update', newData, props.index) + context.emit('update', newData) } From 919f7341214271586d345aaabf207713482c820b Mon Sep 17 00:00:00 2001 From: wakashi1 Date: Mon, 23 May 2022 11:38:00 +0900 Subject: [PATCH 08/14] =?UTF-8?q?=E3=81=86=E3=81=BE=E3=81=8F=E5=8B=95?= =?UTF-8?q?=E3=81=8B=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewQuestionnaire/Forms/ChoiceForm.vue | 35 +++++++++++-------- src/components/NewQuestionnaire/Questions.vue | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue index 3dde8e56..36540da3 100644 --- a/src/components/NewQuestionnaire/Forms/ChoiceForm.vue +++ b/src/components/NewQuestionnaire/Forms/ChoiceForm.vue @@ -1,7 +1,7 @@