Closed yui-har closed 2 years ago
When I checked it with rails console, it seems that it is not a sorting problem but a validation defect.
[2] pry(main)> note = NoteTemplate.find 1
NoteTemplate Load (1.1ms) SELECT "note_templates".* FROM "note_templates" WHERE "note_templates"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
=> #<NoteTemplate:0x00007fa99b668680
id: 1,
name: "comment 1:Repo",
description: "comment-1\r\ncomment-2\r\ncomment-3\r\n",
memo: "",
project_id: 7,
tracker_id: 1,
author_id: 1,
enabled: true,
position: 1,
created_at: Tue, 05 Apr 2022 07:30:59 UTC +00:00,
updated_at: Mon, 18 Apr 2022 05:25:14 UTC +00:00,
visibility: "roles">
[3] pry(main)> note.position = 2
=> 2
[4] pry(main)> note.valid?
NoteTemplate Exists (0.1ms) SELECT 1 AS one FROM "note_templates" WHERE "note_templates"."name" = ? AND "note_templates"."id" != ? AND "note_templates"."project_id" = ? LIMIT ? [["name", "comment 1:Repo"], ["id", 1], ["project_id", 7], ["LIMIT", 1]]
Tracker Load (0.5ms) SELECT "trackers".* FROM "trackers" WHERE "trackers"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
=> false
[5] pry(main)> note.errors
=> #<ActiveModel::Errors:0x00007fa99b5b39d8
@base=
#<NoteTemplate:0x00007fa99b668680
id: 1,
name: "comment 1:Repo",
description: "comment-1\r\ncomment-2\r\ncomment-3\r\n",
memo: "",
project_id: 7,
tracker_id: 1,
author_id: 1,
enabled: true,
position: 2,
created_at: Tue, 05 Apr 2022 07:30:59 UTC +00:00,
updated_at: Mon, 18 Apr 2022 05:25:14 UTC +00:00,
visibility: "roles">,
@details={:role_ids=>[{:error=>:blank}]},
@messages={:role_ids=>["cannot be blank"]}>
[6] pry(main)>
@kyamada23 @nishidayuya Thank you for reviewing and merging #25 and #26. If the problem is resolved, please close this issue.
Summary
When you have edit_issue_templates permission, you can sort the templates for note. However, it cannot be sorted at present.
Description
When I confirmed the development log, I couldn't update the data and it was rolling back.
Environment