samvera / hydra-editor

A basic editor for samvera objects.
Other
10 stars 13 forks source link

Hiding the link that could remove required input #193

Closed jeremyf closed 3 years ago

jeremyf commented 3 years ago

With the following CSS

.multi_value .listing li:first-of-type .remove { display: none; }
.multi_value .listing li:first-of-type { width: 83.333333%; }

I get the following UI

I spent some time working through the javascript, and it's a rather nasty labyrinth. First, all multi-values are written by JS (see the field_manager.es6 file in Hydra::Editor). My hope was to be able to discard the "X Remove" button from the HTML of the first element. However, that proved difficult as there's an assumption that that HTML will be around when we click the "Add another Title" link.

It would be possible to "store that" somewhere, but that felt like some complicated changes. Instead I went down the path of CSS and settled on the above. It's not quite perfect but it does things a little better. Yes, you could disable stylesheets and thus see the button again. Yes you could inspect element and do nefarious things. But at the root, this solution preserves the "required" input field AND helps avoid POSTing the form.

Related to samvera/hyrax#3526