flexa_lib 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/flexa_lib.gemspec +1 -1
- data/lib/flexa_lib/model_extensions.rb +35 -0
- data/lib/flexa_lib.rb +9 -1
- data/vendor/assets/stylesheets/flexa-theme.css.scss +9 -0
- metadata +5 -4
data/flexa_lib.gemspec
CHANGED
@@ -0,0 +1,35 @@
|
|
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.busca(params[:nome_da_sua_busca],params[:page],['campo1','campo2','campo3'])
|
14
|
+
#
|
15
|
+
def busca(parametro,pagina,campos)
|
16
|
+
tem_busca = parametro
|
17
|
+
tem_busca = tem_busca.to_a
|
18
|
+
|
19
|
+
colunas_like = campos.dup
|
20
|
+
colunas_param = campos.dup
|
21
|
+
colunas_like.collect! {|x| "(UPPER("+x+") LIKE UPPER(:search))"}
|
22
|
+
|
23
|
+
if tem_busca.length > 0
|
24
|
+
self.paginate(:page => pagina, :conditions=>[colunas_like.join(' OR '),{:search => "%"+parametro.to_s+"%"}])
|
25
|
+
else
|
26
|
+
self.paginate(:page => pagina)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end #fim do modulo PesquisaWrapper
|
31
|
+
|
32
|
+
# adicionar ao ActiveRecord
|
33
|
+
::ActiveRecord::Base.extend PesquisaWrapper
|
34
|
+
end
|
35
|
+
end
|
data/lib/flexa_lib.rb
CHANGED
@@ -77,17 +77,25 @@ require 'flexa_lib/helpers'
|
|
77
77
|
module ActionView
|
78
78
|
class Base
|
79
79
|
include FlexaLib::Helpers
|
80
|
-
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
83
|
|
84
|
+
|
85
|
+
#Extensoes para ActiveRecord
|
86
|
+
require 'active_support'
|
87
|
+
ActiveSupport.on_load :active_record do
|
88
|
+
require 'flexa_lib/model_extensions'
|
89
|
+
end
|
90
|
+
|
85
91
|
####################################
|
86
92
|
#### Definir o flexa_formtastic_bootstrap
|
87
93
|
#### como FormBuilder Padrão
|
88
94
|
###################################
|
89
95
|
Formtastic::Helpers::FormHelper.builder = FlexaFormtasticBootstrap::FormBuilder
|
90
96
|
|
97
|
+
##### Definir quantidade de registros por Página em Paginação ####
|
98
|
+
WillPaginate.per_page = 25
|
91
99
|
|
92
100
|
#validacoes de CPF e CNPJ
|
93
101
|
require 'flexa_lib/brcpfcnpj'
|
@@ -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: "glyphicons-halflings.png";
|
42
|
+
}
|
43
|
+
.icon-white {
|
44
|
+
background-image: "glyphicons-halflings-white.png";
|
36
45
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexa_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Allan Freitas
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-03-
|
19
|
+
date: 2012-03-21 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: formtastic
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- vendor/assets/images/glyphicons-halflings-white.png
|
151
151
|
- lib/action_view/helpers/text_field_date_helper.rb
|
152
152
|
- lib/flexa_lib/inputs.rb
|
153
|
+
- lib/flexa_lib/model_extensions.rb
|
153
154
|
- lib/flexa_lib/brcpfcnpj.rb
|
154
155
|
- lib/flexa_lib/engine.rb
|
155
156
|
- lib/flexa_lib/brcpfcnpj/cpf_cnpj.rb
|