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 zerofill_count field being ignored during set up #16081

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

marcusmoore
Copy link
Collaborator

Currently, any user supplied value for the "Length of asset tags, including zerofill" on the set up page is ignored upon submission. This PR fixes that.

Setup User page

Copy link

what-the-diff bot commented Jan 16, 2025

PR Summary

  • Introduction of a new property
    A new property called zerofill_count has been added to the settings. This property comes with a default value of 5. It provides more configuration options in our tool.

@snipe
Copy link
Owner

snipe commented Jan 16, 2025

Do we want to assume 5 as a zerofill? Some folks don't use one at all

@marcusmoore
Copy link
Collaborator Author

@snipe that's a good point. I think I pulled that from the column default? Not sure. Either way, I set it to 0 if nothing is provided. ($request->input('zerofill_count', 0 didn't work because the value is null if left empty)

@@ -192,7 +192,7 @@ public function postSaveFirstAdmin(SetupUserRequest $request) : RedirectResponse
$settings->next_auto_tag_base = 1;
$settings->auto_increment_assets = $request->input('auto_increment_assets', 0);
$settings->auto_increment_prefix = $request->input('auto_increment_prefix');
$settings->zerofill_count = $request->input('zerofill_count', 5);
$settings->zerofill_count = $request->input('zerofill_count') ?: 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just:

$settings->zerofill_count = $request->input('zerofill_count', 0);

would work, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too but when I tried it the result of the function was null which triggered an exception.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how we set defaults when no value has been passed everywhere else though. 🤔 I don't see why it wouldn't work here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I figured it out.

These are checkboxes on the front end and if they are unchecked the browser does not include them in the payload:

$settings->full_multiple_companies_support = $request->input('full_multiple_companies_support', 0);
$settings->auto_increment_assets = $request->input('auto_increment_assets', 0);

This is a text input so the browser always includes it but Laravel sets it to null if nothing was input:

$settings->zerofill_count = $request->input('zerofill_count', 0);

So it ends up using null because it is in the request.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and it looks like that db field is not nullable, hence the error

@snipe snipe merged commit 57f8029 into snipe:develop Jan 16, 2025
8 checks passed
@marcusmoore marcusmoore deleted the fixes/zerofill-count-on-setup branch January 16, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants