bartervg / barter.vg

Track and hold discussion on Barter.vg bugs, enhancements, and other issues
https://barter.vg
MIT License
20 stars 4 forks source link

Don't allow form submission if no options are set when editing or adding tradables #166

Open Tecfan opened 3 years ago

Tecfan commented 3 years ago

What problem does this feature address?

Often I spend 15 seconds adding trading tags, and then I click "Set" either without marking the tradable that I wanted to edit, or accidentally clicking "Set" instead of "Add Another Tradable". All my work is then lost. The page refreshes for no reason with nothing happening.

Describe a solution

The "Set" button next to tradables or other collection items on /i/ pages should be disabled until a valid input is added.

Examples of similar features

Tecfan commented 3 years ago

This is so annoying :(

image

As long as this number is "0", aka nothing is marked, the "Set" button should not be possible to click.

bartervg commented 3 years ago

The Set button begins with the disabled attribute. If counter is >0, remove disabled attribute. Would this address the issue?

Tecfan commented 3 years ago

I believe so. The counter goes up regardless of what collection you are editing and thus this would work for all the Set buttons

bartervg commented 3 years ago

Although all of the source code isn't on this repo, I think this could be done with javascript only, and that means, anyone can contribute to the solution: https://github.com/bartervg/barter.vg/blob/develop/js/utils.js

To improve re-usability, I can add data- attributes to the HTML (set button and counter) to use instead of id or name. I've found that using the latter two attributes makes the javascript more difficult to use for other purposes.

Rather than default to disabled in the HTML, the javascript could toggle between disabled if <= 0, and not disabled if > 0.