agileware-jp / redmine_issue_templates

Redmine Issue Template. Pull requests, reporting issues, stars and sponsoring are always welcome!
https://www.redmine.org/plugins/redmine_issue_templates
GNU General Public License v2.0
70 stars 32 forks source link

Note template role setting disappears after changing sort order #48

Closed yui-har closed 1 year ago

yui-har commented 1 year ago

Summary

If you change the sorting order in the note template list, the role setting of the sorted template is disappeared.

Description

  1. Registered 3 note templates.
  2. Edit a note template. (6: note-template-3) Set the following
    • Templates visibility: "to these roles only"
    • Role: Check on "Manager" and "Developer"
  3. Change the sort position of 6:note-template-3.
  4. After changing the sort position, looking at 6:note-template-3, the role setting is cleared.

Environment

Visual Proof / Screenshot

* Before changing the sort position

ScreenShot 2023-01-13 11 23 02

* Changing the sort position

ScreenShot 2023-01-13 9 55 26

* After changing the sort position

ScreenShot 2023-01-13 11 23 17

Workaround

I think changing these to the following will solve the problem.

diff --git a/app/controllers/note_templates_controller.rb b/app/controllers/note_templates_controller.rb
index 519da96..dc4b513 100644
--- a/app/controllers/note_templates_controller.rb
+++ b/app/controllers/note_templates_controller.rb
@@ -49,7 +49,7 @@ class NoteTemplatesController < ApplicationController
       if template_params.key?(:role_ids)
         template_params[:role_ids]
       else
-        @note_template.note_visible_role_ids
+        @note_template.note_visible_roles.pluck(:role_id)
       end

     save_and_flash(:notice_successful_update, :show)

0.3-stable branch https://github.com/agileware-jp/redmine_issue_templates/blob/e0d1974f46d426fcf80c4544555bc26bf1668233/app/controllers/note_templates_controller.rb#L52

master branch https://github.com/agileware-jp/redmine_issue_templates/blob/7c470025670b50277bfce04b53376415fe406da6/app/controllers/note_templates_controller.rb#L55

zh commented 1 year ago

PR merged to both master and 0.3-stable branches.