typus 3.1.0.rc4 → 3.1.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Gemfile +2 -0
  2. data/app/assets/images/{typus/blank.gif → blank.gif} +0 -0
  3. data/app/assets/images/{typus/fancy_close.png → fancy_close.png} +0 -0
  4. data/app/assets/images/{typus/fancy_loading.png → fancy_loading.png} +0 -0
  5. data/app/assets/images/{typus/fancy_nav_left.png → fancy_nav_left.png} +0 -0
  6. data/app/assets/images/{typus/fancy_nav_right.png → fancy_nav_right.png} +0 -0
  7. data/app/assets/images/{typus/fancy_shadow_e.png → fancy_shadow_e.png} +0 -0
  8. data/app/assets/images/{typus/fancy_shadow_n.png → fancy_shadow_n.png} +0 -0
  9. data/app/assets/images/{typus/fancy_shadow_ne.png → fancy_shadow_ne.png} +0 -0
  10. data/app/assets/images/{typus/fancy_shadow_nw.png → fancy_shadow_nw.png} +0 -0
  11. data/app/assets/images/{typus/fancy_shadow_s.png → fancy_shadow_s.png} +0 -0
  12. data/app/assets/images/{typus/fancy_shadow_se.png → fancy_shadow_se.png} +0 -0
  13. data/app/assets/images/{typus/fancy_shadow_sw.png → fancy_shadow_sw.png} +0 -0
  14. data/app/assets/images/{typus/fancy_shadow_w.png → fancy_shadow_w.png} +0 -0
  15. data/app/assets/images/{typus/fancy_title_left.png → fancy_title_left.png} +0 -0
  16. data/app/assets/images/{typus/fancy_title_main.png → fancy_title_main.png} +0 -0
  17. data/app/assets/images/{typus/fancy_title_over.png → fancy_title_over.png} +0 -0
  18. data/app/assets/images/{typus/fancy_title_right.png → fancy_title_right.png} +0 -0
  19. data/app/assets/images/{typus/fancybox-x.png → fancybox-x.png} +0 -0
  20. data/app/assets/images/{typus/fancybox-y.png → fancybox-y.png} +0 -0
  21. data/app/assets/images/{typus/fancybox.png → fancybox.png} +0 -0
  22. data/app/assets/javascripts/typus.js +7 -0
  23. data/app/assets/javascripts/typus/application.js +3 -7
  24. data/app/assets/stylesheets/typus.css +7 -0
  25. data/app/assets/stylesheets/typus/application.css +11 -6
  26. data/app/controllers/admin/resources_controller.rb +6 -1
  27. data/app/helpers/admin/filters_helper.rb +1 -5
  28. data/app/helpers/admin/form_helper.rb +14 -12
  29. data/app/helpers/admin/relationships_helper.rb +15 -13
  30. data/app/helpers/admin/resources_helper.rb +2 -3
  31. data/app/helpers/admin/sidebar_helper.rb +2 -2
  32. data/app/helpers/admin/table_helper.rb +10 -14
  33. data/app/views/admin/base/user_guide.html.erb +1 -1
  34. data/app/views/admin/resources/index.html.erb +1 -1
  35. data/app/views/admin/resources/new.html.erb +1 -1
  36. data/app/views/admin/shared/_head.html.erb +2 -2
  37. data/app/views/admin/templates/_selector.html.erb +1 -7
  38. data/config/locales/typus.ca.models.yml +8 -8
  39. data/config/locales/typus.ca.yml +1 -2
  40. data/config/locales/typus.de.yml +1 -2
  41. data/config/locales/typus.el.yml +1 -2
  42. data/config/locales/typus.es.yml +1 -2
  43. data/config/locales/typus.fr.yml +1 -2
  44. data/config/locales/typus.hu.yml +1 -2
  45. data/config/locales/typus.it.yml +1 -2
  46. data/config/locales/typus.locale.yml.template +1 -2
  47. data/config/locales/typus.pt-BR.yml +1 -2
  48. data/config/locales/typus.ru.yml +1 -2
  49. data/config/locales/typus.zh-CN.yml +1 -2
  50. data/lib/generators/templates/config/initializers/typus_authentication.rb +2 -2
  51. data/lib/generators/typus/migration_generator.rb +1 -1
  52. data/lib/support/active_record.rb +1 -5
  53. data/lib/typus.rb +2 -2
  54. data/lib/typus/authentication/session.rb +5 -5
  55. data/lib/typus/controller/headless.rb +1 -1
  56. data/lib/typus/controller/trash.rb +2 -1
  57. data/lib/typus/orm/active_record/user/instance_methods.rb +1 -1
  58. data/lib/typus/orm/base.rb +1 -1
  59. data/lib/typus/version.rb +1 -1
  60. data/test/app/controllers/admin/posts_controller_test.rb +4 -4
  61. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +1 -1
  62. data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +3 -0
  63. data/test/fixtures/rails_app/app/models/entry.rb +12 -0
  64. data/test/fixtures/rails_app/app/models/post.rb +20 -12
  65. data/test/fixtures/rails_app/db/schema.rb +1 -0
  66. data/test/lib/support/active_record_test.rb +46 -108
  67. data/test/lib/typus_test.rb +4 -4
  68. data/typus.gemspec +2 -1
  69. metadata +41 -30
  70. data/app/assets/javascripts/typus/custom.js +0 -2
  71. data/app/assets/stylesheets/typus/custom.css +0 -11
data/Gemfile CHANGED
@@ -4,11 +4,13 @@ source 'http://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'sqlite3'
7
+ gem 'jquery-rails'
7
8
 
8
9
  # And this stuff needed for the demo application.
9
10
  gem 'acts_as_list'
10
11
  gem 'acts_as_tree'
11
12
  gem 'factory_girl'
13
+ gem "rails-trash"
12
14
 
13
15
  # Asset Management
14
16
  gem "dragonfly", "~> 0.9"
@@ -0,0 +1,7 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require_tree ../vendor
4
+ //= require typus/jquery.application
5
+ //= require typus/jquery.rails.autocomplete
6
+ //= require typus/jquery.searchField
7
+ //= require typus/application
@@ -1,7 +1,3 @@
1
- //= require jquery
2
- //= require jquery_ujs
3
- //= require_tree ../../vendor
4
- //= require typus/jquery.application
5
- //= require typus/jquery.rails.autocomplete
6
- //= require typus/jquery.searchField
7
- //= require typus/custom
1
+
2
+ // Create the file `app/assets/javascripts/typus/application.js` in your
3
+ // application if you need/want to extend some javascript functionality.
@@ -0,0 +1,7 @@
1
+ /*
2
+ *= require typus/reset
3
+ *= require typus/screen
4
+ *= require typus/pagination
5
+ *= require_tree ../vendor
6
+ *= require typus/application
7
+ */
@@ -1,7 +1,12 @@
1
+
2
+ /* Create the file `app/assets/stylesheets/typus/application.css` in your
3
+ application if you need/want to override/add some stylesheets. */
4
+
1
5
  /*
2
- *= require typus/reset
3
- *= require typus/screen
4
- *= require typus/pagination
5
- *= require_tree ../../vendor
6
- *= require typus/custom
7
- */
6
+ .logo {
7
+ height: 50px;
8
+ width: 150px;
9
+ background: transparent url(/images/logo.gif) no-repeat;
10
+ text-indent: -10000px;
11
+ }
12
+ */
@@ -128,10 +128,15 @@ class Admin::ResourcesController < Admin::BaseController
128
128
  private
129
129
 
130
130
  def get_model
131
- @resource = params[:controller].extract_class
131
+ @resource = resource
132
132
  @object_name = ActiveModel::Naming.singular(@resource)
133
133
  end
134
134
 
135
+ def resource
136
+ params[:controller].extract_class
137
+ end
138
+ helper_method :resource
139
+
135
140
  def set_context
136
141
  @resource
137
142
  end
@@ -79,11 +79,7 @@ module Admin
79
79
  end
80
80
 
81
81
  def string_filter(filter)
82
- values = if set_context.const_defined?(filter.to_s.upcase)
83
- set_context::const_get(filter.to_s.upcase).to_a
84
- else
85
- set_context.send(filter.to_s).to_a
86
- end
82
+ values = set_context.send(filter.to_s).to_a
87
83
 
88
84
  items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
89
85
  array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
@@ -22,11 +22,12 @@ module Admin
22
22
  end
23
23
 
24
24
  def typus_tree_field(attribute, form)
25
- render "admin/templates/tree",
26
- :attribute => attribute,
27
- :form => form,
28
- :label_text => @resource.human_attribute_name(attribute),
29
- :values => expand_tree_into_select_field(@resource.roots, "parent_id")
25
+ locals = { :attribute => attribute,
26
+ :form => form,
27
+ :label_text => @resource.human_attribute_name(attribute),
28
+ :values => expand_tree_into_select_field(@resource.roots, "parent_id") }
29
+
30
+ render "admin/templates/tree", locals
30
31
  end
31
32
 
32
33
  def typus_relationships
@@ -47,13 +48,14 @@ module Admin
47
48
  :disabled => attribute_disabled?(attribute),
48
49
  :include_blank => true }
49
50
 
50
- render "admin/templates/#{template}",
51
- :resource => @resource,
52
- :attribute => attribute,
53
- :options => options,
54
- :html_options => {},
55
- :form => form,
56
- :label_text => @resource.human_attribute_name(attribute)
51
+ locals = { :resource => @resource,
52
+ :attribute => attribute,
53
+ :options => options,
54
+ :html_options => {},
55
+ :form => form,
56
+ :label_text => @resource.human_attribute_name(attribute) }
57
+
58
+ render "admin/templates/#{template}", locals
57
59
  end
58
60
 
59
61
  def attribute_disabled?(attribute)
@@ -36,11 +36,12 @@ module Admin
36
36
  ["Trash", {:resource_id=>@item.id, :resource=>@resource.model_name, :action=>"destroy"}, {:confirm=>"Trash?"}]]
37
37
  end
38
38
 
39
- render "admin/templates/has_n",
40
- :association_name => @association_name,
41
- :add_new => build_add_new(options),
42
- :form => form,
43
- :table => build_relationship_table
39
+ locals = { :association_name => @association_name,
40
+ :add_new => build_add_new(options),
41
+ :form => form,
42
+ :table => build_relationship_table }
43
+
44
+ render "admin/templates/has_n", locals
44
45
  end
45
46
 
46
47
  def typus_form_has_and_belongs_to_many(field)
@@ -63,11 +64,12 @@ module Admin
63
64
  @resource_actions = [["Edit", {:action=>"edit"}, {}],
64
65
  ["Unrelate", {:resource_id=> @item.id, :resource=> @resource.model_name, :action=>"unrelate"}, {:confirm=>"Unrelate?"}]]
65
66
 
66
- render "admin/templates/has_n",
67
- :association_name => @association_name,
68
- :add_new => build_add_new,
69
- :form => form,
70
- :table => build_relationship_table
67
+ locals = { :association_name => @association_name,
68
+ :add_new => build_add_new,
69
+ :form => form,
70
+ :table => build_relationship_table }
71
+
72
+ render "admin/templates/has_n", locals
71
73
  end
72
74
 
73
75
  def build_pagination
@@ -100,7 +102,7 @@ module Admin
100
102
  :resource_id => @item.id }
101
103
 
102
104
  if set_condition && admin_user.can?("create", @model_to_relate)
103
- link_to Typus::I18n.t("Add new"), default_options.merge(options)
105
+ link_to Typus::I18n.t("Add New"), default_options.merge(options)
104
106
  end
105
107
  end
106
108
 
@@ -114,7 +116,7 @@ module Admin
114
116
 
115
117
  def set_conditions
116
118
  if @model_to_relate.typus_options_for(:only_user_items) && admin_user.is_not_root?
117
- { Typus.user_fk => admin_user }
119
+ { Typus.user_foreign_key => admin_user }
118
120
  end
119
121
  end
120
122
 
@@ -155,7 +157,7 @@ module Admin
155
157
  # Pass the resource_id only to edit/update because only there is where
156
158
  # the record actually exists.
157
159
  options.merge!(:resource_id => @item.id) if %w(edit update).include?(params[:action])
158
- message = link_to Typus::I18n.t("Add new"), options
160
+ message = link_to Typus::I18n.t("Add New"), options
159
161
  end
160
162
 
161
163
  # Set the template.
@@ -29,9 +29,8 @@ module Admin
29
29
 
30
30
  body = Typus::I18n.t("Cancel adding a new %{resource}?", :resource => @resource.model_name.human.downcase)
31
31
 
32
- render "admin/helpers/resources/display_link_to_previous",
33
- :body => body,
34
- :url => url
32
+ locals = { :body => body, :url => url }
33
+ render "admin/helpers/resources/display_link_to_previous", locals
35
34
  end
36
35
  end
37
36
 
@@ -19,8 +19,8 @@ module Admin
19
19
 
20
20
  def default_actions(klass)
21
21
  Array.new.tap do |tap|
22
- tap << link_to_unless_current(Typus::I18n.t("Add new"), :action => "new") if admin_user.can?("create", klass)
23
- tap << link_to_unless_current(Typus::I18n.t("List"), :action => "index")
22
+ tap << link_to_unless_current(Typus::I18n.t("All #{klass.model_name.human.pluralize}"), :action => "index")
23
+ tap << link_to_unless_current(Typus::I18n.t("Add New"), :action => "new") if admin_user.can?("create", klass)
24
24
  end
25
25
  end
26
26
 
@@ -2,13 +2,14 @@ module Admin
2
2
  module TableHelper
3
3
 
4
4
  def build_table(model, fields, items, link_options = {}, association = nil, association_name = nil)
5
- render "admin/helpers/table/table",
6
- :model => model,
7
- :fields => fields,
8
- :items => items,
9
- :link_options => link_options,
10
- :headers => table_header(model, fields),
11
- :association_name => association_name
5
+ locals = { :model => model,
6
+ :fields => fields,
7
+ :items => items,
8
+ :link_options => link_options,
9
+ :headers => table_header(model, fields),
10
+ :association_name => association_name }
11
+
12
+ render "admin/helpers/table/table", locals
12
13
  end
13
14
 
14
15
  def table_header(model, fields, params = params)
@@ -100,7 +101,7 @@ module Admin
100
101
  end
101
102
 
102
103
  def table_file_field(attribute, item)
103
- typus_file_preview(item, attribute, { :height => 25, :width => 25})
104
+ typus_file_preview(item, attribute, { :height => 25, :width => 25 })
104
105
  end
105
106
 
106
107
  def table_tree_field(attribute, item)
@@ -151,12 +152,7 @@ module Admin
151
152
 
152
153
  def table_transversal_field(attribute, item)
153
154
  field_1, field_2 = attribute.split(".")
154
-
155
- if related_item = item.send(field_1)
156
- related_item.send(field_2)
157
- else
158
- "&mdash;".html_safe
159
- end
155
+ (related_item = item.send(field_1)) ? related_item.send(field_2) : "&mdash;".html_safe
160
156
  end
161
157
 
162
158
  end
@@ -36,7 +36,7 @@ To create a new entry:
36
36
 
37
37
  <ul>
38
38
  <li>Click on entries tab.</li>
39
- <li>Click "Add new" sub tab.</li>
39
+ <li>Click "Add New" sub tab.</li>
40
40
  <li>Start filling in the blanks.</li>
41
41
  <li>When you are ready, click "Save Entry".</li>
42
42
  </ul>
@@ -15,7 +15,7 @@
15
15
  <%= render 'index' %>
16
16
 
17
17
  <ul class="predefined_filters">
18
- <li><%= link_to Typus::I18n.t("All"), :action => 'index' %> (<%= set_context.count %>)</li>
18
+ <li><%= link_to Typus::I18n.t("All"), :action => 'index' %> (<%= resource.count %>)</li>
19
19
  <% predefined_filters.each do |filter, action, scope| %>
20
20
  <% url = action.is_a?(String) ? params.dup.cleanup.merge(:action => action) : action %>
21
21
  <li><%= link_to Typus::I18n.t(filter), url %> <%= "(#{@resource.send(scope).count})" if scope && @resource.respond_to?(scope) %></li>
@@ -1,5 +1,5 @@
1
1
  <%
2
- page_title = Typus::I18n.t("New %{resource}", :resource => @resource.model_name.human)
2
+ page_title = Typus::I18n.t("Add New %{resource}", :resource => @resource.model_name.human)
3
3
  title(page_title)
4
4
  %>
5
5
 
@@ -6,8 +6,8 @@
6
6
 
7
7
  <title><%= Typus.admin_title %> &mdash; <%= yield :title %></title>
8
8
 
9
- <%= stylesheet_link_tag "typus/application" %>
10
- <%= javascript_include_tag "typus/application" %>
9
+ <%= stylesheet_link_tag :typus %>
10
+ <%= javascript_include_tag :typus %>
11
11
 
12
12
  <%= yield :stylesheets -%>
13
13
  <%= yield :javascripts -%>
@@ -1,10 +1,4 @@
1
1
  <%
2
- values = if @resource.const_defined?(attribute.upcase)
3
- @resource::const_get(attribute.upcase)
4
- else
5
- @resource.send(attribute)
6
- end
7
-
8
2
  if @resource.typus_field_options_for(:read_only).include?(attribute.to_sym)
9
3
  html_options = { :disabled => 'disabled' }
10
4
  message = Typus::I18n.t("Read only")
@@ -13,5 +7,5 @@
13
7
 
14
8
  <li id="<%= attribute %>">
15
9
  <%= form.label attribute, "#{label_text} <small>#{message}</small>".html_safe %>
16
- <%= form.select attribute, values, options.merge!(:include_blank => false), html_options %>
10
+ <%= form.select attribute, @resource.send(attribute), options.merge!(:include_blank => false), html_options %>
17
11
  </li>
@@ -7,11 +7,11 @@ ca:
7
7
  admin_user: Usuari
8
8
  attributes:
9
9
  admin_user:
10
- email: "Correu electrònic"
11
- first_name: "Nom"
12
- last_name: "Cognoms"
13
- password: "Contrassenya"
14
- password_confirmation: "Confirmar contrasenya"
15
- status: "Estat"
16
- role: "Rol"
17
- locale: "Idioma"
10
+ email: Correu electrònic
11
+ first_name: Nom
12
+ last_name: Cognoms
13
+ password: Contrasenya
14
+ password_confirmation: Confirmar contrasenya
15
+ status: Estat
16
+ role: Rol
17
+ locale: Idioma
@@ -6,7 +6,7 @@ ca:
6
6
  "Actions": "Accions"
7
7
  "Active": "Actiu"
8
8
  "Add": "Afegir"
9
- "Add new": "Afegir nou"
9
+ "Add New": "Afegir nou"
10
10
  "All": "Tots"
11
11
  "Are you sure?": "Estàs segur?"
12
12
  "Are you sure you want to sign out and end your session?": "Estàs segur que vols sortir i tancar la sessió?"
@@ -32,7 +32,6 @@ ca:
32
32
  "Last few days": "Últims dies"
33
33
  "Last 30 days": "Últims 30 dies"
34
34
  "Last 7 days": "Últims 7 dies"
35
- "List": "Llista"
36
35
  "Logged as": "Identificat com"
37
36
  "Login": "Login"
38
37
 
@@ -6,7 +6,7 @@ de:
6
6
  "Actions": "Aktionen"
7
7
  "Active":
8
8
  "Add": "Zuf&uuml;gen"
9
- "Add new": "Erstellen"
9
+ "Add New": "Erstellen"
10
10
  "Are you sure?":
11
11
  "Are you sure you want to sign out and end your session?": "Wollen Sie sich abmelden und die Sitzung beenden?"
12
12
 
@@ -31,7 +31,6 @@ de:
31
31
  "Last few days": "Letzten Tage"
32
32
  "Last 30 days": "Letzten 30 Tage"
33
33
  "Last 7 days": "Letzten 7 Tage"
34
- "List":
35
34
  "Logged as": "Aufgezeichnet als"
36
35
  "Login": "Anmeldem"
37
36
 
@@ -6,7 +6,7 @@ el:
6
6
  "Actions": "Ενέργειες"
7
7
  "Active": "Ενεργό"
8
8
  "Add": "Προσθήκη"
9
- "Add new": "Προσθήκη νέου"
9
+ "Add New": "Προσθήκη νέου"
10
10
  "Are you sure?": "Είσαστε βέβαιοι;"
11
11
  "Are you sure you want to sign out and end your session?": "Είσαστε σίγουροι ότι επιθυμείτε να αποσυνδεθείτε και να τερματίσετε το session;"
12
12
 
@@ -32,7 +32,6 @@ el:
32
32
  "Last few days": "Τελευταίες ημέρες"
33
33
  "Last 30 days": "Τελευταίες 30 ημέρες"
34
34
  "Last 7 days": "Τελευταίες 7 ημέρες"
35
- "List": "Λίστα"
36
35
  "Logged as": "Συνδεδεμένος ως"
37
36
  "Login": "Σύνδεση"
38
37
 
@@ -6,7 +6,7 @@ es:
6
6
  "Actions": "Acciones"
7
7
  "Active": "Activo"
8
8
  "Add": "Añadir"
9
- "Add new": "Añadir nuevo"
9
+ "Add New": "Añadir nuevo"
10
10
  "All": "Todos"
11
11
  "Are you sure?": "¿Estás seguro?"
12
12
  "Are you sure you want to sign out and end your session?": "¿Estás seguro que quieres salir y cerrar la sessión?"
@@ -32,7 +32,6 @@ es:
32
32
  "Last few days": "Últimos dias"
33
33
  "Last 30 days": "Últimos 30 dias"
34
34
  "Last 7 days": "Últimos 7 dias"
35
- "List": "Lista"
36
35
  "Logged as": "Autenticado como"
37
36
  "Login": "Login"
38
37