Skip to content

Commit 0979860

Browse files
committed
Revert "Make the enter key submit the forms"
This reverts commit e29bd82.
1 parent c9d81e9 commit 0979860

File tree

4 files changed

+107
-106
lines changed

4 files changed

+107
-106
lines changed

src/components/Form.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<script setup lang="ts">
22
const errors = defineModel<string[]>({ required: true });
3-
defineEmits(["submit"]);
43
</script>
54

65
<template>
7-
<form class="flex flex-col gap-4" @keydown.enter.prevent="$emit('submit')">
6+
<div class="flex flex-col gap-4 h-full">
87
<fwb-alert v-if="errors.length > 0" type="danger">
98
<span class="font-medium">Ensure that these requirements are met:</span>
109
<ul class="mt-1.5 ml-4 list-disc list-inside">
1110
<li v-for="error in errors" :key="error">{{ error }}</li>
1211
</ul>
1312
</fwb-alert>
1413

15-
<div class="flex flex-col gap-3">
14+
<div class="flex flex-col gap-3 basis-full overflow-y-auto">
1615
<slot name="content" />
1716
</div>
1817

1918
<div class="grid grid-cols-2 gap-3">
2019
<slot name="footer" />
2120
</div>
22-
</form>
21+
</div>
2322
</template>

src/views/brands/NewBrandView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const createBrand = async () => {
5858
</template>
5959

6060
<template #content>
61-
<Form v-model="newBrandForm.errors" class="w-1/4" @submit="createBrand">
61+
<Form v-model="newBrandForm.errors" class="w-1/4">
6262
<template #content>
6363
<fwb-input
6464
label="Name"

src/views/models/EditModelView.vue

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -306,107 +306,109 @@ onMounted(async () => {
306306
<template #content>
307307
<NetworkError v-if="fetchFailed" />
308308
<div v-else class="w-full max-w-2xl">
309-
<div class="flex flex-col gap-4">
310-
<fwb-select
311-
v-model="editModelForm.brandId"
312-
:options="brands"
313-
label="Brand"
314-
placeholder="required"
315-
disabled
316-
/>
317-
<fwb-input
318-
label="Model name"
319-
name="name"
320-
placeholder="required"
321-
size="md"
322-
v-model="editModelForm.name"
323-
disabled
324-
/>
325-
</div>
326-
327-
<div>
328-
<div class="block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white">
329-
Measurements
330-
</div>
331-
<fwb-card class="p-4 !max-w-full">
332-
<div
333-
v-for="measurement in measurements"
334-
:key="measurement.id"
335-
class="flex justify-between items-center pb-3 bg-gray-800 rounded-lg mb-2"
336-
>
337-
<div>
338-
<span class="text-sm font-medium text-white">{{ measurement.label }}</span>
339-
<span class="text-xs text-gray-400 ml-2">
340-
({{ measurementTypeLabel(measurement.kind) }})
341-
</span>
309+
<Form v-model="editModelForm.errors">
310+
<template #content>
311+
<fwb-select
312+
v-model="editModelForm.brandId"
313+
:options="brands"
314+
label="Brand"
315+
placeholder="required"
316+
disabled
317+
/>
318+
<fwb-input
319+
label="Model name"
320+
name="name"
321+
placeholder="required"
322+
size="md"
323+
v-model="editModelForm.name"
324+
disabled
325+
/>
326+
327+
<div>
328+
<div class="block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white">
329+
Measurements
342330
</div>
343-
<div class="flex gap-2">
344-
<fwb-button
345-
color="default"
346-
size="xs"
347-
@click="openEditMeasurementModal(measurement.id)"
331+
<fwb-card class="p-4 !max-w-full">
332+
<div
333+
v-for="measurement in measurements"
334+
:key="measurement.id"
335+
class="flex justify-between items-center pb-3 bg-gray-800 rounded-lg mb-2"
348336
>
349-
Edit
350-
</fwb-button>
351-
<fwb-button color="red" size="xs" @click="deleteMeasurement(measurement.id)">
352-
Delete
353-
</fwb-button>
354-
</div>
355-
</div>
356-
<div class="flex justify-end" :class="{ 'mt-2': measurements.length > 0 }">
357-
<fwb-button color="default" size="sm" @click="openAddMeasurementModal">
358-
Add new measurement
359-
<template #suffix>
360-
<Icon icon="flowbite:plus-outline" width="16" height="16" />
361-
</template>
362-
</fwb-button>
363-
</div>
364-
</fwb-card>
365-
</div>
366-
367-
<div>
368-
<div class="block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white">
369-
Evaluation
370-
</div>
371-
<fwb-card class="p-4 !max-w-full">
372-
<div class="flex justify-end mb-6">
373-
<fwb-button color="default" size="sm" @click="openAddEvaluationModal">
374-
{{ existingEvaluation ? "Update evaluation" : "Add evaluation" }}
375-
<template #suffix>
376-
<Icon icon="flowbite:plus-outline" width="16" height="16" />
377-
</template>
378-
</fwb-button>
337+
<div>
338+
<span class="text-sm font-medium text-white">{{ measurement.label }}</span>
339+
<span class="text-xs text-gray-400 ml-2">
340+
({{ measurementTypeLabel(measurement.kind) }})
341+
</span>
342+
</div>
343+
<div class="flex gap-2">
344+
<fwb-button
345+
color="default"
346+
size="xs"
347+
@click="openEditMeasurementModal(measurement.id)"
348+
>
349+
Edit
350+
</fwb-button>
351+
<fwb-button color="red" size="xs" @click="deleteMeasurement(measurement.id)">
352+
Delete
353+
</fwb-button>
354+
</div>
355+
</div>
356+
<div class="flex justify-end" :class="{ 'mt-2': measurements.length > 0 }">
357+
<fwb-button color="default" size="sm" @click="openAddMeasurementModal">
358+
Add new measurement
359+
<template #suffix>
360+
<Icon icon="flowbite:plus-outline" width="16" height="16" />
361+
</template>
362+
</fwb-button>
363+
</div>
364+
</fwb-card>
379365
</div>
380366

381-
<div class="space-y-6">
382-
<fwb-input
383-
label="Review score"
384-
name="reviewScore"
385-
placeholder="optional"
386-
size="md"
387-
type="number"
388-
:model-value="existingEvaluation?.review_score"
389-
disabled
390-
/>
391-
<fwb-input
392-
label="Review URL"
393-
name="reviewUrl"
394-
placeholder="optional"
395-
size="md"
396-
:model-value="existingEvaluation?.review_url"
397-
disabled
398-
/>
399-
<fwb-input
400-
label="Shop URL"
401-
name="shopUrl"
402-
placeholder="optional"
403-
size="md"
404-
:model-value="existingEvaluation?.shop_url"
405-
disabled
406-
/>
367+
<div>
368+
<div class="block mt-4 mb-2 text-sm font-medium text-gray-900 dark:text-white">
369+
Evaluation
370+
</div>
371+
<fwb-card class="p-4 !max-w-full">
372+
<div class="flex justify-end mb-6">
373+
<fwb-button color="default" size="sm" @click="openAddEvaluationModal">
374+
{{ existingEvaluation ? "Update evaluation" : "Add evaluation" }}
375+
<template #suffix>
376+
<Icon icon="flowbite:plus-outline" width="16" height="16" />
377+
</template>
378+
</fwb-button>
379+
</div>
380+
381+
<div class="space-y-6">
382+
<fwb-input
383+
label="Review score"
384+
name="reviewScore"
385+
placeholder="optional"
386+
size="md"
387+
type="number"
388+
:model-value="existingEvaluation?.review_score"
389+
disabled
390+
/>
391+
<fwb-input
392+
label="Review URL"
393+
name="reviewUrl"
394+
placeholder="optional"
395+
size="md"
396+
:model-value="existingEvaluation?.review_url"
397+
disabled
398+
/>
399+
<fwb-input
400+
label="Shop URL"
401+
name="shopUrl"
402+
placeholder="optional"
403+
size="md"
404+
:model-value="existingEvaluation?.shop_url"
405+
disabled
406+
/>
407+
</div>
408+
</fwb-card>
407409
</div>
408-
</fwb-card>
409-
</div>
410+
</template>
411+
</Form>
410412
</div>
411413

412414
<SideModal v-model="addMeasurementModalShown">
@@ -415,7 +417,7 @@ onMounted(async () => {
415417
}}</template>
416418

417419
<template #content>
418-
<Form v-model="newMeasurement.errors" @submit="saveMeasurement">
420+
<Form v-model="newMeasurement.errors">
419421
<template #content>
420422
<fwb-input
421423
label="Label"
@@ -446,7 +448,7 @@ onMounted(async () => {
446448
<fwb-button color="alternative" size="md" @click="closeAddMeasurementModal">
447449
Cancel
448450
</fwb-button>
449-
<fwb-button color="default" size="md" :disabled="saving">
451+
<fwb-button color="default" size="md" @click="saveMeasurement" :disabled="saving">
450452
{{ saving ? "Saving..." : "Save" }}
451453
</fwb-button>
452454
</template>
@@ -460,7 +462,7 @@ onMounted(async () => {
460462
</template>
461463

462464
<template #content>
463-
<Form v-model="newEvaluation.errors" @submit="saveEvaluation">
465+
<Form v-model="newEvaluation.errors">
464466
<template #content>
465467
<fwb-input
466468
label="Review score"
@@ -490,7 +492,7 @@ onMounted(async () => {
490492
<fwb-button color="alternative" size="md" @click="closeAddEvaluationModal">
491493
Cancel
492494
</fwb-button>
493-
<fwb-button color="default" size="md" :disabled="saving">
495+
<fwb-button color="default" size="md" @click="saveEvaluation" :disabled="saving">
494496
{{ saving ? "Saving..." : "Save" }}
495497
</fwb-button>
496498
</template>

src/views/models/NewModelView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ onMounted(() => {
9797
<template #content>
9898
<NetworkError v-if="fetchFailed" />
9999
<div v-else class="w-full max-w-2xl">
100-
<Form v-model="newModelForm.errors" @submit="createModel">
100+
<Form v-model="newModelForm.errors">
101101
<template #content>
102102
<fwb-select
103103
v-model="newModelForm.brandId"

0 commit comments

Comments
 (0)