gtt-project/redmine_gtt

Creating an issue through `/issues/new` does not handle the plugin correctly.

dkastl opened this issue · 6 comments

dkastl commented

Firstly calling @project to fetch project related information does not work.
The project can be access thorughissue.project though.

With this change the map will not initialize correctly when the project change triggers a dynamic loading of content.

Here is the error message details on current next branch,

Started GET "/issues/new" for 127.0.0.1 at 2024-05-13 15:12:35 +0900
Processing by IssuesController#new as HTML
  :
  ↳ app/models/issue_status.rb:80:in `new_statuses_allowed'
  Rendering layout layouts/base.html.erb
  Rendering issues/new.html.erb within layouts/base
  Rendered plugins/redmine_gtt/app/views/redmine_gtt/hooks/_view_issues_form_details_top.html.erb (Duration: 1.5ms | Allocations: 2762)
  Rendered issues/_form.html.erb (Duration: 1.7ms | Allocations: 2881)
  Rendered issues/new.html.erb within layouts/base (Duration: 4.2ms | Allocations: 3765)
  Rendered layout layouts/base.html.erb (Duration: 4.3ms | Allocations: 3842)
Completed 500 Internal Server Error in 47ms (ActiveRecord: 8.0ms | Allocations: 21260)

NoMethodError - undefined method `map_rotation' for nil:NilClass:
  plugins/redmine_gtt/app/views/redmine_gtt/hooks/_view_issues_form_details_top.html.erb:5
  lib/redmine/hook/view_listener.rb:61:in `block (2 levels) in render_on'
  lib/redmine/hook/view_listener.rb:59:in `block in render_on'
  lib/redmine/hook.rb:66:in `block (2 levels) in call_hook'
  lib/redmine/hook.rb:66:in `block in call_hook'
  lib/redmine/hook.rb:63:in `call_hook'
  lib/redmine/hook.rb:101:in `call_hook'
  app/views/issues/_form.html.erb:2
  app/helpers/application_helper.rb:1494:in `labelled_fields_for'
  app/views/issues/_form.html.erb:1
  app/views/issues/new.html.erb:11
  app/helpers/application_helper.rb:1487:in `labelled_form_for'
  app/views/issues/new.html.erb:5
  app/controllers/issues_controller.rb:140:in `block (2 levels) in new'
  app/controllers/issues_controller.rb:139:in `new'
  lib/redmine/sudo_mode.rb:61:in `sudo_mode'

and it seems to happen when accessing map_rotation attribute of @project instance.

  <%= map_form_field form, issue.map, bounds: issue.project.map.bounds, rotation: @project.map_rotation,
  :

@dkastl

With this change the map will not initialize correctly when the project change triggers a dynamic loading of content.

Well, I confirmed that this remaining issue on PR:#269.
I am thinking to add system test and solve remaining issues, but it may take a certain time...
Can I merge PR:#277 to #269 and rebase it from the latest next branch ?

I think you can merge, but aren't they still draft?

Ah, that's my draft ... I totally forgot. Feel free to merge as you like

Okay, thanks for confirmation!

I just confirmed a manual test with 2 projects, one with GTT enabled and one without GTT.
Creating new issues from /issues/new was no problem with this fix.

So I will merge this PR, and let's improve CI and tests then in another one.