beautiful_scaffold 0.3.1 → 0.3.2

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.2
2
+
3
+ * bugfix
4
+ * Don't try to translate EN to EN (beautiful_locale)
5
+ * rails destroy beautiful_scaffold don't remove app/controllers directory
6
+
7
+ * enhancement
8
+ * Add error class to control-group (bootstrap + rails validates)
9
+ * :data => { :confirm => "" } replace :confirm => "" (Rails 4 deprecation warning)
10
+ * activerelation.all -> .to_a (rails 4)
11
+
1
12
  == 0.3.1
2
13
 
3
14
  * enhancement
data/README.rdoc CHANGED
@@ -15,7 +15,7 @@ gem 'beautiful_scaffold', '0.2.7'
15
15
  === RubyOnRails 4.X
16
16
 
17
17
  Add this in your Gemfile :
18
- gem 'beautiful_scaffold', '0.3.1'
18
+ gem 'beautiful_scaffold', '~>0.3'
19
19
 
20
20
  === Next
21
21
 
@@ -53,6 +53,7 @@ rails g beautiful_migration AddFieldToModels field:type
53
53
  Run rake db:migrate before rail g beautiful_locale (to get lastest attribute translation)
54
54
 
55
55
  rails g beautiful_locale all
56
+ rails g beautiful_locale en
56
57
  rails g beautiful_locale fr
57
58
  rails g beautiful_locale de
58
59
 
@@ -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.1"
6
+ s.version = "0.3.2"
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"
@@ -128,12 +128,16 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
128
128
  def translate_string(locale, str)
129
129
  # See http://www.microsofttranslator.com/dev/
130
130
  #
131
- url_domain = "mymemory.translated.net"
132
- url_translate = "/api/get?q=to_translate&langpair=en%7C#{locale}"
131
+ if locale == "en" then
132
+ attr_translate = "#{str.gsub(/_/, " ")}"
133
+ else
134
+ url_domain = "mymemory.translated.net"
135
+ url_translate = "/api/get?q=to_translate&langpair=en%7C#{locale}"
133
136
 
134
- urlstr = url_translate.gsub(/to_translate/, str.gsub(/_/, "%20"))
135
- json = JSON.parse(Net::HTTP.get(url_domain, urlstr))
136
- attr_translate = json["responseData"]["translatedText"].strip.downcase
137
+ urlstr = url_translate.gsub(/to_translate/, str.gsub(/_/, "%20"))
138
+ json = JSON.parse(Net::HTTP.get(url_domain, urlstr))
139
+ attr_translate = json["responseData"]["translatedText"].strip.downcase
140
+ end
137
141
  raise 'Free Limit' if attr_translate =~ /mymemory/
138
142
 
139
143
  return attr_translate
@@ -174,7 +174,8 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
174
174
  def generate_controller
175
175
  copy_file "app/controllers/master_base.rb", "app/controllers/beautiful_controller.rb"
176
176
  dirs = ['app', 'controllers', options[:namespace]].compact
177
- empty_directory File.join(dirs)
177
+ # Avoid to remove app/controllers directory (https://github.com/rivsc/Beautiful-Scaffold/issues/6)
178
+ empty_directory File.join(dirs) if not options[:namespace].blank?
178
179
  template "app/controllers/base.rb", File.join([dirs, "#{model_pluralize}_controller.rb"].flatten)
179
180
  end
180
181
 
@@ -154,6 +154,10 @@ function bs_init(){
154
154
  return false;
155
155
  });
156
156
 
157
+ // Add Error Form style with bootstrap
158
+ $("div.control-group>div.field_with_errors").parent().addClass("error");
159
+ $("#error_explanation").addClass("text-error");
160
+
157
161
  // Mass inserting set focus
158
162
  elt = $('form.mass-inserting div[style*="inline"][class*="col"] .input-small').first();
159
163
  if($('form.mass-inserting').hasClass('setfocus')){
@@ -31,27 +31,27 @@ class <%= namespace_for_class %><%= model_camelize.pluralize %>Controller < Beau
31
31
  @<%= model_pluralize %> = @<%= model %>_scope.paginate(
32
32
  :page => params[:page],
33
33
  :per_page => 20
34
- ).all
34
+ ).to_a
35
35
 
36
36
  respond_to do |format|
37
37
  format.html{
38
38
  render
39
39
  }
40
40
  format.json{
41
- render :json => @<%= model %>_scope.all
41
+ render :json => @<%= model %>_scope.to_a
42
42
  }
43
43
  format.csv{
44
44
  require 'csv'
45
45
  csvstr = CSV.generate do |csv|
46
46
  csv << <%= model_camelize %>.attribute_names
47
- @<%= model %>_scope.all.each{ |o|
47
+ @<%= model %>_scope.to_a.each{ |o|
48
48
  csv << <%= model_camelize %>.attribute_names.map{ |a| o[a] }
49
49
  }
50
50
  end
51
51
  render :text => csvstr
52
52
  }
53
53
  format.xml{
54
- render :xml => @<%= model %>_scope.all
54
+ render :xml => @<%= model %>_scope.to_a
55
55
  }
56
56
  format.pdf{
57
57
  pdfcontent = PdfReport.new.to_pdf(<%= model_camelize %>,@<%= model %>_scope)
@@ -68,7 +68,7 @@ class BeautifulController < ApplicationController
68
68
  if modelclass.column_names.include?("position") then
69
69
  new_pos = 0
70
70
  modelclass.transaction do
71
- all_elt = modelclass.where(foreignkey => parent_id).order("position ASC").all
71
+ all_elt = modelclass.where(foreignkey => parent_id).order("position ASC").to_a
72
72
 
73
73
  begin
74
74
  if index == all_elt.length then
@@ -77,7 +77,7 @@
77
77
  </td>
78
78
  <td><%%= link_to '<i class="icon-search"></i>'.html_safe, <%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>), :title => t(:show, :default => "Show") %></td>
79
79
  <td><%%= link_to '<i class="icon-pencil"></i>'.html_safe, edit_<%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>), :title => t(:edit, :default => "Edit") %></td>
80
- <td><%%= link_to '<i class="icon-remove"></i>'.html_safe, <%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>), :confirm => t(:are_you_sure, :default => "Are you sure?"), :method => :delete, :title => t(:destroy, :default => "Destroy") %></td>
80
+ <td><%%= link_to '<i class="icon-remove"></i>'.html_safe, <%= namespace_for_route %><%= singular_table_name %>_path(<%= singular_table_name %>), :data => { :confirm => t(:are_you_sure, :default => "Are you sure?") }, :method => :delete, :title => t(:destroy, :default => "Destroy") %></td>
81
81
  </tr>
82
82
  <%% end %>
83
83
  </tbody>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-24 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Beautiful Scaffold generate a complete scaffold (sort, export, paginate
15
15
  and filter data) http://www.beautiful-scaffold.com