Skip to content

Commit bbc1fcd

Browse files
committed
Fix permit issue and binding.pry
Sort text blocks by global => project order
1 parent 2507624 commit bbc1fcd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/controllers/text_blocks_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def index_path
8080
end
8181

8282
def text_block_params
83-
params[:text_block].permit :name, :text, :issue_status_ids, :position
83+
params[:text_block].permit :name, :text, :position, :issue_status_ids => []
8484
end
8585

8686
def find_text_block
@@ -102,6 +102,11 @@ def get_issue_statuses
102102
end
103103

104104
def get_blocks_by_status(status_id)
105-
IssueStatus.find(status_id).text_blocks.blank? ? text_block_scope : IssueStatus.find(status_id).text_blocks.where(project_id: [nil, @project&.id]).sorted
105+
if IssueStatus.find(status_id).text_blocks.blank
106+
text_block_scope
107+
else
108+
IssueStatus.find(status_id).text_blocks.
109+
where(project_id: [nil, @project&.id]).sorted
110+
end
106111
end
107112
end

app/models/text_block.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TextBlock < ActiveRecord::Base
88
validates_numericality_of :position, :only_integer => true
99
before_create :set_position
1010

11-
scope :sorted, ->{ order :position }
11+
scope :sorted, ->{ order('project_id IS NOT NULL, project_id ASC, position ASC') }
1212

1313
private
1414

@@ -29,10 +29,8 @@ def set_position
2929
max = self.class.where(:project_id => project_id).maximum(:position) || 0
3030
self.position = max + 1
3131
else
32-
binding.pry
3332
max = self.class.where(:project_id => nil).maximum(:position) || 0
3433
self.position = max + 1
3534
end
3635
end
37-
3836
end

0 commit comments

Comments
 (0)