feat: auto complete missing custom fields on machine page
This commit is contained in:
@@ -97,6 +97,34 @@ export function useMachines() {
|
||||
}
|
||||
}
|
||||
|
||||
const addMissingCustomFields = async (machineId, { showToast: shouldShowToast = true } = {}) => {
|
||||
if (!machineId) {
|
||||
const error = 'Identifiant de machine manquant'
|
||||
if (shouldShowToast) {
|
||||
showError(error)
|
||||
}
|
||||
return { success: false, error }
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await post(`/machines/${machineId}/add-custom-fields`)
|
||||
if (result.success) {
|
||||
if (shouldShowToast) {
|
||||
showSuccess('Champs personnalisés complétés avec succès')
|
||||
}
|
||||
} else if (shouldShowToast && result.error) {
|
||||
showError(result.error)
|
||||
}
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de l’ajout des champs personnalisés manquants:', error)
|
||||
if (shouldShowToast) {
|
||||
showError('Erreur lors de la complétion des champs personnalisés')
|
||||
}
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
}
|
||||
|
||||
const deleteMachine = async (id) => {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -143,6 +171,7 @@ export function useMachines() {
|
||||
getMachinesBySite,
|
||||
getMachinesByType,
|
||||
getMachines,
|
||||
isLoading
|
||||
isLoading,
|
||||
addMissingCustomFields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user