beautiful_scaffold 1.0.0.pre → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +9 -0
  3. data/Gemfile +1 -9
  4. data/README.rdoc +1 -1
  5. data/beautiful_scaffold.gemspec +1 -1
  6. data/lib/generators/beautiful_locale_generator.rb +24 -3
  7. data/lib/generators/beautiful_scaffold_common_methods.rb +47 -10
  8. data/lib/generators/beautiful_scaffold_generator.rb +61 -40
  9. data/lib/generators/templates/app/assets/javascripts/application-bs.js +3 -2
  10. data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +37 -1
  11. data/lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js +23 -44
  12. data/lib/generators/templates/app/assets/stylesheets/application-bs.css +1 -2
  13. data/lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss +25 -1
  14. data/lib/generators/templates/app/controllers/base.rb +17 -7
  15. data/lib/generators/templates/app/controllers/master_base.rb +39 -25
  16. data/lib/generators/templates/app/helpers/beautiful_helper.rb +23 -9
  17. data/lib/generators/templates/app/helpers/model_helper.rb +14 -3
  18. data/lib/generators/templates/app/initializers/ransack.rb +16 -0
  19. data/lib/generators/templates/app/views/_mass_inserting.html.erb +3 -2
  20. data/lib/generators/templates/app/views/_modal_columns.html.erb +2 -2
  21. data/lib/generators/templates/app/views/index.html.erb +25 -3
  22. data/lib/generators/templates/app/views/layout.html.erb +0 -11
  23. data/lib/generators/templates/app/views/partials/_index_search.html.erb +1 -1
  24. data/lib/generators/templates/app/views/partials/_index_search_default_fields.html.erb +1 -1
  25. data/lib/generators/templates/app/views/treeview.html.erb +4 -4
  26. metadata +5 -6
  27. data/lib/generators/templates/app/assets/javascripts/bootstrap-datepicker.js +0 -834
  28. data/lib/generators/templates/app/assets/javascripts/bootstrap-timepicker.js +0 -797
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c788ac3707c3a554a7fd4b8d7796645899275068
4
- data.tar.gz: 194fa4ea7f3f50c1548dd1306d9718e3e6eaaf76
3
+ metadata.gz: 22819b7aae444a86cc628089c52962012d24c031
4
+ data.tar.gz: 26aa274ae0fa88969e570ef22415ac490ef7e913
5
5
  SHA512:
6
- metadata.gz: ccdaf02eeca18d1b3e84857a16ca055349207879ff83846b1e794d60efb0c2a6068f6a57351001eacbf96941ac3f3a3b293f3e2a72ac3be4efb0e10c2c337629
7
- data.tar.gz: cd77e358cab2f4c04db96e08d7b52357d07e2223121fa5f67dacf8fae893c971e403e32a039043b982a2051a52a437d6f3d9f801260318dea64a52e6fe9ef7bd
6
+ metadata.gz: 1e555f0e2242f97ead7b3ff4ed8b1260ea9bd73f66e6ea27498a514f7990b3aafb582cac388eac8a0a3663a83a1e7769a33ae6a672380c542e1c261448163345
7
+ data.tar.gz: 1408deef315e1e3d7a1fa84f7e9543a32c5c70db40138f186ec4368abbbf7f8bfde3ddd2de6283a212571046ac1028dcc02067ec0ef264a40ee1c2913b6b9d72
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ == 1.0.1
2
+
3
+ * enhancement
4
+ * Change datetimepicker (eyecon.ro -> eonasdan)
5
+ * Support CamelCase syntaxe for models.
6
+
7
+ * bugfix
8
+ * Change keys symbol into string on session (begin at 0.3.5)
9
+
1
10
  == 1.0.0.pre
2
11
 
3
12
  * enhancement
data/Gemfile CHANGED
@@ -8,14 +8,6 @@ gem "will_paginate"
8
8
  # Search and filter
9
9
  gem "ransack"
10
10
  # Pdf
11
- gem 'prawn', '1.0.0.rc2'
12
- # Textile
13
- gem 'RedCloth'
14
- # BBCode
15
- gem 'bb-ruby'
16
- # Markdown
17
- gem 'bluecloth'
18
- # Markdown
19
- gem 'rdiscount'
11
+ gem 'prawn'
20
12
  # Clear html tag
21
13
  gem 'sanitize'
data/README.rdoc CHANGED
@@ -23,7 +23,7 @@ Add this in your Gemfile :
23
23
 
24
24
  Add this in your Gemfile :
25
25
 
26
- gem 'beautiful_scaffold', '1.0.0.pre'
26
+ gem 'beautiful_scaffold', '1.0.1'
27
27
 
28
28
  === Next
29
29
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "beautiful_scaffold"
6
- s.version = "1.0.0.pre"
6
+ s.version = "1.0.1"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.summary = "Beautiful Scaffold generate fully customizable scaffold"
9
9
  s.email = "claudel.sylvain@gmail.com"
@@ -6,6 +6,8 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
6
6
  source_root File.expand_path('../templates', __FILE__)
7
7
 
8
8
  argument :name, :type => :string, :desc => "type of locale : fr OR en OR de OR ja all..."
9
+
10
+ class_option :mountable_engine, :default => nil
9
11
 
10
12
  def install_locale
11
13
  availablelocale = ["fr", "en", "ja"]
@@ -56,7 +58,15 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
56
58
 
57
59
  already_processed = { name.downcase => {}}
58
60
 
59
- filepath = File.join(Rails.root, 'config', 'locales', "#{Rails.application.class.parent_name.downcase}.#{name.downcase}.yml")
61
+ app_name = (Rails.root || engine_opt)
62
+ engine_or_apps = (Rails.application.class.parent_name || engine_opt).downcase
63
+
64
+ puts "===>"
65
+ puts app_name
66
+ puts "=======>"
67
+ puts engine_or_apps
68
+
69
+ filepath = File.join(app_name, 'config', 'locales', "#{engine_or_apps}.#{name.downcase}.yml")
60
70
  begin
61
71
  hi18n = YAML.load_file(filepath)
62
72
  rescue
@@ -77,9 +87,20 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
77
87
 
78
88
  Dir.glob("app/models/**/*").each { |model_file|
79
89
  puts model_file
80
- next if File.directory?(model_file) or File.basename(model_file).first == '.'
90
+ next if File.directory?(model_file) or
91
+ File.basename(model_file).first == '.' or
92
+ model_file.include?('/concerns/') or
93
+ model_file.include?('pdf_report.rb') or
94
+ model_file.include?('application_record.rb')
95
+
81
96
  model = File.basename(model_file, File.extname(model_file))
82
- klass = model.camelize.constantize
97
+
98
+ if !engine_opt.blank?
99
+ prefix = "#{engine_opt.camelize}::"
100
+ else
101
+ prefix = ''
102
+ end
103
+ klass = "#{prefix}#{model.camelize.constantize}"
83
104
 
84
105
  begin
85
106
  sorted_attr = klass.attribute_names.sort
@@ -3,6 +3,22 @@ module BeautifulScaffoldCommonMethods
3
3
 
4
4
  private
5
5
 
6
+ #############
7
+ # Engine
8
+ #############
9
+
10
+ def engine_opt
11
+ options[:mountable_engine].to_s
12
+ end
13
+
14
+ def engine_name
15
+ engine_opt.blank? ? '' : "#{engine_opt}/"
16
+ end
17
+
18
+ def engine_camel
19
+ options[:mountable_engine].camelize
20
+ end
21
+
6
22
  #############
7
23
  # Namespace
8
24
  #############
@@ -39,10 +55,18 @@ module BeautifulScaffoldCommonMethods
39
55
  # Models
40
56
  ############
41
57
 
58
+ def model
59
+ model_opt.underscore
60
+ end
61
+
42
62
  def model_camelize
43
63
  model.camelize
44
64
  end
45
65
 
66
+ def model_with_engine_camelize
67
+ (engine_name.blank? ? model.camelize : "#{engine_camel}::#{model_camelize}")
68
+ end
69
+
46
70
  def model_pluralize
47
71
  model.pluralize
48
72
  end
@@ -156,16 +180,29 @@ module BeautifulScaffoldCommonMethods
156
180
  end
157
181
 
158
182
  def require_gems
159
- gem('less-rails', '2.8.0')
160
- gem('will_paginate') # v 3.1.5
161
- gem('ransack', '1.8.2')
162
- gem('polyamorous', '1.3.1')
163
- gem('jquery-ui-rails')
164
- gem('prawn', '2.1.0')
165
- gem('prawn-table', '0.2.2')
166
- gem('sanitize')
167
- gem('twitter-bootstrap-rails', '3.2.2')
168
- gem('chardinjs-rails')
183
+ gems = {
184
+ 'less-rails' => '2.8.0',
185
+ 'will_paginate' => nil, # v 3.1.5
186
+ 'ransack' => '1.8.2',
187
+ 'polyamorous' => '1.3.1',
188
+ 'jquery-ui-rails' => nil,
189
+ 'prawn' => '2.1.0',
190
+ 'prawn-table' => '0.2.2',
191
+ 'sanitize' => nil,
192
+ 'twitter-bootstrap-rails' => '3.2.2',
193
+ 'chardinjs-rails' => nil,
194
+ 'momentjs-rails' => '>= 2.9.0',
195
+ 'bootstrap3-datetimepicker-rails' => '~> 4.17.47'
196
+ }
197
+
198
+ # Si engine il faut mettre les gems dans le gemspec et faire le require
199
+ if !Dir.glob('./*.gemspec').empty?
200
+ puts "============> Engine : You must add gems to your main app \n #{gems.to_a.map{ |a| "gem '#{a[0]}'#{(a[1].nil? ? '' : ", '#{a[1]}'")} " }.join("\n")}"
201
+ end
202
+
203
+ gems.each{ |gem_to_add, version|
204
+ gem(gem_to_add, version)
205
+ }
169
206
  end
170
207
 
171
208
  end
@@ -13,11 +13,12 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
13
13
 
14
14
  source_root File.expand_path('../templates', __FILE__)
15
15
 
16
- argument :model, :type => :string, :desc => "Name of model (downcase singular)"
16
+ argument :model_opt, :type => :string, :desc => "Name of model (singular)"
17
17
  argument :myattributes, :type => :array, :default => [], :banner => "field:type field:type"
18
18
 
19
19
  class_option :namespace, :default => nil
20
20
  class_option :donttouchgem, :default => nil
21
+ class_option :mountable_engine, :default => nil
21
22
 
22
23
  def install_gems
23
24
  if options[:donttouchgem].blank? then
@@ -46,62 +47,73 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
46
47
 
47
48
  def mimetype
48
49
  if not File.exist?("app/controllers/beautiful_controller.rb") then
49
- inject_into_file("config/initializers/mime_types.rb", 'Mime::Type.register_alias "application/pdf", :pdf' + "\n", :before => "# Be sure to restart your server when you modify this file." )
50
+ if File.exist?("config/initializers/mime_types.rb") then # For mountable engine
51
+ inject_into_file("config/initializers/mime_types.rb", 'Mime::Type.register_alias "application/pdf", :pdf' + "\n", :before => "# Be sure to restart your server when you modify this file." )
52
+ else
53
+ puts "============> Engine : You must add `Mime::Type.register_alias \"application/pdf\", :pdf` to your config/initializers/mime_types.rb main app !"
54
+ end
50
55
  end
51
56
  end
52
57
 
53
58
  def generate_assets
54
59
  stylesheetspath = "app/assets/stylesheets/"
60
+ stylesheetspath_dest = "#{stylesheetspath}#{engine_name}"
55
61
 
56
62
  # Css
57
- reset = "#{stylesheetspath}reset.css"
63
+ reset = "reset.css"
58
64
  bc_css = [
59
- "#{stylesheetspath}application-bs.css",
60
- "#{stylesheetspath}datepicker.css",
61
- "#{stylesheetspath}timepicker.css",
62
- "#{stylesheetspath}beautiful-scaffold.css.scss",
63
- "#{stylesheetspath}tagit-dark-grey.css",
64
- "#{stylesheetspath}colorpicker.css",
65
- "#{stylesheetspath}bootstrap-wysihtml5.css"
65
+ "application-bs.css",
66
+ "beautiful-scaffold.css.scss",
67
+ "tagit-dark-grey.css",
68
+ "colorpicker.css",
69
+ "bootstrap-wysihtml5.css"
66
70
  ]
67
-
71
+
68
72
  javascriptspath = "app/assets/javascripts/"
73
+ javascriptspath_dest = "#{javascriptspath}#{engine_name}"
74
+
75
+ [reset, bc_css].flatten.each{ |path|
76
+ copy_file "#{stylesheetspath}#{path}", "#{stylesheetspath_dest}#{path}"
77
+ }
69
78
 
70
79
  # Js
71
80
  bc_js = [
72
- "#{javascriptspath}application-bs.js",
73
- "#{javascriptspath}beautiful_scaffold.js",
74
- "#{javascriptspath}bootstrap-datepicker.js",
75
- "#{javascriptspath}bootstrap-datetimepicker-for-beautiful-scaffold.js",
76
- "#{javascriptspath}bootstrap-timepicker.js",
77
- "#{javascriptspath}jquery.jstree.js",
78
- "#{javascriptspath}jquery-barcode.js",
79
- "#{javascriptspath}tagit.js",
80
- "#{javascriptspath}bootstrap-colorpicker.js",
81
- "#{javascriptspath}a-wysihtml5-0.3.0.min.js",
82
- "#{javascriptspath}bootstrap-wysihtml5.js",
83
- "#{javascriptspath}fixed_menu.js"
81
+ "application-bs.js",
82
+ "beautiful_scaffold.js",
83
+ "bootstrap-datetimepicker-for-beautiful-scaffold.js",
84
+ "jquery.jstree.js",
85
+ "jquery-barcode.js",
86
+ "tagit.js",
87
+ "bootstrap-colorpicker.js",
88
+ "a-wysihtml5-0.3.0.min.js",
89
+ "bootstrap-wysihtml5.js",
90
+ "fixed_menu.js"
84
91
  ]
85
92
 
86
- [reset, bc_css, bc_js].flatten.each{ |path|
87
- copy_file path, path
93
+ [bc_js].flatten.each{ |path|
94
+ copy_file "#{javascriptspath}#{path}", "#{javascriptspath_dest}#{path}"
88
95
  }
89
96
 
90
97
  # Jstree theme
91
- directory "app/assets/stylesheets/themes", "app/assets/stylesheets/themes"
98
+ directory "#{stylesheetspath}themes", "#{stylesheetspath}themes"
92
99
 
93
100
  # Images
94
101
  dir_image = "app/assets/images"
95
- directory dir_image, dir_image
102
+ dir_image_dest = "app/assets/images/#{engine_opt}"
103
+ directory dir_image, dir_image_dest
96
104
 
97
105
  # Old method
98
106
  #generate("bootstrap:install","static")
99
107
  # New method
100
108
  copy_file "#{stylesheetspath}bootstrap_and_overrides.css.less",
101
- "#{stylesheetspath}bootstrap_and_overrides.css.less"
109
+ "#{stylesheetspath_dest}bootstrap_and_overrides.css.less"
102
110
 
103
111
  # Precompile BS assets
104
- inject_into_file("config/initializers/assets.rb", "Rails.application.config.assets.precompile += ['application-bs.css','application-bs.js']", after: /\z/m)
112
+ if File.exist?("config/initializers/assets.rb") then # For mountable engine
113
+ inject_into_file("config/initializers/assets.rb", "Rails.application.config.assets.precompile += ['#{engine_name}application-bs.css','#{engine_name}application-bs.js']", after: /\z/m)
114
+ else
115
+ puts "============> Engine : You must add `Rails.application.config.assets.precompile += ['#{engine_name}application-bs.css','#{engine_name}application-bs.js']` to your config/initializers/assets.rb main app !"
116
+ end
105
117
  end
106
118
 
107
119
  def generate_layout
@@ -110,8 +122,8 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
110
122
  template "app/views/_beautiful_menu.html.erb", "app/views/layouts/_beautiful_menu.html.erb"
111
123
  end
112
124
 
113
- empty_directory "app/views/beautiful"
114
- template "app/views/dashboard.html.erb", "app/views/beautiful/dashboard.html.erb"
125
+ empty_directory "app/views/#{engine_name}beautiful"
126
+ template "app/views/dashboard.html.erb", "app/views/#{engine_name}beautiful/dashboard.html.erb"
115
127
  copy_file "app/views/_modal_columns.html.erb", "app/views/layouts/_modal_columns.html.erb"
116
128
  copy_file "app/views/_mass_inserting.html.erb", "app/views/layouts/_mass_inserting.html.erb"
117
129
 
@@ -126,7 +138,8 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
126
138
 
127
139
  directory "app/models/concerns", "app/models/concerns"
128
140
 
129
- inject_into_file("app/models/#{model}.rb",'
141
+ gsub_file "app/models/#{engine_name}#{model}.rb", 'ActiveRecord::Base', 'ApplicationRecord' # Rails 4 -> 5
142
+ inject_into_file("app/models/#{engine_name}#{model}.rb",'
130
143
 
131
144
  include DefaultSortingConcern
132
145
  include FulltextConcern
@@ -149,7 +162,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
149
162
  a,t = attr.split(':')
150
163
  if ['references', 'reference'].include?(t) then
151
164
  begin
152
- inject_into_file("app/models/#{a}.rb", "\n has_many :#{model_pluralize}, :dependent => :nullify", :after => "ApplicationRecord")
165
+ inject_into_file("app/models/#{engine_name}#{a}.rb", "\n has_many :#{model_pluralize}, :dependent => :nullify", :after => "ApplicationRecord")
153
166
  rescue
154
167
  end
155
168
  end
@@ -157,22 +170,26 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
157
170
  end
158
171
 
159
172
  def generate_controller
160
- copy_file "app/controllers/master_base.rb", "app/controllers/beautiful_controller.rb"
161
- dirs = ['app', 'controllers', options[:namespace]].compact
173
+ copy_file "app/controllers/master_base.rb", "app/controllers/#{engine_name}beautiful_controller.rb"
174
+ dirs = ['app', 'controllers', engine_name, options[:namespace]].compact
162
175
  # Avoid to remove app/controllers directory (https://github.com/rivsc/Beautiful-Scaffold/issues/6)
163
176
  empty_directory File.join(dirs) if not options[:namespace].blank?
164
- template "app/controllers/base.rb", File.join([dirs, "#{model_pluralize}_controller.rb"].flatten)
177
+ dest_ctrl_file = File.join([dirs, "#{model_pluralize}_controller.rb"].flatten)
178
+ template "app/controllers/base.rb", dest_ctrl_file
165
179
  end
166
180
 
167
181
  def generate_helper
168
- copy_file "app/helpers/beautiful_helper.rb", "app/helpers/beautiful_helper.rb"
169
- dirs = ['app', 'helpers', options[:namespace]].compact
182
+ dest_bs_helper_file = "app/helpers/#{engine_name}beautiful_helper.rb"
183
+ template "app/helpers/beautiful_helper.rb", dest_bs_helper_file
184
+
185
+ dirs = ['app', 'helpers', engine_name, options[:namespace]].compact
170
186
  empty_directory File.join(dirs)
171
- template "app/helpers/model_helper.rb", File.join([dirs, "#{model_pluralize}_helper.rb"].flatten)
187
+ dest_helper_file = File.join([dirs, "#{model_pluralize}_helper.rb"].flatten)
188
+ template "app/helpers/model_helper.rb", dest_helper_file
172
189
  end
173
190
 
174
191
  def generate_views
175
- namespacedirs = ["app", "views", options[:namespace]].compact
192
+ namespacedirs = ["app", "views", engine_name, options[:namespace]].compact
176
193
  empty_directory File.join(namespacedirs)
177
194
 
178
195
  dirs = [namespacedirs, model_pluralize]
@@ -189,6 +206,10 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
189
206
  copy_file "app/views/_form_habtm_tag.html.erb", "app/views/layouts/_form_habtm_tag.html.erb"
190
207
  end
191
208
 
209
+ def install_ransack_intializer
210
+ copy_file "app/initializers/ransack.rb", "config/initializers/ransack.rb"
211
+ end
212
+
192
213
  def install_willpaginate_renderer_for_bootstrap
193
214
  copy_file "app/initializers/link_renderer.rb", "config/initializers/link_renderer.rb"
194
215
  end
@@ -5,8 +5,9 @@
5
5
  //= require turbolinks
6
6
  //= require a-wysihtml5-0.3.0.min
7
7
  //= require bootstrap-colorpicker
8
- //= require bootstrap-datepicker
9
- //= require bootstrap-timepicker
8
+ //= require moment
9
+ //= require moment/fr
10
+ //= require bootstrap-datetimepicker
10
11
  //= require bootstrap-datetimepicker-for-beautiful-scaffold
11
12
  //= require bootstrap-wysihtml5
12
13
  //= require jquery.jstree
@@ -128,7 +128,7 @@ function bs_init(){
128
128
  // Collapse without IDS (next)
129
129
  $('body').on('click.collapse-next.data-api', '[data-toggle=collapse-next]', function() {
130
130
  var $target = $(this).parent().next();
131
- $target.data('collapse') ? $target.collapse('toggle') : $target.collapse()
131
+ $target.collapse('toggle');
132
132
  return false;
133
133
  });
134
134
 
@@ -149,4 +149,40 @@ function bs_init(){
149
149
  }catch (e){
150
150
  }
151
151
 
152
+ // Toggle display Search
153
+ $(document).on('click','#hide-search-btn',function(){
154
+ $('div.index-main div.col-md-9').addClass('col-md-12');
155
+ $('div.index-main div.col-md-12').removeClass('col-md-9');
156
+ $('div.index-main div.col-md-3').hide();
157
+ $('#hide-search-btn').hide();
158
+ $('#show-search-btn').show();
159
+ });
160
+ $(document).on('click','#show-search-btn',function(){
161
+ $('div.index-main div.col-md-12').addClass('col-md-9');
162
+ $('div.index-main div.col-md-9').removeClass('col-md-12');
163
+ $('div.index-main div.col-md-3').show();
164
+ $('#hide-search-btn').show();
165
+ $('#show-search-btn').hide();
166
+ });
167
+
168
+ // Toggle display Menu
169
+ $(document).on('click','#hide-menu-btn',function(){
170
+ $('body div.fixed').addClass('hide-menu');
171
+ $('body div.filler').addClass('hide-menu');
172
+ $('body div.fixed').removeClass('show-menu');
173
+ $('body div.filler').removeClass('show-menu');
174
+
175
+ $('#hide-menu-btn').hide();
176
+ $('#show-menu-btn').show();
177
+ });
178
+ $(document).on('click','#show-menu-btn',function(){
179
+ $('body div.fixed').addClass('show-menu');
180
+ $('body div.filler').addClass('show-menu');
181
+ $('body div.fixed').removeClass('hide-menu');
182
+ $('body div.filler').removeClass('hide-menu');
183
+
184
+ $('#hide-menu-btn').show();
185
+ $('#show-menu-btn').hide();
186
+ });
187
+
152
188
  }
@@ -1,48 +1,27 @@
1
1
  function datetimepicker_init(){
2
- $(document).on('click', '.dpicker', function(e){
3
- e.stopPropagation();
4
- e.stopImmediatePropagation();
5
- $(this).datepicker({ format : 'dd/mm/yyyy', language : $('html').attr("lang") }).on('changeDate', function(ev){
6
- var eltid = ev.currentTarget.id;
7
- //eltid = $('#' + ev.currentTarget.id).data('id');
8
- $('#' + eltid + '_3i').val(ev.date.getDate()); // Day
9
- $('#' + eltid + '_2i').val(ev.date.getMonth()+1); // Month
10
- $('#' + eltid + '_1i').val(ev.date.getFullYear()); // Year
11
- });
12
- $(this).change(function(){
13
- if( !$(this).val() ){
14
- id = '#' + $(this).data('id');
15
- $(id + '_3i').val("");
16
- $(id + '_2i').val("");
17
- $(id + '_1i').val("");
18
- }
19
- });
20
- $(this).trigger('focus');
21
- $(this).trigger('select');
2
+ $(document).on('click', '.dpicker', function(e){
3
+ e.stopPropagation();
4
+ e.stopImmediatePropagation();
5
+ $(this).datetimepicker({ format : 'DD/MM/YYYY', locale : 'en' }).on('dp.change', function(elt){
6
+ var eltid = elt.currentTarget.dataset.id;
7
+ $('#' + eltid + '_3i').val(elt.date.date());
8
+ $('#' + eltid + '_2i').val(elt.date.month()+1);
9
+ $('#' + eltid + '_1i').val(elt.date.year());
22
10
  });
23
- $(document).on('click', '.input-group-addon', function(){
24
- try{
25
- dpick = $(this).parent().find('.dpicker');
26
- dpick.trigger('focus');
27
- dpick.trigger('select');
28
- }catch (e){
29
- }
30
- });
31
- $(document).on('click', '.tpicker', function(){
32
- $(this).timepicker({ template: 'modal', showMeridian: false, minuteStep: 1, defaultTime: false, showInputs: false, disableFocus: true }).on('change', function(ev){
33
- tpickerdate = new Date("01/01/1970 " + ev.currentTarget.value);
34
- var eltid = ev.currentTarget.id;
35
- //eltid = $('#' + ev.currentTarget.id).data('id');
36
- $('#' + eltid + '_4i').val(tpickerdate.getHours()); // Hour
37
- $('#' + eltid + '_5i').val(tpickerdate.getMinutes()); // Min
38
- });
39
- $(this).change(function(){
40
- if( !$(this).val() ){
41
- id = '#' + $(this).data('id');
42
- $(id + '_4i').val("");
43
- $(id + '_5i').val("");
44
- }
45
- });
46
- $(this).click();
11
+ $(this).trigger('focus');
12
+ $(this).trigger('select');
13
+ return false;
14
+ });
15
+ $(document).on('click', '.tpicker', function(e){
16
+ e.stopPropagation();
17
+ e.stopImmediatePropagation();
18
+ $(this).datetimepicker({ format : 'HH:mm', locale : 'en' }).on('dp.change', function(elt){
19
+ var eltid = elt.currentTarget.dataset.id;
20
+ $('#' + eltid + '_4i').val(elt.date.hour());
21
+ $('#' + eltid + '_5i').val(elt.date.minute());
47
22
  });
23
+ $(this).trigger('focus');
24
+ $(this).trigger('select');
25
+ return false;
26
+ });
48
27
  }
@@ -11,8 +11,7 @@
11
11
  *= require_self
12
12
  *= require reset
13
13
  *= require jquery-ui
14
- *= require datepicker
15
- *= require timepicker
14
+ *= require bootstrap-datetimepicker
16
15
  *= require beautiful-scaffold
17
16
  *= require tagit-dark-grey
18
17
  *= require colorpicker
@@ -55,7 +55,7 @@ $shadow-spinner:#0060CC;
55
55
  height:30px;
56
56
  margin:0 auto;
57
57
  position:relative;
58
- top:-50px;
58
+ top:-40px;
59
59
  -moz-animation:spinoffPulse 1s infinite linear;
60
60
  -webkit-animation:spinoffPulse 1s infinite linear;
61
61
  }
@@ -166,4 +166,28 @@ html, body {
166
166
  }
167
167
  .search-and-filter h3{
168
168
  margin-top:0;
169
+ }
170
+
171
+ #modal-columns div.modal-body label{
172
+ display: inline-block;
173
+ margin-top: 0px;
174
+ margin-bottom: 0px;
175
+ margin-left: 20px;
176
+ }
177
+ .search-and-filter .form-group label{
178
+ margin-bottom: 0;
179
+ margin-top: 5px;
180
+ }
181
+
182
+ div.filler.show-menu{
183
+ margin-left: 200px;
184
+ }
185
+ div.fixed.show-menu{
186
+ display: block;
187
+ }
188
+ div.filler.hide-menu{
189
+ margin-left: 0;
190
+ }
191
+ div.fixed.hide-menu{
192
+ display: none !important;
169
193
  }
@@ -1,4 +1,14 @@
1
1
  # encoding : utf-8
2
+ <%
3
+ if !engine_name.blank?
4
+ b_module = "module #{engine_camel}"
5
+ e_module = "end"
6
+ else
7
+ b_module = ""
8
+ e_module = ""
9
+ end
10
+ %>
11
+ <%= b_module %>
2
12
  class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < BeautifulController
3
13
 
4
14
  before_action :load_<%= model %>, :only => [:show, :edit, :update, :destroy]
@@ -7,12 +17,12 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
7
17
  #authorize_resource
8
18
 
9
19
  def index
10
- session[:fields] ||= {}
11
- session[:fields]["<%= model %>"] ||= (<%= model_camelize %>.columns.map(&:name) - ["id"])[0..4]
12
- do_select_fields("<%= model %>")
13
- do_sort_and_paginate("<%= model %>")
20
+ session['fields'] ||= {}
21
+ session['fields']['<%= model %>'] ||= (<%= model_camelize %>.columns.map(&:name) - ["id"])[0..4]
22
+ do_select_fields('<%= model %>')
23
+ do_sort_and_paginate('<%= model %>')
14
24
 
15
- @q = <%= model_camelize %>.search(
25
+ @q = <%= model_camelize %>.ransack(
16
26
  params[:q]
17
27
  )
18
28
 
@@ -142,7 +152,7 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
142
152
  # Selected with filter and search
143
153
  do_sort_and_paginate(:<%= model %>)
144
154
 
145
- @<%= model_pluralize %> = <%= model_camelize %>.search(
155
+ @<%= model_pluralize %> = <%= model_camelize %>.ransack(
146
156
  params[:q]
147
157
  ).result(
148
158
  :distinct => true
@@ -192,4 +202,4 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
192
202
  params.require(:<%= model %>).permit(<%= model_camelize %>.permitted_attributes)
193
203
  end
194
204
  end
195
-
205
+ <%= e_module %>