flexa_lib 0.5.0 → 0.5.1

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 CHANGED
@@ -81,5 +81,40 @@ Vamos gerar o Lookup
81
81
  # rails g flexa_lib:lookup Model campo_pesquisa1 campo_pesquisa2
82
82
 
83
83
 
84
+ ########## Formulário Com COCOON #################
85
+ Versão 0.5.1 da gem pra cima
86
+
87
+ - Forma Personalizavel
88
+
89
+ ------------------------------------------------------------
90
+ <%= flexa_form_item_box(f,:servicos) do %>
91
+ <%= f.semantic_fields_for :servicos do |fp| %>
92
+ <%= render :partial => 'servico_fields', :locals =>{:f => fp},:render_options => {:wrapper => 'inline' } %>
93
+ <% end %>
94
+ <%end%>
95
+
96
+ <%= flexa_form_add_button(f,:servicos) if !@readonly %>
97
+ ------------------------------------------------------------
98
+
99
+ - Forma simplificada
100
+ # Parametros:
101
+ variavel "f" do formulário pai,
102
+ nome_do_filho_plural
103
+ variavel "@readonly" obritagoria
104
+
105
+ <%= flexa_form_nested_item_box(f,:servicos,@readonly)%>
106
+
107
+
108
+ Gerar a View para o Filho
109
+
110
+ # Parametros
111
+ Resource PAI no plural
112
+ Model Filho no plural
113
+ Nomes dos Campos a serem gerados no arquivo
114
+
115
+ rails g flexa_lib:cocoon_view Estados Cidades campo1 campo2
116
+
117
+
118
+
84
119
  ########## PARA ESTUDO ############
85
120
  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.5.0'
10
+ s.version = '0.5.1'
11
11
  s.platform = Gem::Platform::RUBY
12
12
 
13
13
  s.authors = ['Allan Freitas','Marcio Sfalsin']
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  #s.add_dependency 'thor', '~> 0.14'
36
36
  s.add_dependency 'sass-rails', '>=3.2.3'
37
37
  s.add_dependency 'formtastic', '>=2.0.2'
38
+ s.add_dependency 'cocoon' , '>=1.0.17'
38
39
  s.add_dependency 'table_for_collection', '>=1.0.6'
39
40
  s.add_dependency 'will_paginate', '>=3.0.2'
40
41
  s.add_dependency 'will_paginate_twitter_bootstrap', '>=1.0.0'
@@ -31,7 +31,7 @@ module FlexaFormtasticBootstrap
31
31
 
32
32
  include FlexaFormtasticBootstrap::Helpers::InputHelper
33
33
  include FlexaFormtasticBootstrap::Helpers::InputsHelper
34
- include FlexaFormtasticBootstrap::Helpers::ButtonsHelper
34
+ #include FlexaFormtasticBootstrap::Helpers::ButtonsHelper
35
35
 
36
36
  end
37
37
 
@@ -2,7 +2,7 @@ module FlexaFormtasticBootstrap
2
2
  module Helpers
3
3
  module ButtonsHelper
4
4
 
5
- include Formtastic::Helpers::ButtonsHelper
5
+ #include Formtastic::Helpers::ButtonsHelper
6
6
 
7
7
  def buttons(*args, &block)
8
8
 
@@ -31,4 +31,3 @@ module FlexaFormtasticBootstrap
31
31
 
32
32
  end
33
33
  end
34
-
@@ -0,0 +1,67 @@
1
+ module FlexaLib
2
+ module Helpers
3
+ module CocoonHelpers
4
+
5
+
6
+ def flexa_form_nested_item_box(parent_form,child_resource,readonly=false,&block)
7
+
8
+ nested_form_view = child_resource.to_s.singularize << '_fields'
9
+
10
+ if !readonly
11
+ (content_tag :div, :id=>child_resource.to_s, :class=>"form_horizontal" do
12
+ parent_form.semantic_fields_for(child_resource.to_sym) do |fp|
13
+ render :partial => nested_form_view, :locals =>{:f => fp},:render_options => {:wrapper => 'inline' }
14
+ end
15
+ #block.call
16
+ end)+flexa_form_add_button(parent_form,child_resource.to_sym)
17
+ else
18
+ content_tag :div, :id=>child_resource.to_s, :class=>"form_horizontal" do
19
+ parent_form.semantic_fields_for(child_resource.to_sym) do |fp|
20
+ render :partial => nested_form_view, :locals =>{:f => fp},:render_options => {:wrapper => 'inline' }
21
+ end
22
+ #block.call
23
+ end
24
+ end
25
+ end
26
+
27
+ def flexa_form_item_box(parent_form,child_resource,&block)
28
+ content_tag :div, :id=>child_resource.to_s, :class=>"form_horizontal" do
29
+ block.call
30
+ end
31
+ end
32
+
33
+ def flexa_form_item_row(&block)
34
+ content_tag :div, :class=>"nested-fields form_horizontal" do
35
+ block.call
36
+ end
37
+ end
38
+
39
+ def flexa_form_delete_button(parent_form)
40
+ content_tag(:div, :class=>"select clearfix optional", :style=>"margin-left: -15px;") do
41
+ concat(content_tag(:label) do
42
+ raw "&nbsp;"
43
+ end)
44
+ concat(content_tag(:div,:style=>"line-height: 25px;margin-right:2px;") do
45
+ link_to_remove_association content_tag("i", "",:class=>"icon-white icon-minus"), parent_form, :class=>"btn btn-smallest btn-danger", :id => "delete"
46
+ end)
47
+ end
48
+ end
49
+
50
+ def flexa_form_delete_button(parent_form)
51
+ content_tag(:div, :class=>"select clearfix optional", :style=>"margin-left: -15px;") do
52
+ concat(content_tag(:label) do
53
+ raw "&nbsp;"
54
+ end)
55
+ concat(content_tag(:div,:style=>"line-height: 25px;margin-right:2px;") do
56
+ link_to_remove_association content_tag("i", "",:class=>"icon-white icon-minus"), parent_form, :class=>"btn btn-smallest btn-danger", :id => "delete"
57
+ end)
58
+ end
59
+ end
60
+
61
+ def flexa_form_add_button(parent_form,child_resource)
62
+ link_to_add_association content_tag("i", "",:class=>"icon-white icon-plus"), parent_form, child_resource.to_sym,:class=>"btn btn-smallest btn-info", :id => "plus","data-association-insertion-method"=>"after","data-association-insertion-node"=>"#"+child_resource.to_s
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -95,6 +95,10 @@ module FlexaLib
95
95
  image_tag(imagem)
96
96
  end
97
97
 
98
+ #
99
+ def formata_real(valor)
100
+ number_to_currency(valor, {:separator => ",", :delimiter => ".", :unit => "R$ "})
101
+ end
98
102
 
99
103
  end
100
104
  end
@@ -6,6 +6,7 @@ require 'flexa_lib/helpers/paginate_helpers'
6
6
  require 'flexa_lib/helpers/table_helpers'
7
7
  require 'flexa_lib/helpers/lookup_helpers'
8
8
  require 'flexa_lib/helpers/tab_helpers'
9
+ require 'flexa_lib/helpers/cocoon_helpers'
9
10
 
10
11
  module FlexaLib
11
12
  module Helpers
@@ -24,5 +25,7 @@ module FlexaLib
24
25
  include LookupHelpers
25
26
 
26
27
  include TabHelpers
28
+
29
+ include CocoonHelpers
27
30
  end
28
31
  end
@@ -49,4 +49,4 @@ module TableHelper
49
49
  end
50
50
 
51
51
  end #fim da classe BooleanColumn
52
- end
52
+ end
data/lib/flexa_lib.rb CHANGED
@@ -56,8 +56,12 @@ require 'table_for_collection'
56
56
  require 'flexa_lib/table_for_boolean_column'
57
57
 
58
58
  #FORMTASTIC
59
+ #require 'formtastic'
59
60
  require 'flexa_formtastic_bootstrap'
60
61
 
62
+ #cocoon
63
+ require 'cocoon'
64
+
61
65
  #sprockets
62
66
  #require 'sprockets/railtie'
63
67
 
@@ -0,0 +1,35 @@
1
+ module FlexaLib
2
+ class CocoonViewGenerator < Rails::Generators::NamedBase
3
+
4
+ argument :nested, :type => :string, :required => true
5
+ argument :campos, :type => :array, :required => true
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def initialize(args, *options)
10
+
11
+ super(args, *options)
12
+ initialize_views_variables
13
+ end
14
+
15
+ def generate_lookup
16
+ template "cocoon_view.erb", File.join('app/views', @controller_file_path, "_#{nested.singularize.underscore}_fields.html.erb")
17
+ end
18
+
19
+ protected
20
+
21
+ def initialize_views_variables
22
+ @controller_file_path = extract_modules(name)
23
+ end
24
+
25
+ def extract_modules(name)
26
+ modules = name.include?('/') ? name.split('/') : name.split('::')
27
+ name = modules.pop
28
+ path = modules.map { |m| m.underscore }
29
+ file_path = (path + [name.underscore]).join('/')
30
+
31
+ file_path
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,6 @@
1
+ <%%=flexa_form_item_row do %>
2
+ <%%= f.inputs do %><% if campos.count>0%><%campos.each do |campo| %>
3
+ <%%= f.input :<%=campo%>, :input_html=>{:class=>"input-small",:readonly => @readonly, :disabled=>@readonly } %><%end%><%end%>
4
+ <%%= flexa_form_delete_button(f) if !@readonly%>
5
+ <%% end %>
6
+ <%% end %>
@@ -8,6 +8,7 @@
8
8
  // = require jquery_ujs
9
9
  //= require bootstrap
10
10
  //= require populate
11
+ //= require cocoon
11
12
  //= require 'jquery.cookie'
12
13
  //= require 'jquery-ui-1.8.18.custom.min'
13
14
 
@@ -60,5 +60,9 @@
60
60
 
61
61
 
62
62
  div.lookup div.input input.readonly {
63
- width: 220px;
63
+ width: 175px;
64
+ }
65
+
66
+ div.lookup div.input input.lookup_disabled {
67
+ width: 210px;
64
68
  }
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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
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-04-17 00:00:00 Z
19
+ date: 2012-04-18 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: sass-rails
@@ -51,9 +51,25 @@ dependencies:
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: table_for_collection
54
+ name: cocoon
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 53
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 17
66
+ version: 1.0.17
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: table_for_collection
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ">="
@@ -65,11 +81,11 @@ dependencies:
65
81
  - 6
66
82
  version: 1.0.6
67
83
  type: :runtime
68
- version_requirements: *id003
84
+ version_requirements: *id004
69
85
  - !ruby/object:Gem::Dependency
70
86
  name: will_paginate
71
87
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
91
  - - ">="
@@ -81,11 +97,11 @@ dependencies:
81
97
  - 2
82
98
  version: 3.0.2
83
99
  type: :runtime
84
- version_requirements: *id004
100
+ version_requirements: *id005
85
101
  - !ruby/object:Gem::Dependency
86
102
  name: will_paginate_twitter_bootstrap
87
103
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
107
  - - ">="
@@ -97,7 +113,7 @@ dependencies:
97
113
  - 0
98
114
  version: 1.0.0
99
115
  type: :runtime
100
- version_requirements: *id005
116
+ version_requirements: *id006
101
117
  description: "Helpers, Geradores(de controllers, views, Scaffolds Personalizados) Em Breve Documenta\xC3\xA7\xC3\xA3o."
102
118
  email:
103
119
  - allan.freitas@flexait.com.br
@@ -240,6 +256,7 @@ files:
240
256
  - lib/flexa_lib/brcpfcnpj/cpf_validator.rb
241
257
  - lib/flexa_lib/version.rb
242
258
  - lib/flexa_lib/helpers/table_helpers.rb
259
+ - lib/flexa_lib/helpers/cocoon_helpers.rb
243
260
  - lib/flexa_lib/helpers/paginate_helpers.rb
244
261
  - lib/flexa_lib/helpers/button_helpers.rb
245
262
  - lib/flexa_lib/helpers/button_grid_helpers.rb
@@ -249,9 +266,9 @@ files:
249
266
  - lib/flexa_lib/helpers/link_helpers.rb
250
267
  - lib/flexa_lib/helpers.rb
251
268
  - lib/flexa_lib/date_extensions.rb
252
- - lib/generators/flexa_lib/assets/assets_generator.rb
253
269
  - lib/generators/flexa_lib/crud/templates/controller.rb
254
270
  - lib/generators/flexa_lib/crud/crud_generator.rb
271
+ - lib/generators/flexa_lib/cocoon_view/cocoon_view_generator.rb
255
272
  - lib/generators/flexa_lib/lookup/lookup_generator.rb
256
273
  - lib/generators/flexa_lib/lookup/templates/lookup_controller.rb
257
274
  - lib/generators/flexa_lib/lookup/lookup_generator_test.rb
@@ -308,6 +325,7 @@ files:
308
325
  - lib/generators/flexa_lib/crud/templates/view_new.html.erb
309
326
  - lib/generators/flexa_lib/crud/templates/view_show.html.erb
310
327
  - lib/generators/flexa_lib/crud/templates/view_form.html.erb
328
+ - lib/generators/flexa_lib/cocoon_view/templates/cocoon_view.erb
311
329
  - lib/generators/flexa_lib/lookup/templates/lookup_view.erb
312
330
  - LICENSE
313
331
  - README.txt
@@ -1,21 +0,0 @@
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