beautiful_scaffold 0.3.4 → 0.3.5

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/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ == 0.3.5
2
+
3
+ * enhancement
4
+ * Option to avoid to add bad gem for the rails app.
5
+ * Add concern to models
6
+ * Add concern for the routes
7
+
8
+ * bugfix
9
+ * Change symbol into string (access session)
10
+ * Table Checkbox (All checkbox bugfix)
11
+
1
12
  == 0.3.4
2
13
 
3
14
  * bugfix
data/README.rdoc CHANGED
@@ -7,15 +7,15 @@ Demo : http://demo.beautiful-scaffold.com/
7
7
 
8
8
  == Install
9
9
 
10
- === RubyOnRails 3.X
10
+ === RubyOnRails 4.1
11
11
 
12
12
  Add this in your Gemfile :
13
- gem 'beautiful_scaffold', '0.2.7'
13
+ gem 'beautiful_scaffold', '0.3.4'
14
14
 
15
- === RubyOnRails 4.X
15
+ === RubyOnRails 4.2
16
16
 
17
17
  Add this in your Gemfile :
18
- gem 'beautiful_scaffold', '~>0.3'
18
+ gem 'beautiful_scaffold', '0.3.5'
19
19
 
20
20
  === Next
21
21
 
@@ -26,7 +26,7 @@ bundle install
26
26
 
27
27
  === Scaffold
28
28
 
29
- rails generate beautiful_scaffold model attr:type attr:type... [--namespace=name]
29
+ rails generate beautiful_scaffold model attr:type attr:type... [--namespace=name] [--donttouchgem=name]
30
30
 
31
31
  type available :
32
32
  * integer
@@ -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 = "0.3.4"
6
+ s.version = "0.3.5"
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"
@@ -9,10 +9,14 @@ class BeautifulMigrationGenerator < Rails::Generators::Base
9
9
 
10
10
  argument :name, :type => :string, :desc => "Name of the migration CamelCase AddXxxToYyy (Yyy must be plural)"
11
11
  argument :myattributes, :type => :array, :default => [], :banner => "field:type field:type (for bt relation model:references)"
12
+
12
13
  class_option :namespace, :default => nil
14
+ class_option :donttouchgem, :default => nil
13
15
 
14
16
  def install_gems
15
- require_gems
17
+ if options[:donttouchgem].blank? then
18
+ require_gems
19
+ end
16
20
  end
17
21
 
18
22
  def add_field_for_fulltext
@@ -156,12 +156,10 @@ module BeautifulScaffoldCommonMethods
156
156
  end
157
157
 
158
158
  def require_gems
159
- # for jquery-ui add "2.3.0" version for jquery-rails
160
- #say_status("Warning", "Set 2.0.1 version for jquery-rails (for a good compatibility with beautiful_scaffold)", :yellow)
161
159
 
162
160
  gem('less-rails', :github => "CQQL/less-rails", :branch => 'less-2.5')
163
161
  gem('will_paginate')
164
- gem('ransack', :github => 'activerecord-hackery/ransack', :branch => 'rails-4.1')
162
+ gem('ransack', :github => 'activerecord-hackery/ransack', :branch => 'rails-4.2')
165
163
  gem('polyamorous', :github => 'activerecord-hackery/polyamorous')
166
164
  gem('jquery-ui-rails')
167
165
  gem('prawn', '1.0.0')
@@ -17,9 +17,13 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
17
17
  argument :myattributes, :type => :array, :default => [], :banner => "field:type field:type"
18
18
 
19
19
  class_option :namespace, :default => nil
20
+ class_option :donttouchgem, :default => nil
20
21
 
21
22
  def install_gems
22
- require_gems
23
+ if options[:donttouchgem].blank? then
24
+ require_gems
25
+ end
26
+
23
27
  #inside Rails.root do # Bug ?!
24
28
  Bundler.with_clean_env do
25
29
  run "bundle install"
@@ -127,38 +131,23 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
127
131
 
128
132
  def generate_model
129
133
  generate("model", "#{model} #{beautiful_attr_to_rails_attr.join(' ')} #{@fulltext_field.join(' ')}")
130
-
131
- inject_into_file("app/models/#{model}.rb",'
132
- scope :sorting, lambda{ |options|
133
- attribute = options[:attribute]
134
- direction = options[:sorting]
135
134
 
136
- attribute ||= "id"
137
- direction ||= "DESC"
135
+ directory "app/models/concerns", "app/models/concerns"
138
136
 
139
- order("#{attribute} #{direction}")
140
- }
141
-
142
- include BeautifulScaffoldModule
143
- before_save :fulltext_field_processing
137
+ inject_into_file("app/models/#{model}.rb",'
144
138
 
145
- # You can OVERRIDE this method used in model form and search form (in belongs_to relation)
146
- def caption
147
- (self["name"] || self["label"] || self["description"] || "##{id}")
148
- end
139
+ include DefaultSortingConcern
140
+ include FulltextConcern
141
+ include CaptionConcern
149
142
 
150
- def fulltext_field_processing
151
- # You can preparse with own things here
152
- generate_fulltext_field([' + fulltext_attribute.map{ |e| ('"' + e + '"') }.join(",") + '])
143
+ cattr_accessor :fulltext_fields do
144
+ [' + fulltext_attribute.map{ |e| ('"' + e + '"') }.join(",") + ']
153
145
  end
154
146
 
155
147
  def self.permitted_attributes
156
148
  return ' + attributes_without_type.map{ |attr| ":#{attr}" }.join(",") + '
157
149
  end', :after => "class #{model_camelize} < ActiveRecord::Base")
158
150
 
159
- inject_into_file("config/application.rb", ' config.autoload_paths += %W(#{config.root}/app/modules)' + "\n", :after => "< Rails::Application\n")
160
-
161
- directory "modules", "app/modules"
162
151
  copy_file "app/models/pdf_report.rb", "app/models/pdf_report.rb"
163
152
  end
164
153
 
@@ -216,18 +205,36 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
216
205
  routes_in_text = File.read("config/routes.rb")
217
206
 
218
207
  if not routes_in_text[/beautiful#dashboard/] and not routes_in_text[/beautiful#select_fields/] then
219
- myroute = "root :to => 'beautiful#dashboard'\n"
220
- myroute += " match ':model_sym/select_fields' => 'beautiful#select_fields', :via => [:get, :post]\n"
208
+
209
+ myroute = <<EOF
210
+ root :to => 'beautiful#dashboard'
211
+ match ':model_sym/select_fields' => 'beautiful#select_fields', :via => [:get, :post]
212
+
213
+ concern :bs_routes do
214
+ collection do
215
+ post :batch
216
+ get :treeview
217
+ match :search_and_filter, :action => :index, :as => :search, :via => [:get, :post]
218
+ end
219
+ member do
220
+ post :treeview_update
221
+ end
222
+ end
223
+
224
+ # Add route with concerns: :bs_routes here # Do not remove
225
+ EOF
226
+
221
227
  route(myroute)
222
228
  end
223
229
 
224
230
  search_namespace = namespace_alone + "/" if not namespace_alone.blank?
225
231
  search_namespace ||= ""
226
232
 
227
- myroute = 'match "' + search_namespace + model_pluralize + '/search_and_filter" => "' + search_namespace + model_pluralize + '#index", :via => [:get, :post], :as => :' + namespace_for_route + 'search_' + model_pluralize + "\n "
228
- myroute += "namespace :#{namespace_alone} do\n " if not namespace_alone.blank?
229
- myroute += "resources :#{model_pluralize} do\n collection do\n post :batch\n get :treeview\n end\n member do\n post :treeview_update\n end\n end\n"
230
- myroute += "end\n" if not namespace_alone.blank?
231
- route(myroute)
233
+ myroute = "\n "
234
+ myroute += "namespace :#{namespace_alone} do\n " if not namespace_alone.blank?
235
+ myroute += "resources :#{model_pluralize}, concerns: :bs_routes\n "
236
+ myroute += "end\n" if not namespace_alone.blank?
237
+
238
+ inject_into_file("config/routes.rb", myroute, :after => ":bs_routes here # Do not remove")
232
239
  end
233
240
  end
@@ -1,5 +1,5 @@
1
1
  //= require jquery
2
- //= require jquery.ui.all
2
+ //= require jquery-ui
3
3
  //= require jquery_ujs
4
4
  //= require twitter/bootstrap
5
5
  //= require jquery.livequery
@@ -70,7 +70,7 @@ function bs_init(){
70
70
 
71
71
  // Processing
72
72
  $(document).on('click', '#checkall', function(){
73
- $('.cbbatch').attr('checked', ($(this).attr('checked') != undefined));
73
+ $('.cbbatch').prop('checked', this.checked);
74
74
  });
75
75
 
76
76
  // Filter columns
@@ -10,7 +10,7 @@
10
10
  *
11
11
  *= require_self
12
12
  *= require reset
13
- *= require jquery.ui.all
13
+ *= require jquery-ui
14
14
  *= require datepicker
15
15
  *= require timepicker
16
16
  *= require beautiful-scaffold
@@ -0,0 +1,8 @@
1
+ module CaptionConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ # You can OVERRIDE this method used in model form and search form (in belongs_to relation)
5
+ def caption
6
+ (self["name"] || self["label"] || self["description"] || "##{id}")
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module DefaultSortingConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ scope :sorting, lambda{ |options|
6
+ attribute = options[:attribute]
7
+ direction = options[:sorting]
8
+
9
+ attribute ||= "id"
10
+ direction ||= "DESC"
11
+
12
+ order("#{attribute} #{direction}")
13
+ }
14
+ end
15
+ end
@@ -1,11 +1,33 @@
1
- module BeautifulScaffoldModule
2
- def generate_fulltext_field(fields)
1
+ module FulltextConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ #########################
6
+ #
7
+ # Scopes
8
+ # Relations
9
+ # Filter
10
+ #...
11
+ #########################
12
+ before_save :fulltext_field_processing
13
+ end
14
+
15
+ #########################
16
+ # Méthode d'instance
17
+ #########################
18
+ def fulltext_field_processing
19
+ # You can preparse with own things here
20
+ generate_fulltext_field
21
+ end
22
+
23
+ def generate_fulltext_field
24
+ fields = (self.class.fulltext_fields || [])
3
25
  fields.each{ |f|
4
26
  html, clear = htmlize(self[f], self[f + '_typetext'])
5
27
  self[f + '_fulltext'] = clear
6
28
  }
7
29
  end
8
-
30
+
9
31
  def htmlize(text, type)
10
32
  case type
11
33
  when 'bbcode' then
@@ -25,4 +47,10 @@ module BeautifulScaffoldModule
25
47
  end
26
48
  return html, Sanitize.clean(html)
27
49
  end
28
- end
50
+
51
+ class_methods do
52
+ #########################
53
+ # Méthode de Class
54
+ #########################
55
+ end
56
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sylvain Claudel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-10-22 00:00:00 Z
18
+ date: 2015-03-20 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Beautiful Scaffold generate a complete scaffold (sort, export, paginate and filter data) http://www.beautiful-scaffold.com
@@ -79,6 +79,9 @@ files:
79
79
  - lib/generators/templates/app/initializers/link_renderer.rb
80
80
  - lib/generators/templates/app/locales/beautiful_scaffold.en.yml
81
81
  - lib/generators/templates/app/locales/beautiful_scaffold.fr.yml
82
+ - lib/generators/templates/app/models/concerns/caption_concern.rb
83
+ - lib/generators/templates/app/models/concerns/default_sorting_concern.rb
84
+ - lib/generators/templates/app/models/concerns/fulltext_concern.rb
82
85
  - lib/generators/templates/app/models/pdf_report.rb
83
86
  - lib/generators/templates/app/views/_beautiful_menu.html.erb
84
87
  - lib/generators/templates/app/views/_form.html.erb
@@ -233,7 +236,6 @@ files:
233
236
  - lib/generators/templates/markitup/skins/simple/style.css
234
237
  - lib/generators/templates/markitup/templates/preview.css
235
238
  - lib/generators/templates/markitup/templates/preview.html
236
- - lib/generators/templates/modules/beautiful_scaffold_module.rb
237
239
  homepage: http://beautiful-scaffold.com
238
240
  licenses: []
239
241
 
@@ -264,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
266
  requirements: []
265
267
 
266
268
  rubyforge_project: beautiful_scaffold
267
- rubygems_version: 1.8.24
269
+ rubygems_version: 1.8.25
268
270
  signing_key:
269
271
  specification_version: 3
270
272
  summary: Beautiful Scaffold generate fully customizable scaffold