Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a couple bugs in CustomFieldSetDefaultValuesForModel component #15486

Merged
merged 27 commits into from
Sep 11, 2024

Conversation

marcusmoore
Copy link
Collaborator

Description

This PR fixes a couple bugs and adds some niceties to the CustomFieldSetDefaultValuesForModel component.


🐛 Selecting a fieldset, checking the "Add default values" checkbox, and then selecting "No custom fields" would result in the fieldset default value fields still being shown:
fieldset default value fields still being shown


🐛 Having checkboxes and radio buttons have the same values resulted in only the first group rendered on the page being selectable:

example-converted.mov

✨ "Add default values" is dynamic. It is hidden if no fieldset is selected, disabled if the selected fieldset does not have fields in it, and enabled if the selected fieldset has fields that can have default values assigned:

Hidden Disabled Enabled
hidden disabled enabled

✨ In addition, when some input is entered and then the fieldset is changed the input is carried over if the field is present on the newly selected fieldset.

Before:
before

After:
after


Type of change

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

Copy link

what-the-diff bot commented Sep 10, 2024

PR Summary

  • Enhancements to app/Livewire/CustomFieldSetDefaultValuesForModel.php File
    • New code libraries have been incorporated for better functionality.
    • Certain redundant properties like $fields have been removed for code optimization.
    • The mount method has been refined to accept $model_id directly, which improves the processing speed and reduces complexities.
    • Two new utility methods have been introduced that help in array manipulation, leading to better data management.
    • Computed properties are now being used for efficient processing of model and fields.
    • The existing render method is updated to make use of selectedValues, subsequently decreasing the load times.
  • Updates to resources/views/livewire/custom-field-set-default-values-for-model.blade.php File
    • Improved user experience by making the add_default_values checkbox visible only when fieldset_id is present, hence reducing confusion.
    • Fine-tuned loop operation for fields; the loop now uses $this->fields and includes wire:key attribute enabling better data access and tracking.
    • Optimized code by removing the $field parameter from the getSelectedValueForField method.
    • Increased the efficiency and tracking of various elements in the loop by leveraging wire:key attribute, which simplifies data identification and retrieval.

@marcusmoore marcusmoore marked this pull request as ready for review September 10, 2024 23:52
@snipe
Copy link
Owner

snipe commented Sep 11, 2024

Nice!

@snipe snipe merged commit 601d8d7 into snipe:develop Sep 11, 2024
9 checks passed
@marcusmoore marcusmoore deleted the fixes/custom-field-values branch September 12, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants