Skip to content

Commit

Permalink
Adopt fields in wayPoint form to vuetify 2 #248
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfausk committed Jan 9, 2025
1 parent c790f25 commit 187b460
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 246 deletions.
75 changes: 75 additions & 0 deletions web/assets/js/components/Common/SwitchField.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<script setup lang="ts">
import {computed} from "vue";
import {ErrorData, getViolationsFeedback} from "../../utils";
// const props = defineProps(['modelValue', 'value']); // vue3
// const emit = defineEmits(['update:modelValue']); // vue3
const emit = defineEmits(['input']);
export interface Props {
caption: string,
value: boolean,
label?: string,
hint?: string,
placeholder?: string,
dataTest?: string,
error?: ErrorData,
violationFields?: string[],
isLoading?: boolean
disabled?: boolean
}
const props = withDefaults(defineProps<Props>(), {
label: '',
hint: '',
placeholder: '',
violationFields: () => [] as string[],
dataTest: '',
error: () => {return {} as ErrorData} ,
isLoading: false,
disabled: false,
});
const value = computed({
get() {
// return props.modelValue // vue3
return props.value
},
set(value) {
// emit('update:modelValue', value); // vue3
emit('input', value)
}
});
const errorMessages = computed(() => {
if (!props.error) {
return ''
}
return getViolationsFeedback(props.violationFields, props.error);
})
</script>

<template>
<div class="mb-2">
{{ caption }}<br>
<v-switch
v-model="value"
:disabled="isLoading || disabled"
:label="label"
dense
class="mt-0"
:error-messages="errorMessages"
:error="!!errorMessages?.length"
:hint="hint"
:persistent-hint="!!hint"
:hide-details="!hint && !errorMessages?.length"
:data-test="dataTest"
:loading="isLoading"
></v-switch>
</div>
</template>

<style scoped>
</style>
77 changes: 77 additions & 0 deletions web/assets/js/components/Common/TextareaField.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<script setup lang="ts">
import {computed} from "vue";
import {ErrorData, getViolationsFeedback} from "../../utils";
// const props = defineProps(['modelValue', 'value']); // vue3
// const emit = defineEmits(['update:modelValue']); // vue3
const emit = defineEmits(['input']);
export interface Props {
value: string,
label?: string,
hint?: string,
placeholder?: string,
dataTest?: string,
error?: ErrorData,
violationFields?: string[],
isLoading?: boolean
disabled?: boolean
}
const props = withDefaults(defineProps<Props>(), {
label: '',
hint: '',
placeholder: '',
violationFields: () => [] as string[],
dataTest: '',
error: () => {return {} as ErrorData} ,
isLoading: false,
disabled: false,
});
const value = computed({
get() {
// return props.modelValue // vue3
return props.value
},
set(value) {
// emit('update:modelValue', value); // vue3
emit('input', value)
}
});
const errorMessages = computed(() => {
if (!props.error) {
return ''
}
return getViolationsFeedback(props.violationFields, props.error);
})
</script>

<template>
<v-textarea
v-model="value"
:disabled="isLoading || disabled"
minlength="1"
maxlength="3500"
:label="label"
:placeholder="placeholder"
:data-test="dataTest"
rows="3"
trim
max-rows="15"
outlined
dense
class="mb-2"
:hint="hint"
:persistent-hint="!!hint"
:hide-details="!hint && !errorMessages?.length"
:error-messages="errorMessages"
:error="!!errorMessages?.length"
/>
</template>

<style scoped>
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script setup lang="ts">
import {computed, ref} from "vue";
import {getViolationsFeedback} from "../../../utils";
// const props = defineProps(['modelValue', 'value']); // vue3
// const emit = defineEmits(['update:modelValue']); // vue3
const emit = defineEmits(['input']);
export interface Props {
value: number,
label?: string,
hint?: string,
error?: Object | boolean,
isLoading?: boolean
}
const props = withDefaults(defineProps<Props>(), {
label: 'Wetter',
hint: '',
error: false,
isLoading: false,
});
const contactsCountOptions = ref<number[]>(Array.from(Array(41), (x, i) => i));
const value = computed({
get() {
// return props.modelValue // vue3
return props.value
},
set(value) {
// emit('update:modelValue', value); // vue3
emit('input', value)
}
});
const errorMessages = computed(() => {
return getViolationsFeedback(['contactsCount'], props.error);
})
</script>

<template>
<v-select
v-model="value"
:items="contactsCountOptions"
:label="label"
data-test="contactsCount"
outlined
:hint="hint"
:persistent-hint="!!hint"
dense
:disabled="isLoading"
:error-messages="errorMessages"
:error="!!errorMessages?.length"
/>
</template>

<style scoped>
</style>
1 change: 1 addition & 0 deletions web/assets/js/components/Common/WayPoint/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export {default as WayPointContactsCountField} from './WayPointContactsCountField.vue';
export {default as WayPointLocationNameField} from './WayPointLocationNameField.vue';
export {default as WayPointVisitedAtField} from './WayPointVisitedAtField.vue';
2 changes: 2 additions & 0 deletions web/assets/js/components/Common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {default as SwitchField} from './SwitchField.vue';
export {default as TextareaField} from './TextareaField.vue';
1 change: 1 addition & 0 deletions web/assets/js/components/Tags/ColorBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<v-chip
class="font-weight-bold d-flex align-items-center"
:style="`background-color: ${ color }`"
small
pill
>
<span
Expand Down
13 changes: 13 additions & 0 deletions web/assets/js/components/Tags/TagCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:state="nameState"
label="Name"
outlined
dense
data-test="name"
/>
Gewählte Tag-Farbe:
Expand All @@ -26,6 +27,7 @@
data-test="farbe"
required
outlined
dense
item-value="name"
item-text="name"
>
Expand All @@ -47,6 +49,7 @@
label="Für welchen Klienten?"
placeholder="Für welchen Klienten?"
:items="availableClients"
dense
item-value="@id"
item-text="name"
outlined
Expand Down Expand Up @@ -75,6 +78,16 @@
Bitte erst Name und Farbe wählen bevor ein neuer Tag erstellt werden kann.
</span>
</v-tooltip>
<v-btn
v-else
type="submit"
color="secondary"
data-test="button-tag-create"
:disabled="isFormInvalid || isLoading"
block
>
Neuen Tag erstellen
</v-btn>
<form-error
:error="error"
/>
Expand Down
Loading

0 comments on commit 187b460

Please sign in to comment.