flexa_lib 0.3.9 → 0.5.0
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/README.txt +68 -1
- data/flexa_lib.gemspec +3 -2
- data/lib/flexa_formtastic_bootstrap/inputs/lookup_input.rb +16 -7
- data/lib/flexa_lib/date_extensions.rb +1 -1
- data/lib/flexa_lib/helpers/other_helpers.rb +3 -0
- data/lib/flexa_lib/helpers/tab_helpers.rb +0 -2
- data/lib/flexa_lib/model_extensions.rb +72 -2
- data/lib/flexa_lib/table_for_boolean_column.rb +52 -0
- data/lib/flexa_lib.rb +9 -1
- data/lib/generators/flexa_lib/assets/assets_generator.rb +21 -0
- data/lib/generators/flexa_lib/crud/crud_generator.rb +31 -3
- data/lib/generators/flexa_lib/crud/templates/controller.rb +109 -0
- data/lib/generators/flexa_lib/lookup/templates/lookup_controller.rb +5 -5
- data/vendor/assets/stylesheets/flexa-theme.css.scss +5 -0
- metadata +32 -13
data/README.txt
CHANGED
@@ -15,4 +15,71 @@ Deixar dessa forma:
|
|
15
15
|
*= require flexa-theme
|
16
16
|
*/
|
17
17
|
|
18
|
-
##
|
18
|
+
##
|
19
|
+
|
20
|
+
##### GERAR um CRUD completo com MODEL #####
|
21
|
+
1 - Gerar o model normalmente
|
22
|
+
rails g model Fluxo nome:string
|
23
|
+
|
24
|
+
2 - Gerar a estrutura:
|
25
|
+
- Controller + Views
|
26
|
+
rails g flexa_lib:crud Fluxos
|
27
|
+
- Controller
|
28
|
+
rails g flexa_lib:crud Fluxos --no_views
|
29
|
+
- Views
|
30
|
+
rails g flexa_lib:crud Fluxos --no_controller
|
31
|
+
|
32
|
+
|
33
|
+
##### GERAR OS ASSETS NECESSARIOS #####
|
34
|
+
rails g flexa_lib:assets
|
35
|
+
-substitui o "application.css" e o "application.js"
|
36
|
+
|
37
|
+
##### GERAR LAYOUTS ########
|
38
|
+
- Layout Padrão
|
39
|
+
rails g flexa_lib:layout
|
40
|
+
|
41
|
+
- Sem FRAMESET
|
42
|
+
rails g flexa_lib:layout --no_frame
|
43
|
+
|
44
|
+
|
45
|
+
################## HELPERS #################
|
46
|
+
====== Helpers de Formulário =========
|
47
|
+
# flexa_form_horizontal
|
48
|
+
#
|
49
|
+
# vai gerar uma DIV para aplicar FLOAT:LEFT nos inputs do formulário
|
50
|
+
# <%=flexa_form_horizontal do%>
|
51
|
+
# conteudo vai aqui
|
52
|
+
# <%end%>
|
53
|
+
|
54
|
+
====== Helper da Tabela ========
|
55
|
+
Ao usar um campo "boolean" na listagem use
|
56
|
+
<% boolean_column :nome_do_campo, :title=>"Nome do Campo" %>
|
57
|
+
em vez de
|
58
|
+
<% column :nome_do_campo, :title=>"Nome do Campo" %>
|
59
|
+
|
60
|
+
########## LOOKUPS ##############
|
61
|
+
Versão 0.5.0 da gem pra cima
|
62
|
+
|
63
|
+
- no model que usará o INPUT deve ser usado
|
64
|
+
"delegate_lookup" com os mesmos parametros do delegate comum
|
65
|
+
Ex.:
|
66
|
+
# delegate_lookup :nome, :to => :pais
|
67
|
+
obs.: Não é mais necessário o código abaixo, pois a função delegate_lookup já se encarrega disso
|
68
|
+
# def pais_nome=(val)
|
69
|
+
# false
|
70
|
+
# end
|
71
|
+
|
72
|
+
- no model QueVamosUsarOCampo devemos colocar
|
73
|
+
# alias_attribute :pais_id, :id
|
74
|
+
# alias_attribute :pais_nome, :nome
|
75
|
+
|
76
|
+
- O Input do formulário(para uso com o "Formtastic extendido pela Flexa")
|
77
|
+
# <%= f.input :pais_id, :as=>:lookup, :lookup=>{:display=>:pais_nome, :route=>lookups_paises_path},
|
78
|
+
# :input_html => { :readonly => @readonly, :disabled=>@readonly } %>
|
79
|
+
|
80
|
+
Vamos gerar o Lookup
|
81
|
+
# rails g flexa_lib:lookup Model campo_pesquisa1 campo_pesquisa2
|
82
|
+
|
83
|
+
|
84
|
+
########## PARA ESTUDO ############
|
85
|
+
Rails::Generators.invoke("model", ["Example", "title:string", "--skip"])
|
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.5.0'
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
12
|
|
13
13
|
s.authors = ['Allan Freitas','Marcio Sfalsin']
|
@@ -33,9 +33,10 @@ Gem::Specification.new do |s|
|
|
33
33
|
#s.add_development_dependency("rails", ">= 3.1")
|
34
34
|
#s.add_development_dependency("devise", ">= 1.5.3")
|
35
35
|
#s.add_dependency 'thor', '~> 0.14'
|
36
|
+
s.add_dependency 'sass-rails', '>=3.2.3'
|
36
37
|
s.add_dependency 'formtastic', '>=2.0.2'
|
37
38
|
s.add_dependency 'table_for_collection', '>=1.0.6'
|
38
39
|
s.add_dependency 'will_paginate', '>=3.0.2'
|
39
40
|
s.add_dependency 'will_paginate_twitter_bootstrap', '>=1.0.0'
|
40
41
|
|
41
|
-
end
|
42
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module FlexaFormtasticBootstrap
|
2
2
|
module Inputs
|
3
|
-
class LookupInput < FlexaFormtasticBootstrap::Inputs::StringInput
|
4
|
-
|
3
|
+
#class LookupInput < FlexaFormtasticBootstrap::Inputs::StringInput
|
4
|
+
class LookupInput < Formtastic::Inputs::StringInput
|
5
|
+
include Base
|
6
|
+
include Base::Stringish
|
7
|
+
|
5
8
|
def to_html
|
6
9
|
lookup_feedback_fields = Array.new
|
7
10
|
lookup_feedback_fields<<method
|
@@ -12,15 +15,21 @@ module FlexaFormtasticBootstrap
|
|
12
15
|
generic_input_wrapping do
|
13
16
|
ihtml_display = input_html_options
|
14
17
|
ihtml_display[:readonly]=true
|
18
|
+
if !input_html_options[:readonly]
|
19
|
+
ihtml_display[:class] = "readonly"
|
20
|
+
end
|
15
21
|
ihtml_display[:style]="background-color: white;border: 1px solid #CCC;" if !input_html_options[:readonly]
|
16
22
|
ihtml_display[:id]=options[:lookup][:display]
|
17
|
-
str = builder.text_field(options[:lookup][:display], ihtml_display)
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
str = builder.text_field(options[:lookup][:display], ihtml_display)
|
24
|
+
|
25
|
+
if !input_html_options[:readonly]
|
26
|
+
str = str << template.link_to(template.content_tag("i", "",:class=>"icon-search icon-white"),"#"+'div_'+method.to_s,
|
27
|
+
{:target=>"_blank",:class=>"btn btn-info btnlookup","data-toggle"=>"modal"})<<
|
28
|
+
builder.hidden_field(method, {:id=>method})
|
21
29
|
iframe = template.content_tag(:iframe,"",:src=>lookup_url,:marginheight=>0,:height=>"350",:width=>"100%",:frameborder=>"0")
|
22
30
|
str << template.content_tag(:div,iframe,:id=>'div_'+method.to_s,:class=>"modal hide fade",:style=>"display: none; ")
|
23
|
-
|
31
|
+
end
|
32
|
+
|
24
33
|
#se for usar sem o Bootstrap voltar para a linha abaixo
|
25
34
|
#label_html << template.content_tag(:div,str,:style=>"margin:0;padding:0;display:inline")
|
26
35
|
template.content_tag(:div,str,:style=>"margin:0;padding:0;display:inline")
|
@@ -10,7 +10,7 @@ class Date
|
|
10
10
|
end
|
11
11
|
|
12
12
|
if date =~ %r{^(\d+)/(\d+)/(\d+)$}
|
13
|
-
_parse_without_us_format("#{$3.length == 2 ? "20#{$3}" : $3}-#{$
|
13
|
+
_parse_without_us_format("#{$3.length == 2 ? "20#{$3}" : $3}-#{$2}-#{$1}", *args)
|
14
14
|
else
|
15
15
|
_parse_without_us_format(date, *args)
|
16
16
|
end
|
@@ -31,8 +31,78 @@ module FlexaLib
|
|
31
31
|
end
|
32
32
|
|
33
33
|
end #fim do modulo PesquisaWrapper
|
34
|
-
|
34
|
+
|
35
|
+
module Lookup
|
36
|
+
def delegate_lookup(*methods)
|
37
|
+
options = methods.pop
|
38
|
+
unless options.is_a?(Hash) && to = options[:to]
|
39
|
+
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
|
40
|
+
end
|
41
|
+
|
42
|
+
to = to.to_s
|
43
|
+
prefix, allow_nil = options.values_at(:prefix, :allow_nil)
|
44
|
+
|
45
|
+
prefix = true if prefix.nil?
|
46
|
+
allow_nil = true if allow_nil.nil?
|
47
|
+
|
48
|
+
|
49
|
+
if prefix == true && to =~ /^[^a-z_]/
|
50
|
+
raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
|
51
|
+
end
|
52
|
+
|
53
|
+
method_prefix =
|
54
|
+
if prefix
|
55
|
+
"#{prefix == true ? to : prefix}_"
|
56
|
+
else
|
57
|
+
''
|
58
|
+
end
|
59
|
+
|
60
|
+
file, line = caller.first.split(':', 2)
|
61
|
+
line = line.to_i
|
62
|
+
|
63
|
+
methods.each do |method|
|
64
|
+
method = method.to_s
|
65
|
+
|
66
|
+
# Attribute writer methods only accept one argument. Makes sure []=
|
67
|
+
# methods still accept two arguments.
|
68
|
+
definition = (method =~ /[^\]]=$/) ? "arg" : "*args, &block"
|
69
|
+
|
70
|
+
if allow_nil
|
71
|
+
module_eval(<<-EOS, file, line - 2)
|
72
|
+
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
|
73
|
+
if #{to} || #{to}.respond_to?(:#{method}) # if client || client.respond_to?(:name)
|
74
|
+
#{to}.#{method}(#{definition}) # client.name(*args, &block)
|
75
|
+
end # end
|
76
|
+
end # end
|
77
|
+
EOS
|
78
|
+
else
|
79
|
+
exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
|
80
|
+
|
81
|
+
module_eval(<<-EOS, file, line - 1)
|
82
|
+
def #{method_prefix}#{method}(#{definition}) # def customer_name(*args, &block)
|
83
|
+
#{to}.#{method}(#{definition}) # client.name(*args, &block)
|
84
|
+
rescue NoMethodError # rescue NoMethodError
|
85
|
+
if #{to}.nil? # if client.nil?
|
86
|
+
#{exception} # # add helpful message to the exception
|
87
|
+
else # else
|
88
|
+
raise # raise
|
89
|
+
end # end
|
90
|
+
end # end
|
91
|
+
EOS
|
92
|
+
end
|
93
|
+
|
94
|
+
#cria funcao com valor false
|
95
|
+
module_eval(<<-EOS, file, line - 2)
|
96
|
+
def #{method_prefix}#{method}=(val) # def customer_name=(val)
|
97
|
+
false # false
|
98
|
+
end # end
|
99
|
+
EOS
|
100
|
+
#cria funcao com valor false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
::ActiveRecord::Base.extend Lookup
|
35
105
|
# adicionar ao ActiveRecord
|
36
106
|
::ActiveRecord::Base.extend PesquisaWrapper
|
37
107
|
end
|
38
|
-
end
|
108
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'action_view/helpers'
|
3
|
+
require 'action_view/helpers/asset_tag_helper'
|
4
|
+
require 'flexa_lib/helpers/other_helpers'
|
5
|
+
require 'action_pack'
|
6
|
+
|
7
|
+
module TableHelper
|
8
|
+
class Table # :nodoc:
|
9
|
+
|
10
|
+
def boolean_column(*args, &block)
|
11
|
+
col_options = args.extract_options!
|
12
|
+
res = nil
|
13
|
+
|
14
|
+
col_options[:html] = { :th => { :width => "1%",:style=>"text-align: center;" },
|
15
|
+
:td => { :style=>"text-align: center;" }}
|
16
|
+
|
17
|
+
attr = args.shift or nil
|
18
|
+
|
19
|
+
if block_given?
|
20
|
+
col_options[:callback] = block
|
21
|
+
@columns << (res = CallbackColumn.new(@template, @records, attr, col_options))
|
22
|
+
elsif attr
|
23
|
+
@columns << (res = BooleanColumn.new(@template, @records, attr, col_options))
|
24
|
+
else
|
25
|
+
raise ArgumentError, "Attribute name or block should be given"
|
26
|
+
end
|
27
|
+
res
|
28
|
+
end
|
29
|
+
|
30
|
+
end #fim da classe TABLE
|
31
|
+
|
32
|
+
class BooleanColumn < Column # :nodoc:
|
33
|
+
|
34
|
+
include ActionView::Helpers
|
35
|
+
include FlexaLib::Helpers::OtherHelpers
|
36
|
+
include ActionView::Helpers::AssetTagHelper
|
37
|
+
include Sprockets::Helpers::RailsHelper
|
38
|
+
|
39
|
+
attr_accessor :output_buffer
|
40
|
+
|
41
|
+
def config
|
42
|
+
Rails.application.config.action_controller if Object.const_defined?("Rails")
|
43
|
+
end
|
44
|
+
|
45
|
+
def content_for(record)
|
46
|
+
#@callback = Proc.new {|n| boolean(n)}
|
47
|
+
@callback = Proc.new {|n| flexa_boolean_grid(n)}
|
48
|
+
@attr ? @callback.call(record.kind_of?(Hash) ? record[@attr] : record.send(@attr)) : @callback.call(record)
|
49
|
+
end
|
50
|
+
|
51
|
+
end #fim da classe BooleanColumn
|
52
|
+
end
|
data/lib/flexa_lib.rb
CHANGED
@@ -53,9 +53,13 @@ require 'will_paginate_twitter_bootstrap'
|
|
53
53
|
#TABLE_FOR
|
54
54
|
require 'table_for_collection'
|
55
55
|
|
56
|
+
require 'flexa_lib/table_for_boolean_column'
|
57
|
+
|
56
58
|
#FORMTASTIC
|
57
59
|
require 'flexa_formtastic_bootstrap'
|
58
60
|
|
61
|
+
#sprockets
|
62
|
+
#require 'sprockets/railtie'
|
59
63
|
|
60
64
|
########################################
|
61
65
|
############## FLEXA LIB ###############
|
@@ -86,6 +90,10 @@ ActiveSupport.on_load :active_record do
|
|
86
90
|
require 'flexa_lib/model_extensions'
|
87
91
|
end
|
88
92
|
|
93
|
+
#require 'sprocetks'
|
94
|
+
ActiveSupport.on_load :action_view do
|
95
|
+
include ::Sprockets::Helpers::RailsHelper
|
96
|
+
end
|
89
97
|
####################################
|
90
98
|
#### Definir o flexa_formtastic_bootstrap
|
91
99
|
#### como FormBuilder Padrão
|
@@ -98,4 +106,4 @@ WillPaginate.per_page = 25
|
|
98
106
|
#validacoes de CPF e CNPJ
|
99
107
|
require 'flexa_lib/brcpfcnpj'
|
100
108
|
|
101
|
-
#### FIM DO ARQUIVO ##########
|
109
|
+
#### FIM DO ARQUIVO ##########
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FlexaLib
|
2
|
+
class AssetsGenerator < Rails::Generators::Base
|
3
|
+
#argument :colunas, :type => :array
|
4
|
+
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
#class_option :orm
|
8
|
+
class_option :no_js, :type => :boolean, :default => false, :desc => 'Sem Javascript'
|
9
|
+
class_option :no_css, :type => :boolean, :default => false, :desc => 'Sem CSS'
|
10
|
+
class_option :force, :type => :boolean, :default => true, :desc => 'Forçando os Arquivos'
|
11
|
+
|
12
|
+
def generate_assets
|
13
|
+
if !options.no_css
|
14
|
+
copy_file "application.css", "app/assets/stylesheets/application.css"
|
15
|
+
end
|
16
|
+
if !options.no_js
|
17
|
+
copy_file "application.js", "app/assets/javascripts/application.js"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,22 +1,47 @@
|
|
1
|
+
require 'rails/generators/base'
|
1
2
|
require 'rails/generators/generated_attribute'
|
3
|
+
require 'rails/generators/resource_helpers'
|
2
4
|
|
3
5
|
module FlexaLib
|
4
|
-
class CrudGenerator < Rails::Generators::
|
6
|
+
class CrudGenerator < Rails::Generators::NamedBase
|
7
|
+
#include Rails::Generators::ResourceHelpers
|
8
|
+
|
9
|
+
# check_class_collision :suffix => "Controller"
|
10
|
+
|
11
|
+
class_option :orm, :banner => "NAME", :type => :string, :required => true,
|
12
|
+
:desc => "ORM to generate the controller for"
|
13
|
+
|
14
|
+
class_option :http, :type => :boolean, :default => false,
|
15
|
+
:desc => "Generate controller with HTTP actions only"
|
16
|
+
|
5
17
|
source_root File.expand_path('../templates', __FILE__)
|
6
18
|
|
7
|
-
argument :controller_path, :type => :string
|
19
|
+
#argument :controller_path, :type => :string
|
20
|
+
argument :name, :type => :string
|
8
21
|
argument :model_name, :type => :string, :required => false
|
9
22
|
|
23
|
+
class_option :no_controller, :type => :boolean, :default => false, :desc => 'Sem controller'
|
24
|
+
class_option :no_views, :type => :boolean, :default => false, :desc => 'Sem Views'
|
10
25
|
class_option :layout, :type => :string, :desc => 'Specify the layout name'
|
11
26
|
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
|
12
27
|
class_option :will_paginate, :type => :boolean, :default => false, :desc => 'Specify if you use will_paginate'
|
13
28
|
class_option :themed_type, :type => :string, :default => 'crud', :desc => 'Specify the themed type, crud or text. Default is crud'
|
14
29
|
|
15
30
|
def initialize(args, *options)
|
31
|
+
#p args.to_yaml
|
32
|
+
|
16
33
|
super(args, *options)
|
17
34
|
initialize_views_variables
|
18
35
|
end
|
19
36
|
|
37
|
+
|
38
|
+
def create_controller_files
|
39
|
+
if !options.no_controller
|
40
|
+
template "controller.rb", File.join('app/controllers', "#{@controller_file_path}_controller.rb")
|
41
|
+
route("resources :#{plural_resource_name}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
20
45
|
def copy_views
|
21
46
|
generate_views
|
22
47
|
unless options.layout.blank?
|
@@ -40,7 +65,8 @@ module FlexaLib
|
|
40
65
|
protected
|
41
66
|
|
42
67
|
def initialize_views_variables
|
43
|
-
|
68
|
+
#@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
69
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(name)
|
44
70
|
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
45
71
|
@model_name = @base_name.singularize unless @model_name
|
46
72
|
@model_name = @model_name.camelize
|
@@ -93,6 +119,8 @@ module FlexaLib
|
|
93
119
|
end
|
94
120
|
|
95
121
|
def generate_views
|
122
|
+
return if options.no_views
|
123
|
+
|
96
124
|
views = {
|
97
125
|
'crud' => {
|
98
126
|
'view_tables.html.erb' => File.join('app/views', @controller_file_path, "index.html.#{options.engine}"),
|
@@ -0,0 +1,109 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
<%
|
3
|
+
model_nome = class_name.split('::')
|
4
|
+
controller_class_name = class_name
|
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
|
+
@<%= ptbl_nome %> = <%= tbl_nome.camelcase %>.flexa_search(:search => {:text => params[:search],:fields => ['id']}, :page => params[:page])
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
format.html # index.html.erb
|
34
|
+
format.json { render :json => <%= "@#{ptbl_nome}" %> }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# GET <%= route_url %>/1
|
39
|
+
# GET <%= route_url %>/1.json
|
40
|
+
def show
|
41
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.find(params[:id])
|
42
|
+
|
43
|
+
respond_to do |format|
|
44
|
+
format.html # show.html.erb
|
45
|
+
format.json { render :json => <%= "@#{tbl_nome}" %> }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# GET <%= route_url %>/new
|
50
|
+
# GET <%= route_url %>/new.json
|
51
|
+
def new
|
52
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.new
|
53
|
+
|
54
|
+
respond_to do |format|
|
55
|
+
format.html # new.html.erb
|
56
|
+
format.json { render :json => <%= "@#{tbl_nome}" %> }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# GET <%= route_url %>/1/edit
|
61
|
+
def edit
|
62
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.find(params[:id])
|
63
|
+
end
|
64
|
+
|
65
|
+
# POST <%= route_url %>
|
66
|
+
# POST <%= route_url %>.json
|
67
|
+
def create
|
68
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.new(params[:<%= tbl_nome %>])
|
69
|
+
|
70
|
+
respond_to do |format|
|
71
|
+
if @<%= tbl_nome %>.save
|
72
|
+
format.html { redirect_to @<%= tbl_nome %>, :notice => <%= "'#{tbl_nome.camelcase} was successfully created.'" %> }
|
73
|
+
format.json { render :json => <%= "@#{tbl_nome}" %>, :status => :created, :location => <%= "@#{tbl_nome}" %> }
|
74
|
+
else
|
75
|
+
format.html { render :action => "new" }
|
76
|
+
format.json { render :json => <%= "@#{tbl_nome}" %>.errors , :status => :unprocessable_entity }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# PATCH/PUT <%= route_url %>/1
|
82
|
+
# PATCH/PUT <%= route_url %>/1.json
|
83
|
+
def update
|
84
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.find(params[:id])
|
85
|
+
|
86
|
+
respond_to do |format|
|
87
|
+
if @<%= tbl_nome%>.update_attributes(params[:<%=tbl_nome%>])
|
88
|
+
format.html { redirect_to @<%= tbl_nome %>, :notice => <%= "'#{tbl_nome.camelcase} was successfully updated.'" %> }
|
89
|
+
format.json { head :ok }
|
90
|
+
else
|
91
|
+
format.html { render :action => "edit" }
|
92
|
+
format.json { render :json => <%= "@#{tbl_nome}" %>.errors, :status => :unprocessable_entity }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# DELETE <%= route_url %>/1
|
98
|
+
# DELETE <%= route_url %>/1.json
|
99
|
+
def destroy
|
100
|
+
@<%= tbl_nome %> = <%= tbl_nome.camelcase %>.find(params[:id])
|
101
|
+
@<%= tbl_nome%>.destroy
|
102
|
+
|
103
|
+
respond_to do |format|
|
104
|
+
format.html { redirect_to <%= index_helper %>_url }
|
105
|
+
format.json { head :ok }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
<% end -%>
|
@@ -4,11 +4,11 @@ class Lookups::<%=class_name.pluralize %>Controller < ApplicationController
|
|
4
4
|
# GET <%= route_url %>
|
5
5
|
# GET <%= route_url %>.xml
|
6
6
|
def index
|
7
|
-
<%
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@<%= plural_table_name %> = <%= class_name%>.
|
7
|
+
<%
|
8
|
+
cols_search = colunas.dup
|
9
|
+
cols_search = cols_search.join("','")
|
10
|
+
%>
|
11
|
+
@<%= plural_table_name %> = <%= class_name%>.flexa_search(:search => {:text => params[:search],:fields => ['<%=cols_search%>']}, :page => params[:page])
|
12
12
|
|
13
13
|
respond_to do |format|
|
14
14
|
format.html # index.html.erb
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Allan Freitas
|
@@ -16,12 +16,28 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-04-
|
19
|
+
date: 2012-04-17 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: sass-rails
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 2
|
33
|
+
- 3
|
34
|
+
version: 3.2.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: formtastic
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
26
42
|
requirements:
|
27
43
|
- - ">="
|
@@ -33,11 +49,11 @@ dependencies:
|
|
33
49
|
- 2
|
34
50
|
version: 2.0.2
|
35
51
|
type: :runtime
|
36
|
-
version_requirements: *
|
52
|
+
version_requirements: *id002
|
37
53
|
- !ruby/object:Gem::Dependency
|
38
54
|
name: table_for_collection
|
39
55
|
prerelease: false
|
40
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
59
|
- - ">="
|
@@ -49,11 +65,11 @@ dependencies:
|
|
49
65
|
- 6
|
50
66
|
version: 1.0.6
|
51
67
|
type: :runtime
|
52
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
53
69
|
- !ruby/object:Gem::Dependency
|
54
70
|
name: will_paginate
|
55
71
|
prerelease: false
|
56
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
58
74
|
requirements:
|
59
75
|
- - ">="
|
@@ -65,11 +81,11 @@ dependencies:
|
|
65
81
|
- 2
|
66
82
|
version: 3.0.2
|
67
83
|
type: :runtime
|
68
|
-
version_requirements: *
|
84
|
+
version_requirements: *id004
|
69
85
|
- !ruby/object:Gem::Dependency
|
70
86
|
name: will_paginate_twitter_bootstrap
|
71
87
|
prerelease: false
|
72
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
89
|
none: false
|
74
90
|
requirements:
|
75
91
|
- - ">="
|
@@ -81,7 +97,7 @@ dependencies:
|
|
81
97
|
- 0
|
82
98
|
version: 1.0.0
|
83
99
|
type: :runtime
|
84
|
-
version_requirements: *
|
100
|
+
version_requirements: *id005
|
85
101
|
description: "Helpers, Geradores(de controllers, views, Scaffolds Personalizados) Em Breve Documenta\xC3\xA7\xC3\xA3o."
|
86
102
|
email:
|
87
103
|
- allan.freitas@flexait.com.br
|
@@ -211,6 +227,7 @@ files:
|
|
211
227
|
- vendor/assets/images/arrow2.gif
|
212
228
|
- vendor/assets/images/icon_sucess.gif
|
213
229
|
- lib/action_view/helpers/text_field_date_helper.rb
|
230
|
+
- lib/flexa_lib/table_for_boolean_column.rb
|
214
231
|
- lib/flexa_lib/model_extensions.rb
|
215
232
|
- lib/flexa_lib/brcpfcnpj.rb
|
216
233
|
- lib/flexa_lib/engine.rb
|
@@ -232,6 +249,8 @@ files:
|
|
232
249
|
- lib/flexa_lib/helpers/link_helpers.rb
|
233
250
|
- lib/flexa_lib/helpers.rb
|
234
251
|
- lib/flexa_lib/date_extensions.rb
|
252
|
+
- lib/generators/flexa_lib/assets/assets_generator.rb
|
253
|
+
- lib/generators/flexa_lib/crud/templates/controller.rb
|
235
254
|
- lib/generators/flexa_lib/crud/crud_generator.rb
|
236
255
|
- lib/generators/flexa_lib/lookup/lookup_generator.rb
|
237
256
|
- lib/generators/flexa_lib/lookup/templates/lookup_controller.rb
|