@@ -4,9 +4,10 @@ class TextBlocksController < ApplicationController
4
4
self . main_menu = false
5
5
6
6
before_action :find_project_by_project_id
7
+ before_action :get_issue_statuses , except : [ :index , :destroy ]
7
8
8
- before_action :require_admin , if : -> { @project . nil? }
9
- before_action :authorize , if : -> { @project . present? }
9
+ before_action :require_admin , if : -> { @project . nil? } , except : :blocks_by_status
10
+ before_action :authorize , if : -> { @project . present? } , except : :blocks_by_status
10
11
11
12
menu_item :settings , only : [ :new , :create , :edit , :update , :destroy ]
12
13
helper_method :index_path
@@ -50,6 +51,12 @@ def destroy
50
51
redirect_to index_path
51
52
end
52
53
54
+ def blocks_by_status
55
+ @txtblocks = get_blocks_by_status ( params [ :status_id ] )
56
+ respond_to do |format |
57
+ format . json { render json : @txtblocks . to_json }
58
+ end
59
+ end
53
60
54
61
private
55
62
@@ -62,7 +69,7 @@ def index_path
62
69
end
63
70
64
71
def text_block_params
65
- params [ :text_block ] . permit :name , :text
72
+ params [ :text_block ] . permit :name , :text , :issue_status_ids => [ ]
66
73
end
67
74
68
75
def find_text_block
@@ -79,4 +86,11 @@ def text_block_scope
79
86
TextBlock . order ( name : :asc ) . where ( project_id : @project &.id )
80
87
end
81
88
89
+ def get_issue_statuses
90
+ @issue_statuses = IssueStatus . all . sorted
91
+ end
92
+
93
+ def get_blocks_by_status ( status_id )
94
+ IssueStatus . find ( status_id ) . text_blocks . blank? ? text_block_scope : IssueStatus . find ( status_id ) . text_blocks . where ( project_id : [ nil , @project &.id ] )
95
+ end
82
96
end
0 commit comments