scientist-softserv / amigos

0 stars 0 forks source link

:bug: Based Near property oddities #43

Open ShanaLMoore opened 3 months ago

ShanaLMoore commented 3 months ago

Summary

Details

ON MAIN - A user is able to add a location to a work.

image

Add new work > pick a work type Add required fields. Click 'Additional Fields' Find the location property. In the drop down, type in a city name. Select one from the auto populated list. Submit the work

Based_near will be displayed on the work's show page.

![image](https://github.com/scientist-softserv/amigos/assets/10081604/fe908d6a-088b-4e3d-9ba9-3df0f9cd8162)

Click to edit the work. The location property will display the selected city:

![image](https://github.com/scientist-softserv/amigos/assets/10081604/42c012ec-6607-4472-8177-9a2295893bf5)

ON flexible_double_combo ...

How it looks when saved:

image

We noticed that the params look weird after the form get validated here. Diff from main is that it includes several #<ActionController::Parameters within the nested params. Is that a problem?

![Screenshot 2024-06-28 at 10 05 08 AM](https://github.com/scientist-softserv/amigos/assets/10081604/3c7db654-38e0-4242-8887-ea231aaa911d)

Dev Notes

Make sure geonames is configured. Otherwise, the drop down will not find any results.

In .koppie/config/intitializers/hyrax.rb update the following to:

  config.geonames_username = ENV['GEONAMES_USERNAME'] || 'scientist'

This diff Avoids the error about invalid type when saving based_near property on flexible_double_combo. I'm not sure if it's the correct approach. Related PR

image

kirkkwang commented 3 months ago

Currently, the Based Near that shows up on the show page should be Location and reads from based_near_label solr property

laritakr commented 3 months ago

The problem is in the form in works_controller_behavior method build_form. The form being built and validated doesn't have a location object so it validates and updates the form incorrectly.

when the form goes to validate @fields contains

    "based_near"=>
    #<ActionController::Parameters {"0"=>#<ActionController::Parameters {"hidden_label"=>"Northern Europe, ", "id"=>"https://sws.geonames.org/7729883/", "_destroy"=>""} permitted: false>} permitted: false>,

The form needs to contain

   "based_near"=>[#<Hyrax::ControlledVocabularies::Location:0x67944 ID:_:g413400>],

The initial build of the form should include the based_near location object. In our branch it doesn't.

In Hyrax::FormFactory, prepopulate! is not filling in the value for based_near in the call to Valkyrie's change_set

laritakr commented 2 months ago

Tabled for now as a known bug, to work on higher priority issues.