Module: ClientEngine::ClientsHelper

Defined in:
app/helpers/client_engine/clients_helper.rb

Instance Method Summary collapse

Instance Method Details

#column_div_formObject



69
70
71
72
73
# File 'app/helpers/client_engine/clients_helper.rb', line 69

def column_div_form
	 :div, class: 'col-xs-12 col-sm-8 col-md-8' do
		concat(form)
	end
end


75
76
77
78
79
# File 'app/helpers/client_engine/clients_helper.rb', line 75

def column_div_link
	 :div, class:'col-xs-12 col-sm-4 col-md-4', style: 'text-align: right;' do
		concat(link)
	end
end

#correo(client) ⇒ Object

BEGIN ERROR EXPLANATION ######



172
173
174
# File 'app/helpers/client_engine/clients_helper.rb', line 172

def correo(client)
	link_to client.email , "mailto:"+client.email, target:"_top"
end

#error_explanation(object) ⇒ Object

BEGIN ERROR EXPLANATION ###



138
139
140
141
142
143
144
145
# File 'app/helpers/client_engine/clients_helper.rb', line 138

def error_explanation object
	@object = object
	if not object.nil?
		 :div do
			concat(errors_flash)
		end
	end
end

#error_explanation_loopObject



157
158
159
160
161
162
163
# File 'app/helpers/client_engine/clients_helper.rb', line 157

def error_explanation_loop
	 :ul do
       	@object.errors.full_messages.each do |message|
        	concat(li_message(message))
        end
    end
end

#errors_flashObject



147
148
149
150
151
152
153
154
# File 'app/helpers/client_engine/clients_helper.rb', line 147

def errors_flash
	if @object.errors.any?
		 :div, class: "alert alert-danger", role:"alert" do
			concat("<strong>Se produjeron los siguientes errores:</strong>".html_safe)
	      	concat(error_explanation_loop)
		end
	end
end

#formObject



81
82
83
84
85
86
87
# File 'app/helpers/client_engine/clients_helper.rb', line 81

def form
	form_tag @path, :method => 'get', :id => "search_form", remote: true do
	  	 :div, class:' form-inline' do
	  		concat( input_groups)
	  	end
	end
end

#input_group_addonObject



105
106
107
108
109
# File 'app/helpers/client_engine/clients_helper.rb', line 105

def input_group_addon
	 :div, class: 'input-group-addon' do
	  	concat( :span,'', class:'glyphicon glyphicon-search', aria:{hidden:'true'})
	end
end

#input_groupsObject



97
98
99
100
101
102
103
# File 'app/helpers/client_engine/clients_helper.rb', line 97

def input_groups
	 :div, class:'input-group' do
	  	concat( :div, 'Buscar', class:'input-group-addon')
	  	concat(text_field_tag :search, params[:search], class: 'form-control', size: 50, onkeyup: 'remoteSubmit("#search_form");', autofocus: true )
	  	concat(input_group_addon)
	end
end

#javascript_paginate_helperObject



132
133
134
# File 'app/helpers/client_engine/clients_helper.rb', line 132

def javascript_paginate_helper
	javascript_tag("$('ul.pagination a').click(function(){$.getScript(this.href); return false; });")
end

#li_message(message) ⇒ Object



165
166
167
168
169
# File 'app/helpers/client_engine/clients_helper.rb', line 165

def li_message message
	 :li do
   		"#{message}"
 		end
end


89
90
91
92
93
94
95
# File 'app/helpers/client_engine/clients_helper.rb', line 89

def link
	if !@link_path.nil? && @modal_id.nil?
		link_to "#{fa_icon('plus')} #{@link_text}".html_safe, @link_path, class:'btn btn-primary full-btn margin-btn'
	elsif !@link_path.nil? && !@modal_id.nil?
		link_to "#{fa_icon('plus')} #{@link_text}".html_safe, @link_path, class:'btn btn-primary full-btn margin-btn', remote: true, "data-toggle" => "modal", "data-target" => @modal_id
	end
end

#paginate(resource, options = nil) ⇒ Object

BEGIN PAGINATE ####



114
115
116
117
118
119
120
121
122
# File 'app/helpers/client_engine/clients_helper.rb', line 114

def paginate resource, options = nil
	if not options
		@resource = resource
		 :div, style: 'text-align: center;' do
			concat(will_paginate_helper)
			concat(javascript_paginate_helper)
		end
	end
end

#rowObject



62
63
64
65
66
67
# File 'app/helpers/client_engine/clients_helper.rb', line 62

def row
	 :div, class: 'row' do
		concat(column_div_form)
		concat(column_div_link)
	end
end

#search_form_client(path, link_text, link_path) ⇒ Object

BEGIN SEARCH FORM CLIENTE ###



52
53
54
55
56
57
58
59
60
# File 'app/helpers/client_engine/clients_helper.rb', line 52

def search_form_client path, link_text, link_path
	@path = path
	@link_text = link_text
	@link_path = link_path

	 :div, id:'buscador' do
		concat(row)
	end
end

#sortable(column, class_name, title = nil) ⇒ Object

BEGIN SORTABLE ###



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/client_engine/clients_helper.rb', line 5

def sortable(column,class_name, title = nil)
  	title ||= column.titleize
  	if column.split(".").count >= 2
	  	css_class = (
	  		(column.split(".").last.to_s == sort_column(class_name).split(".").last.to_s) &&
	  		(column.split(".").last(2).first.pluralize.to_s == sort_column(class_name).split(".").last(2).first.pluralize.to_s)
	  		) ? "#{sort_direction}" : nil
	  	css_class = css_class == "asc" ? "long-arrow-down" : (css_class == "desc" ? "long-arrow-up" : nil)
	else
  		css_class = column.split(".").last.to_s == sort_column(class_name).split(".").last.to_s ? "#{sort_direction}" : nil
  		css_class = css_class == "asc" ? "long-arrow-down" : (css_class == "desc" ? "long-arrow-up" : nil)
  	end
  	column.split(".").to_s
  	sort_column(class_name).split(".").to_s
  	css_class

  	direction = (column.split(".").last.to_s == sort_column(class_name).split(".").last.to_s && sort_direction == "asc") ? "desc" : "asc"
  	link_to "#{fa_icon(css_class)} #{title}".html_safe, {sort: column, direction: direction, search: params[:search]}, {remote: true}
end

#titleObject



43
44
45
46
47
48
# File 'app/helpers/client_engine/clients_helper.rb', line 43

def title
	 :h1 do
		concat(fa_icon(@icono))
		concat(" " + @texto)
	end
end

#title_rowObject



37
38
39
40
41
# File 'app/helpers/client_engine/clients_helper.rb', line 37

def title_row
	 :div,class:'col-xs-10 col-sm-11 col-md-11' do
		concat(title)
	end
end

#titulo(icono, texto) ⇒ Object

BEGIN HELPER TITULO ###



27
28
29
30
31
32
33
34
35
# File 'app/helpers/client_engine/clients_helper.rb', line 27

def titulo icono,texto
	@icono = icono
	@texto = texto
	content_for :title do
		 :div, class: :row do
			concat(title_row)
		end
	end
end

#will_paginate_helperObject



123
124
125
126
127
128
129
130
# File 'app/helpers/client_engine/clients_helper.rb', line 123

def will_paginate_helper
	will_paginate @resource, :page_links => true,
	 							 :inner_window => 1,
	  							 :outer_window => 1,
	   							 :previous_label => '← Anterior',
	    						 :next_label => 'Siguiente →',
	     						 renderer: BootstrapPagination::Rails
end