chore: update frontend configuration
This commit is contained in:
@@ -5,7 +5,7 @@ import { useToast } from './useToast'
|
||||
const componentModelsBuckets = ref({})
|
||||
const loadingComponentModels = ref(false)
|
||||
|
||||
export function useComponentModels() {
|
||||
export function useComponentModels () {
|
||||
const { get, post, patch, delete: del } = useApi()
|
||||
const { showSuccess, showError } = useToast()
|
||||
|
||||
@@ -18,7 +18,7 @@ export function useComponentModels() {
|
||||
const key = typeComposantId || '__all__'
|
||||
componentModelsBuckets.value = {
|
||||
...componentModelsBuckets.value,
|
||||
[key]: result.data,
|
||||
[key]: result.data
|
||||
}
|
||||
}
|
||||
return result
|
||||
@@ -39,7 +39,7 @@ export function useComponentModels() {
|
||||
const bucket = componentModelsBuckets.value[key] || []
|
||||
componentModelsBuckets.value = {
|
||||
...componentModelsBuckets.value,
|
||||
[key]: [...bucket, result.data],
|
||||
[key]: [...bucket, result.data]
|
||||
}
|
||||
showSuccess(`Modèle de composant "${result.data.name}" créé`)
|
||||
}
|
||||
@@ -59,12 +59,12 @@ export function useComponentModels() {
|
||||
if (result.success) {
|
||||
const key = result.data?.typeComposantId || '__all__'
|
||||
const bucket = componentModelsBuckets.value[key] || []
|
||||
const updatedBucket = bucket.map((model) =>
|
||||
const updatedBucket = bucket.map(model =>
|
||||
model.id === id ? result.data : model
|
||||
)
|
||||
componentModelsBuckets.value = {
|
||||
...componentModelsBuckets.value,
|
||||
[key]: updatedBucket,
|
||||
[key]: updatedBucket
|
||||
}
|
||||
showSuccess(`Modèle de composant "${result.data.name}" mis à jour`)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ export function useComponentModels() {
|
||||
if (result.success) {
|
||||
const updatedBuckets = {}
|
||||
for (const [key, bucket] of Object.entries(componentModelsBuckets.value)) {
|
||||
updatedBuckets[key] = bucket.filter((model) => model.id !== id)
|
||||
updatedBuckets[key] = bucket.filter(model => model.id !== id)
|
||||
}
|
||||
componentModelsBuckets.value = updatedBuckets
|
||||
showSuccess('Modèle de composant supprimé')
|
||||
@@ -101,7 +101,7 @@ export function useComponentModels() {
|
||||
const allComponentModels = computed(() => {
|
||||
return Object.values(componentModelsBuckets.value).reduce((acc, bucket) => {
|
||||
bucket.forEach((model) => {
|
||||
if (!acc.find((existing) => existing.id === model.id)) {
|
||||
if (!acc.find(existing => existing.id === model.id)) {
|
||||
acc.push(model)
|
||||
}
|
||||
})
|
||||
@@ -126,6 +126,6 @@ export function useComponentModels() {
|
||||
deleteComponentModel,
|
||||
getComponentModels,
|
||||
getComponentModelsForType,
|
||||
isComponentModelLoading,
|
||||
isComponentModelLoading
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user