Skip to content

Commit 25b98e8

Browse files
committed
Add validation modal and enhance menu state handling
- Introduced a validation modal in the identity form actions component. - Added validations prop to handle validation errors. - Updated menu state logging to be commented out for cleaner output. - Refactored various components for consistency and improved readability.
1 parent b5187f9 commit 25b98e8

File tree

7 files changed

+71
-24
lines changed

7 files changed

+71
-24
lines changed

nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ export default defineNuxtConfig({
150150
actions: [{ icon: 'mdi-close', color: 'white' }],
151151
},
152152
},
153+
extras: {
154+
animations: 'all',
155+
},
153156
},
154157
vite: {
155158
define: {

src/assets/sass/global.sass

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ blockquote
55
margin: 0 0 20px
66
border-left: 4px solid $primary
77

8-
98
.sesame-sticky-last-column-table
109
thead tr:last-child th:last-child
1110
background-color: $tooltip-color
@@ -31,14 +30,16 @@ body.body--dark
3130
color: $primary
3231
font-weight: bold
3332

34-
3533
.outer-ne-resize
3634
resize: vertical
3735
overflow: auto
3836

39-
4037
.inner-ne-resize,
4138
.outer-ne-resize
4239
transform: rotateX(180deg)
4340
height: 100%
4441
width: 100%
42+
43+
.sesame.animated.infinite
44+
animation-iteration-count: infinite !important
45+
animation-duration: 3s !important

src/components/2pan/index.vue

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ const props = defineProps({
133133
type: Boolean,
134134
default: false,
135135
},
136-
hideLeftButtons:{
136+
hideLeftButtons: {
137137
type: Boolean,
138138
default: false,
139139
},
140-
hideRightButtons:{
140+
hideRightButtons: {
141141
type: Boolean,
142142
default: false,
143143
},
@@ -175,7 +175,7 @@ const props = defineProps({
175175
},
176176
refresh: {
177177
type: Function,
178-
default: () => { },
178+
default: () => {},
179179
},
180180
total: {
181181
type: Number,
@@ -231,9 +231,11 @@ const props = defineProps({
231231
return row
232232
},
233233
234-
cancel: async () => { },
235-
add: async () => { return {} },
236-
onMounted: async () => { },
234+
cancel: async () => {},
235+
add: async () => {
236+
return {}
237+
},
238+
onMounted: async () => {},
237239
},
238240
},
239241
})
@@ -275,11 +277,14 @@ const route = useRoute()
275277
const { pagination, onRequest, initializePagination } = usePagination()
276278
initializePagination(props.total)
277279
278-
watch(() => props.data, async () => {
279-
if (pagination.value) {
280-
pagination.value.rowsNumber = props.total
281-
}
282-
})
280+
watch(
281+
() => props.data,
282+
async () => {
283+
if (pagination.value) {
284+
pagination.value.rowsNumber = props.total
285+
}
286+
},
287+
)
283288
284289
const emit = defineEmits(['create', 'refresh', 'read', 'update', 'delete'])
285290
const { debug } = useDebug()
@@ -304,10 +309,10 @@ function highlightRow(rowKey) {
304309
}
305310
}
306311
function selectedIsHidden() {
307-
if (props.hideSelection === false){
308-
return "multiple"
309-
}else {
310-
return "none"
312+
if (props.hideSelection === false) {
313+
return 'multiple'
314+
} else {
315+
return 'none'
311316
}
312317
}
313318
@@ -334,7 +339,7 @@ async function read(row) {
334339
async function add() {
335340
const read = NEW_ID
336341
targetId.value = read
337-
target.value = await props.actions.add() || {}
342+
target.value = (await props.actions.add()) || {}
338343
await router.push({ query: { ...route.query, read } })
339344
}
340345
@@ -404,5 +409,4 @@ onMounted(async () => {
404409
})
405410
</script>
406411

407-
<style>
408-
</style>
412+
<style></style>

src/components/identityForm/actions.vue

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
<template lang="pug">
22
div.flex
33
div
4+
q-btn.sesame.infinite.animated.flash(color="negative" @click="validationsModal = true" v-if="!isNew && hasValidations()" outline)
5+
q-tooltip.text-body2(slot="trigger") Afficher les erreurs
6+
q-icon.text-negative(name='mdi-alert-box')
7+
q-dialog(v-model="validationsModal")
8+
q-card(style="min-width: 350px")
9+
q-card-section.q-pa-sm.bg-negative.text-white.flex
10+
q-icon(name='mdi-alert-box' size="2rem")
11+
div.text-h6.q-ml-md Erreurs de validation
12+
q-card-section.q-py-sm
13+
q-list(separator)
14+
q-item(v-for="field in Object.keys(validations)" :key="field")
15+
q-item-section.text-negative
16+
q-item-label {{ field }}
17+
q-item-label(v-for='f in validations[field]' caption) - {{ f }}
18+
q-card-actions(align="right")
19+
q-btn(flat label="Fermer" color="primary" v-close-popup)
420
q-btn(color="positive" icon='mdi-content-save-plus' @click="create" v-show="isNew" v-if="crud.create")
521
q-tooltip.text-body2 Créer
6-
q-toggle.q-pa-md.q-gutter-y-lg(
22+
q-toggle.q-px-md.q-gutter-y-lg(
723
checked-icon="mdi-account-check"
824
unchecked-icon="mdi-account-cancel"
925
indeterminate-icon="mdi-lock-reset"
@@ -76,6 +92,10 @@ const props = defineProps({
7692
refreshTarget: {
7793
type: Function,
7894
},
95+
validations: {
96+
type: Object,
97+
default: {},
98+
},
7999
})
80100
81101
const $q = useQuasar()
@@ -85,6 +105,8 @@ const { handleError } = useErrorHandling()
85105
86106
const emits = defineEmits(['submit', 'sync', 'logs', 'create', 'delete'])
87107
108+
const validationsModal = ref(false)
109+
88110
async function doChangePassword() {
89111
const requestOptions = { method: 'POST', body: JSON.stringify({ id: props.identity._id, newPassword: newpassword.value }) }
90112
try {
@@ -105,6 +127,18 @@ async function doChangePassword() {
105127
}
106128
resetPasswordModal.value = false
107129
}
130+
131+
function hasValidations() {
132+
if (props.validations) {
133+
for (const field in props.validations) {
134+
if (Object.keys(props.validations[field]).length > 0) {
135+
return true
136+
}
137+
}
138+
}
139+
return false
140+
}
141+
108142
async function submit() {
109143
// console.log('submit from actions')
110144
emits('submit')

src/components/jsonFormRendererApi.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const data = defineModel('data', {
100100
function onChange(event: JsonFormsChangeEvent) {
101101
data.value = event.data
102102
103-
console.log('onChange', event)
103+
// console.log('onChange', event)
104104
105105
if (!event.data) {
106106
console.error('error', event.errors)

src/composables/useMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function useMenu(identityStateStore) {
173173
const stateValue = identityStateStore.getStateValue(label)
174174
const value = stateValue > 9999 ? '9999+' : stateValue?.toString() || '0'
175175

176-
console.log('stateValue', label, stateValue, value)
176+
// console.log('stateValue', label, stateValue, value)
177177

178178
// const badgeType = menu.badgeValue ? menu.badgeValue : 'UNKNOWN'
179179
// const stateInfo = getStateInfos(IdentityState[badgeType])

src/pages/identities/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ q-page.container
3838
@sync="sync"
3939
@logs="logs"
4040
@delete="deleteIdentity"
41+
:validations="getValidations(target)"
4142
:crud="crud"
4243
:isNew="isNew"
4344
:refreshTarget="refreshTarget"
@@ -222,5 +223,9 @@ const fieldsList = computed(() => {
222223
}, [])
223224
})
224225
226+
function getValidations(target: Identity) {
227+
return target?.additionalFields?.validations ? target?.additionalFields?.validations : {}
228+
}
229+
225230
provide('fieldsList', fieldsList.value)
226231
</script>

0 commit comments

Comments
 (0)