flexa_lib 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/flexa_lib.gemspec +2 -2
- data/lib/flexa_lib/helpers/other_helpers.rb +23 -0
- data/lib/flexa_lib/inputs/boolean_input.rb +1 -1
- data/lib/flexa_lib/model_extensions.rb +39 -0
- data/lib/generators/flexa_lib/crud/templates/view_edit.html.erb +1 -1
- data/lib/generators/flexa_lib/crud/templates/view_new.html.erb +1 -1
- data/lib/generators/flexa_lib/crud/templates/view_print.html.erb +1 -1
- data/lib/generators/flexa_lib/crud/templates/view_show.html.erb +1 -1
- data/lib/generators/flexa_lib/crud/templates/view_tables.html.erb +4 -4
- data/lib/generators/flexa_lib/lookup/templates/lookup_controller.rb +1 -1
- data/lib/generators/rails/scaffold_controller/templates/controller.rb +111 -0
- data/vendor/assets/stylesheets/flexa-theme.css.scss +9 -0
- metadata +3 -1
data/flexa_lib.gemspec
CHANGED
@@ -7,7 +7,7 @@ require 'flexa_lib/version'
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = 'flexa_lib'
|
9
9
|
# s.version = FlexaLib::VERSION
|
10
|
-
s.version = '0.
|
10
|
+
s.version = '0.3.0'
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
12
|
|
13
13
|
s.authors = ['Allan Freitas','Marcio Sfalsin']
|
@@ -38,4 +38,4 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.add_dependency 'will_paginate', '>=3.0.2'
|
39
39
|
s.add_dependency 'will_paginate_twitter_bootstrap', '>=1.0.0'
|
40
40
|
|
41
|
-
end
|
41
|
+
end
|
@@ -60,6 +60,29 @@ module FlexaLib
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
# flexa_form_horizontal
|
64
|
+
#
|
65
|
+
# vai gerar uma DIV para aplicar FLOAT:LEFT nos inputs do formulário
|
66
|
+
# <%=flexa_form_horizontal do%>
|
67
|
+
# conteudo vai aqui
|
68
|
+
# <%end%>
|
69
|
+
#
|
70
|
+
def flexa_form_horizontal(&block)
|
71
|
+
content_tag :div, :class=>"form_horizontal" do
|
72
|
+
block.call
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def flexa_boolean_grid(status)
|
78
|
+
if status
|
79
|
+
imagem = 'icon_sucess.gif'
|
80
|
+
else
|
81
|
+
imagem = 'icon_error.gif'
|
82
|
+
end
|
83
|
+
image_tag(imagem)
|
84
|
+
end
|
85
|
+
|
63
86
|
|
64
87
|
end
|
65
88
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
module FlexaLib
|
4
|
+
module ActiveRecord
|
5
|
+
module PesquisaWrapper
|
6
|
+
|
7
|
+
#
|
8
|
+
# metodo BUSCA
|
9
|
+
#
|
10
|
+
# parametro = nome da variavel vinda como parametro para busca
|
11
|
+
# pagina = variavel que vem do "params" geralmente params[:page]
|
12
|
+
# campos = array de CAMPOS a serem pesquisados
|
13
|
+
# Model.flexa_search(:search => {:text => params[:search],
|
14
|
+
# :fields => ['nome','cod_cidade']}, :page => params[:page])
|
15
|
+
#
|
16
|
+
def flexa_search(options)
|
17
|
+
options = options.dup
|
18
|
+
|
19
|
+
search_options = options.fetch(:search) { raise ArgumentError, ":search is required" }
|
20
|
+
likes_search = search_options.fetch(:fields) { raise ArgumentError, ":fields is required" }
|
21
|
+
text_search = search_options.fetch(:text) { raise ArgumentError, ":text is required" }
|
22
|
+
|
23
|
+
options.delete(:search)
|
24
|
+
|
25
|
+
if text_search.length > 0 and likes_search.count > 0
|
26
|
+
|
27
|
+
likes_search.collect! {|x| "(UPPER("+x+") LIKE UPPER(:search))"}
|
28
|
+
paginate(options).where(likes_search.join(' OR '), :search => "%"+text_search.to_s+"%")
|
29
|
+
else
|
30
|
+
paginate(options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end #fim do modulo PesquisaWrapper
|
35
|
+
|
36
|
+
# adicionar ao ActiveRecord
|
37
|
+
::ActiveRecord::Base.extend PesquisaWrapper
|
38
|
+
end
|
39
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%%= render :partial=>'form', :locals=>{:f=>f} %>
|
6
6
|
|
7
|
-
<%%= flexa_fixed_toolbar "<%= plural_model_name %>", <%= plural_resource_name %>_path do %>
|
7
|
+
<%%= flexa_fixed_toolbar "<%= plural_model_name.humanize %>", <%= plural_resource_name %>_path do %>
|
8
8
|
<%%= flexa_submit_button %>
|
9
9
|
<%%= flexa_cancel_button_to @<%= resource_name %> %>
|
10
10
|
<%%= flexa_delete_button_to @<%= resource_name %> %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<%%= render :partial=>'form', :locals=>{:f=>f} %>
|
6
6
|
|
7
|
-
<%%= flexa_fixed_toolbar "<%= plural_model_name %>", <%= plural_resource_name %>_path do %>
|
7
|
+
<%%= flexa_fixed_toolbar "<%= plural_model_name.humanize %>", <%= plural_resource_name %>_path do %>
|
8
8
|
<%%= flexa_submit_button %>
|
9
9
|
<%%= flexa_cancel_button_to @<%= resource_name %> %>
|
10
10
|
<%%end%>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<%%= render :partial=>'form', :locals=>{:f=>f} %>
|
7
7
|
|
8
|
-
<%%= flexa_fixed_toolbar "<%= plural_model_name %>", <%= plural_resource_name %>_path do %>
|
8
|
+
<%%= flexa_fixed_toolbar "<%= plural_model_name.humanize %>", <%= plural_resource_name %>_path do %>
|
9
9
|
<%%= flexa_submit_button "Imprimir" %>
|
10
10
|
<%%= flexa_cancel_button_to @<%= resource_name %> %>
|
11
11
|
<%%end%>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
<%%= render :partial=>'form', :locals=>{:f=>f} %>
|
8
8
|
|
9
|
-
<%%= flexa_fixed_toolbar "<%= plural_model_name %>", <%= plural_resource_name %>_path do %>
|
9
|
+
<%%= flexa_fixed_toolbar "<%= plural_model_name.humanize %>", <%= plural_resource_name %>_path do %>
|
10
10
|
<%%= flexa_cancel_button_to @<%= resource_name %> %>
|
11
11
|
<%%= flexa_edit_button_to @<%= resource_name %> %>
|
12
12
|
<%%= flexa_delete_button_to @<%= resource_name %> %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<%%= flexa_table_for @<%= plural_resource_name %> do -%>
|
2
2
|
<% columns.each do |col| -%>
|
3
|
-
<%% column :<%=col.name%>, :title=>"<%=col.name.
|
3
|
+
<%% column :<%=col.name%>, :title=>"<%=col.name.humanize%>" %>
|
4
4
|
<% end %>
|
5
5
|
<%% end -%>
|
6
6
|
|
7
|
-
<%%= flexa_fixed_toolbar "<%= plural_model_name %>", <%= plural_resource_name %>_path do %>
|
8
|
-
<%%= flexa_add_button_to <%= resource_name.
|
9
|
-
<%%= flexa_search_tool <%= resource_name.
|
7
|
+
<%%= flexa_fixed_toolbar "<%= plural_model_name.humanize %>", <%= plural_resource_name %>_path do %>
|
8
|
+
<%%= flexa_add_button_to <%= resource_name.camelcase %> %>
|
9
|
+
<%%= flexa_search_tool <%= resource_name.camelcase %> %>
|
10
10
|
<%%= flexa_will_paginate @<%= plural_resource_name %> %>
|
11
11
|
<%% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Lookups::<%=
|
1
|
+
class Lookups::<%=class_name.pluralize %>Controller < ApplicationController
|
2
2
|
#created by <%=ENV['SUDO_USER']||ENV['USERNAME']%> at <%=Time.now.strftime('%d/%m/%Y %H:%M')%>
|
3
3
|
|
4
4
|
# GET <%= route_url %>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
<%
|
3
|
+
model_nome = class_name.split('::')
|
4
|
+
|
5
|
+
if model_nome.count > 1
|
6
|
+
|
7
|
+
ptbl_nome = plural_table_name.split('_')
|
8
|
+
tbl_nome = singular_table_name.split('_')
|
9
|
+
#
|
10
|
+
model_nome.shift
|
11
|
+
|
12
|
+
#model_nome
|
13
|
+
#
|
14
|
+
ptbl_nome.shift
|
15
|
+
ptbl_nome = ptbl_nome.join('_')
|
16
|
+
#
|
17
|
+
tbl_nome.shift
|
18
|
+
tbl_nome = tbl_nome.join('_')
|
19
|
+
|
20
|
+
else
|
21
|
+
model_nome = class_name
|
22
|
+
ptbl_nome = plural_table_name
|
23
|
+
tbl_nome = singular_table_name
|
24
|
+
end
|
25
|
+
%>
|
26
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
27
|
+
# GET <%= route_url %>
|
28
|
+
# GET <%= route_url %>.json
|
29
|
+
def index
|
30
|
+
#MODEL.busca(string_para_busca,pagina_atual,['campo1','campo2])
|
31
|
+
@<%= ptbl_nome %> = <%= tbl_nome.camelcase %>.busca(params[:search],params[:page],['id'])
|
32
|
+
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.html # index.html.erb
|
36
|
+
format.json { render json: <%= "@#{ptbl_nome}" %> }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET <%= route_url %>/1
|
41
|
+
# GET <%= route_url %>/1.json
|
42
|
+
def show
|
43
|
+
@<%= tbl_nome %> = <%= orm_class.find(model_nome, "params[:id]") %>
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
format.html # show.html.erb
|
47
|
+
format.json { render json: <%= "@#{tbl_nome}" %> }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# GET <%= route_url %>/new
|
52
|
+
# GET <%= route_url %>/new.json
|
53
|
+
def new
|
54
|
+
@<%= tbl_nome %> = <%= orm_class.build(model_nome) %>
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html # new.html.erb
|
58
|
+
format.json { render json: <%= "@#{tbl_nome}" %> }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# GET <%= route_url %>/1/edit
|
63
|
+
def edit
|
64
|
+
@<%= tbl_nome %> = <%= orm_class.find(model_nome, "params[:id]") %>
|
65
|
+
end
|
66
|
+
|
67
|
+
# POST <%= route_url %>
|
68
|
+
# POST <%= route_url %>.json
|
69
|
+
def create
|
70
|
+
@<%= tbl_nome %> = <%= orm_class.build(model_nome, "params[:#{tbl_nome}]") %>
|
71
|
+
|
72
|
+
respond_to do |format|
|
73
|
+
if @<%= orm_instance.save %>
|
74
|
+
format.html { redirect_to @<%= tbl_nome %>, notice: <%= "'#{human_name} was successfully created.'" %> }
|
75
|
+
format.json { render json: <%= "@#{tbl_nome}" %>, status: :created, location: <%= "@#{tbl_nome}" %> }
|
76
|
+
else
|
77
|
+
format.html { render action: "new" }
|
78
|
+
format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# PATCH/PUT <%= route_url %>/1
|
84
|
+
# PATCH/PUT <%= route_url %>/1.json
|
85
|
+
def update
|
86
|
+
@<%= tbl_nome %> = <%= orm_class.find(model_nome, "params[:id]") %>
|
87
|
+
|
88
|
+
respond_to do |format|
|
89
|
+
if @<%= tbl_nome.update_attributes("params[:#{tbl_nome}]") %>
|
90
|
+
format.html { redirect_to @<%= tbl_nome %>, notice: <%= "'#{human_name} was successfully updated.'" %> }
|
91
|
+
format.json { head :no_content }
|
92
|
+
else
|
93
|
+
format.html { render action: "edit" }
|
94
|
+
format.json { render json: <%= "@#{tbl_nome.errors}" %>, status: :unprocessable_entity }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# DELETE <%= route_url %>/1
|
100
|
+
# DELETE <%= route_url %>/1.json
|
101
|
+
def destroy
|
102
|
+
@<%= tbl_nome %> = <%= orm_class.find(model_nome, "params[:id]") %>
|
103
|
+
@<%= tbl_nome.destroy %>
|
104
|
+
|
105
|
+
respond_to do |format|
|
106
|
+
format.html { redirect_to <%= index_helper %>_url }
|
107
|
+
format.json { head :no_content }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
<% end -%>
|
@@ -33,4 +33,13 @@
|
|
33
33
|
//CSS para FormtasticBootstrap
|
34
34
|
.hidden {
|
35
35
|
display: none;
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
//OVERRIDE
|
40
|
+
[class^="icon-"], [class*=" icon-"] {
|
41
|
+
background-image: url("glyphicons-halflings.png");
|
42
|
+
}
|
43
|
+
.icon-white {
|
44
|
+
background-image: url("glyphicons-halflings-white.png");
|
36
45
|
}
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: flexa_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Allan Freitas
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/flexa_formtastic_bootstrap/helpers/buttons_helper.rb
|
164
164
|
- lib/flexa_formtastic_bootstrap/helpers/fieldset_wrapper.rb
|
165
165
|
- lib/action_view/helpers/text_field_date_helper.rb
|
166
|
+
- lib/generators/rails/scaffold_controller/templates/controller.rb
|
166
167
|
- lib/generators/flexa_lib/crud/crud_generator.rb
|
167
168
|
- lib/generators/flexa_lib/lookup/lookup_generator.rb
|
168
169
|
- lib/generators/flexa_lib/lookup/lookup_generator_test.rb
|
@@ -170,6 +171,7 @@ files:
|
|
170
171
|
- lib/flexa_lib/engine.rb
|
171
172
|
- lib/flexa_lib/brcpfcnpj.rb
|
172
173
|
- lib/flexa_lib/helpers.rb
|
174
|
+
- lib/flexa_lib/model_extensions.rb
|
173
175
|
- lib/flexa_lib/version.rb
|
174
176
|
- lib/flexa_lib/inputs.rb
|
175
177
|
- lib/flexa_lib/inputs/date_picker_input.rb
|