snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Fixes Vague Error Messages In Setting Asset Model Default Values

Open spencerrlongg opened this issue 1 year ago • 2 comments

Description

Fixes an issue when setting default values for custom fields on a model would error, but not show the field that errored or keep the custom fields shown.

image

Fixes #SC-25921

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)

Test Configuration:

  • PHP version: 8.2
  • MySQL version 8.1

spencerrlongg avatar Sep 25 '24 20:09 spencerrlongg

PR Summary

  • Introduction of a new validatorErrors property A new validatorErrors property has been added to the AssetModelsController. This property is used to store any errors that might occur during the validation process.

  • Improved error handling in the update method The update method within the AssetModelsController has been updated. Instead of displaying a hardcoded error message when an issue arises, it now uses the validatorErrors property.

  • Validation error management in assignCustomFieldsDefaultValues method There is now a method for storing errors during the assignCustomFieldsDefaultValues process. Any errors found during this process are held in the validatorErrors property.

  • Refinement of the mount method in the Livewire component The mount method in the Livewire component now checks for errors stored in the session. Depending on the findings, it adjusts the add_default_values property accordingly.

  • Upgraded Blade template for the Custom Field Set The blade template handling Custom Field Set now uses db_column_name() to handle errors. This replaces the previous hardcoded system and allows for more dynamic error management.

  • Simplified handling of error message display Error message display handling has been simplified and consolidated across custom_fields_form.blade.php and edit.blade.php.

  • Code readability improvements Unnecessary blank lines have been removed and whitespace adjusted for better readability across the various modified Blade templates.

what-the-diff[bot] avatar Sep 25 '24 20:09 what-the-diff[bot]

This should be ready to go now, @snipe

spencerrlongg avatar Oct 01 '24 15:10 spencerrlongg

Doesn't seem like it'll let me re-run codacy again after switching base branch, so 🤷‍♂️

spencerrlongg avatar Nov 12 '24 21:11 spencerrlongg