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

Feature Request: Userfield checkboxes: Mandatory unchecked state #2601

Open
jonaskp opened this issue Oct 31, 2024 · 4 comments
Open

Feature Request: Userfield checkboxes: Mandatory unchecked state #2601

jonaskp opened this issue Oct 31, 2024 · 4 comments

Comments

@jonaskp
Copy link

jonaskp commented Oct 31, 2024

When adding a mandatory checkbox as a userfield, currently this will force you to check it (=True), otherwise you cannot save.
My example below is based on a checkbox for a product, but I think this applies everywhere.

Benefits:
The current implementation of checkboxes, does not show whether or not you have actively chosen the checkbox to be "un-checked", or if you just haven't selected anything (for instance for products that was already created, when you create the checkbox).

The below suggestion would make it easy to see whether or not you have actually "selected" true/false on the checkbox or not.

Suggestion for how it should work:

  • Should have both a "checked"/true and "un-checked"/false state - plus a "not-yet-selected"/blank state.
    These could be: "Checkmark" (true), "X" (false), "blank" (blank/unselected).
    Or alternatively "Checkmark" (true), "blank" (false), "greyed out" (blank/unselected).

  • The checkbox should always start as "blank". This should happen both if you create a new product after the userfield has been created, or if you create the Userfield after (meaning the "blank" checkbox gets added to all current products).
    The "unselected" option is only "available" to Grocy (not the user). Once you either check or uncheck the checkbox, it is not possible to go back to "blank/unselected" state.

  • For Mandatory checkboxes, this would now give the option to actively select "un-checked" for a checkbox, as the "mandatory-check" would check whether the checkbox is "blank"/unselected.

Other considerations:
I don't know if this should be a change to the current checkbox, or if it should be a new different type of userfield. Like a separate "true/false"-checkbox. Personally I think this is how the checkbox should work, so no need to have two different "versions".
I can't think of a reason (other than time needed to implement vs benefit) why you would specifically want the checkbox to function the way it currently does, over the above suggestion, but I might be missing some usecases.
Also, the current implementation basically make a "mandatory checkbox" redundant, as the only possible option when creating a product, is to have it "checked" - otherwiser you wont be allowed to save.

Current workarounds
You can create a userfield list instead, with the options: "Yes"/"No" (or similar), which basically gives the same functionality (which is what I have done in the cases where I wanted a mandatory checkbox.

However, I think I actually consider this a bug (at least the part about the mandatory checkbox), which is why I have made an issue (even though there is a fairly obvious and easy workaround).
Whether or not this should have been marked as a bug or feature request, I was unsure. But I think the possible solutions goes beyond just a bug fix, so I settled on feature request.

Demo instance for the "Bug" regarding mandatory Checkbox:
I have created a demo-instance: https://test-4q9qfsfebzq698hq1wn9vt.demo-prerelease.grocy.info
It has 2 products under Master Data -> Products: Food Product and Non-Food Product.
And a userfield mandatory checkbox "is this food?" (created AFTER both products was created).
For the Food Product, the checkbox has been "checked".
For the Non-Food Product, the checkbox is unchecked (as the userfield was created AFTER the product).

When trying to edit the product, the mandatory checkbox is marked as an error, if you try to leave it unchecked. Checking, and then unchecking again, also gives an error.

@berrnd
Copy link
Member

berrnd commented Oct 31, 2024

I think I actually consider this a bug
Whether or not this should have been marked as a bug or feature request, I was unsure

Great that you haven't declared it as a Bug, since I'm very allergic that everything, what's just not behaving how one personally likes it, is reported as a big Bug.

Grocy's web frontend utilizes standard HTML. Mandatory form input fields are declared by an attributed required (doc ref). The mandatory option of any Userfield does nothing more than settings this attribute on the corresponding input field (code ref). Userfields are implemented in a generic way, so most things are just the same for every Userfield type.

So generally we can only use what the HTML standard defines and major web Browser's support.

If you e.g. search for something like html required unchecked checkbox, there is no standard for that. In other user interfaces (e.g. default .Net Windows stuff), there is often a so called tri-state checkbox. The third state (beside checked/unchecked) is then most of the time visualized as a filled square (so no checkmark, just a solid color and maybe another one then used for the checked state).

So we can't utilize a standard for that and have to invent it ourselves when we want that in Grocy's web frontend. Maybe somehow utilizing the input indeterminate state for that (doc ref). If you have practical experience how to do mandatory unchecked checkboxes in HTML, feel free to propose a better solution.

@berrnd berrnd changed the title Feature Request: Make mandatory Checkbox (userfield) possible, with an actual "not-checked"/false option Feature Request: Userfield checkboxes: Mandatory unchecked state Oct 31, 2024
@jonaskp
Copy link
Author

jonaskp commented Oct 31, 2024

Great that you haven't declared it as a Bug, since I'm very allergic that everything, what's just not behaving how one personally likes it, is reported as a big Bug.

Totally agree. Sometimes it's a grey area, but it's always good practice to try to look at issues from different angles, and try to find out if it is actually just that you have different expectations.

From a user stand-point, I still think that the "mandatory checkbox that is not able to be unchecked" is kind of a "bug". Because having a checkbox (that is mandatory) that can only ever be checked, is not what I would call "expected behavior".
But as you explain, from an implementation/developer stand-point, this is more a limitation of the technology currently.

And as such, I would not consider this like any sort of high priority.
There is a very easy workaround that essentially does the same thing - and so far this might only be an issue for 1 user...

So I basically just wanted to flag this, when I noticed it.
If for no other reason, than to have it logged, so if someone else finds that they have need and issue, they can find the workaround as well.

If you have practical experience how to do mandatory unchecked checkboxes in HTML, feel free to propose a better solution.

Unfortunately, no. Still very limited in my coding experience.

So I am one of those people who can just find the issues (and having worked as a business analyst and being part of testing, basically have been trained for it), often suggest (part of) a solution, but then have to hand the actual work over to someone else...
Still hoping one day to be able to actually contribute to one of these kind of projects that people like yourself put so much time and effort into, for so many of us to enjoy.

@lakefire

This comment was marked as spam.

@berrnd

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants