Closed r-ferrier closed 7 months ago
The biggest issue here is making a partner that already exists. You fill in all the fields to get a "partner already exists" notice. GI have hit this a few times.
Edit: maybe this is describing a slightly diff issue -> https://github.com/geeksforsocialchange/PlaceCal/issues/2341
That sounds like a different issue and a tricky one, we'd have to expose a list of existing partners to get around that. Long term that would look like transferring to a different security / permissions model. When I raised it before you proposed that GFSC staff deal with it manually. https://github.com/geeksforsocialchange/PlaceCal/issues/2063#issuecomment-1774955303
Research: multi-page activemodel saving
https://old.reddit.com/r/rails/comments/bxmo8i/whats_gems_if_any_do_you_use_to_build_complex/
Other thoughts:
Apart from what Alfie said there may also be a way to do this by having a partner have a "setup stage" that only shows a small subset of controls, validating only those controls as it goes, before saving completely and becoming "fully formed". Then the "new partner" interface would be a setup wizard with multiple steps.
But this would be a lot of work:
gonna watch this and see if we can provide validation before saving / losing info
https://www.youtube.com/watch?v=9zJ-r3Rsx7Q
Another option might be to trigger the models validation in the controller and then set the formfields in advance when resetting the page. We do something similar here.
def validate_partner_relation
# we only allow admins to assign partners they can see so any ids here are proof of a relationship
return if current_user.root?
return unless params[:user][:partner_ids].reject { |id| id == '' }.empty?
# we're about to refresh the page so save the users input
@user = User.new(permitted_attributes(User))
flash.now[:danger] = 'User was not created: You must assign a Partner to the User or you will not be able to access it after creation'
render 'new', status: :unprocessable_entity
end
ok conclusion based on the video to do live feedback with hotwire
This is unlikely to solve the issue of dropped fields with an invalid submit but may reduce the amount people do that. We could probably disable the submit button based on this feedback until all fields are valid.
I think I would give this ee
with the basic implementation per form. If we are covering all forms or a form with a less basic implementation then the eee
situation escalates quite quickly.
Checking this manually. So far I have checked
Partner
Tags
Collection (has no validations)
Neighbourhoods
(has only one validation for unit_code_value
)
(only root can edit)
Supporters (only root can modify supporters)
Articles
Site
Calendar
Users
Turns out the slug
field is going to be tricky because we use this friendly_id gem that seems to want to do the slugging by itself but also we have the slug form field and they might be fighting each other.
slug
is root only, and tbh its kind of a pain letting people edit it as wrong stuff gets pasted in there all the time.
would be happy to move this to readonly as a stopgap if that helps things? if we are in a pinch we can always change it with console
site and tag creation is the only place i think we actually need people to be able to edit it? (hm perhaps this needs verifying a bit - its mostly partners that get junk data, and people messing with the slug on sites dont realise itll need a new ssl cert)
alternatively - lets just slap a big red warning on it - "dont edit if you dont know what youre doing" kind of thing - its only our few remaining root users this applies to anyway? (yeah this is prob easiest actually?)
Tags
Site
Calendar
Users
state persists but select2 issue raised #2357
Slug and images have been sharded out so not covered by this verification
Description
input lost if validation fails
AC
notes
Ivan uncovered these fields that are failing
Partner
Tags
Site
Calendar
Users
We should investigate dynamic in-page form field validation.~~From notion: https://www.notion.so/gfsc/Kim-s-timeline-for-completion-12-3-24-d0e8ef7a03c44ba08e56d4477e3fea5d Improve field validation process — can we have fields autosave as you go, etc? I think hotwire is meant to be good for this.~~
primary models
secondary models