Module: Ccls::Helper

Defined in:
lib/ccls_engine/helper.rb

Instance Method Summary collapse

Instance Method Details

#required(text) ⇒ Object Also known as: req

Just a simple method to wrap the passed text in a span with class=‘required’



106
107
108
# File 'lib/ccls_engine/helper.rb', line 106

def required(text)
	"<span class='required'>#{text}</span>"
end

#sort_down_imageObject



7
8
9
# File 'lib/ccls_engine/helper.rb', line 7

def sort_down_image
	"#{Rails.root}/public/images/sort_down.png"
end

&uarr; and &darr;



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ccls_engine/helper.rb', line 12

def sort_link(column,text=nil)
	#	make local copy so mods to muck up real params which
	#	may still be references elsewhere.
	local_params = params.dup

#
#	May want to NOT flip dir for other columns.  Only the current order.
#	Will wait until someone else makes the suggestion.
#
	order = column.to_s.downcase.gsub(/\s+/,'_')
	dir = ( local_params[:dir] && local_params[:dir] == 'asc' ) ? 'desc' : 'asc'

	local_params[:page] = nil
	link_text = text||column
	classes = ['sortable',order]
	arrow = ''
	if local_params[:order] && local_params[:order] == order
		classes.push('sorted')
		arrow = if dir == 'desc'
			if File.exists? sort_down_image
				image_tag( File.basename(sort_down_image), :class => 'down arrow')
			else
				"<span class='down arrow'>&darr;</span>"
			end
		else
			if File.exists? sort_up_image
				image_tag( File.basename(sort_up_image), :class => 'up arrow')
			else
				"<span class='up arrow'>&uarr;</span>"
			end
		end
	end
	s = "<div class='#{classes.join(' ')}'>"
	s << link_to(link_text,local_params.merge(:order => order,:dir => dir))
	s << arrow unless arrow.blank?
	s << "</div>"
	s
end

#sort_up_imageObject



3
4
5
# File 'lib/ccls_engine/helper.rb', line 3

def sort_up_image
	"#{Rails.root}/public/images/sort_up.png"
end

#subject_id_bar(study_subject, &block) ⇒ Object Also known as: study_subject_id_bar

Used to replace the _id_bar partial



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ccls_engine/helper.rb', line 74

def subject_id_bar(study_subject,&block)
	stylesheets('study_subject_id_bar')
	content_for :main do
		"<div id='id_bar'>\n" <<
		"<div class='childid'>\n" <<
		"<span>ChildID:</span>\n" <<
		"<span>#{study_subject.try(:childid)}</span>\n" <<
		"</div><!-- class='childid' -->\n" <<
		"<div class='studyid'>\n" <<
		"<span>StudyID:</span>\n" <<
		"<span>#{study_subject.try(:studyid)}</span>\n" <<
		"</div><!-- class='studyid' -->\n" <<
		"<div class='full_name'>\n" <<
		"<span>#{study_subject.full_name}</span>\n" <<
		"</div><!-- class='full_name' -->\n" <<
		"<div class='controls'>\n" <<
		@content_for_id_bar.to_s <<
		((block_given?)?yield: '') <<
		"</div><!-- class='controls' -->\n" <<
		"</div><!-- id='id_bar' -->\n"
	end

	content_for :main do
		"<div id='do_not_contact'>\n" <<
		"Study Subject requests no further contact with Study.\n" <<
		"</div>\n" 
	end if study_subject.try(:do_not_contact?)
end

#user_rolesObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ccls_engine/helper.rb', line 51

def user_roles
	s = ''
	if current_user.may_administrate?
		s << "<ul>"
		@roles.each do |role|
			s << "<li>"
			if @user.role_names.include?(role.name)
				s << link_to( "Remove user role of '#{role.name}'", 
					user_role_path(@user,role.name),
					:method => :delete )
			else
				s << link_to( "Assign user role of '#{role.name}'", 
					user_role_path(@user,role.name),
					:method => :put )
			end
			s << "</li>\n"
		end
		s << "</ul>\n"
	end
	s
end