typus 3.1.0.rc4 → 3.1.0.rc5
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/Gemfile +2 -0
- data/app/assets/images/{typus/blank.gif → blank.gif} +0 -0
- data/app/assets/images/{typus/fancy_close.png → fancy_close.png} +0 -0
- data/app/assets/images/{typus/fancy_loading.png → fancy_loading.png} +0 -0
- data/app/assets/images/{typus/fancy_nav_left.png → fancy_nav_left.png} +0 -0
- data/app/assets/images/{typus/fancy_nav_right.png → fancy_nav_right.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_e.png → fancy_shadow_e.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_n.png → fancy_shadow_n.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_ne.png → fancy_shadow_ne.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_nw.png → fancy_shadow_nw.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_s.png → fancy_shadow_s.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_se.png → fancy_shadow_se.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_sw.png → fancy_shadow_sw.png} +0 -0
- data/app/assets/images/{typus/fancy_shadow_w.png → fancy_shadow_w.png} +0 -0
- data/app/assets/images/{typus/fancy_title_left.png → fancy_title_left.png} +0 -0
- data/app/assets/images/{typus/fancy_title_main.png → fancy_title_main.png} +0 -0
- data/app/assets/images/{typus/fancy_title_over.png → fancy_title_over.png} +0 -0
- data/app/assets/images/{typus/fancy_title_right.png → fancy_title_right.png} +0 -0
- data/app/assets/images/{typus/fancybox-x.png → fancybox-x.png} +0 -0
- data/app/assets/images/{typus/fancybox-y.png → fancybox-y.png} +0 -0
- data/app/assets/images/{typus/fancybox.png → fancybox.png} +0 -0
- data/app/assets/javascripts/typus.js +7 -0
- data/app/assets/javascripts/typus/application.js +3 -7
- data/app/assets/stylesheets/typus.css +7 -0
- data/app/assets/stylesheets/typus/application.css +11 -6
- data/app/controllers/admin/resources_controller.rb +6 -1
- data/app/helpers/admin/filters_helper.rb +1 -5
- data/app/helpers/admin/form_helper.rb +14 -12
- data/app/helpers/admin/relationships_helper.rb +15 -13
- data/app/helpers/admin/resources_helper.rb +2 -3
- data/app/helpers/admin/sidebar_helper.rb +2 -2
- data/app/helpers/admin/table_helper.rb +10 -14
- data/app/views/admin/base/user_guide.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +1 -1
- data/app/views/admin/resources/new.html.erb +1 -1
- data/app/views/admin/shared/_head.html.erb +2 -2
- data/app/views/admin/templates/_selector.html.erb +1 -7
- data/config/locales/typus.ca.models.yml +8 -8
- data/config/locales/typus.ca.yml +1 -2
- data/config/locales/typus.de.yml +1 -2
- data/config/locales/typus.el.yml +1 -2
- data/config/locales/typus.es.yml +1 -2
- data/config/locales/typus.fr.yml +1 -2
- data/config/locales/typus.hu.yml +1 -2
- data/config/locales/typus.it.yml +1 -2
- data/config/locales/typus.locale.yml.template +1 -2
- data/config/locales/typus.pt-BR.yml +1 -2
- data/config/locales/typus.ru.yml +1 -2
- data/config/locales/typus.zh-CN.yml +1 -2
- data/lib/generators/templates/config/initializers/typus_authentication.rb +2 -2
- data/lib/generators/typus/migration_generator.rb +1 -1
- data/lib/support/active_record.rb +1 -5
- data/lib/typus.rb +2 -2
- data/lib/typus/authentication/session.rb +5 -5
- data/lib/typus/controller/headless.rb +1 -1
- data/lib/typus/controller/trash.rb +2 -1
- data/lib/typus/orm/active_record/user/instance_methods.rb +1 -1
- data/lib/typus/orm/base.rb +1 -1
- data/lib/typus/version.rb +1 -1
- data/test/app/controllers/admin/posts_controller_test.rb +4 -4
- data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +1 -1
- data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +3 -0
- data/test/fixtures/rails_app/app/models/entry.rb +12 -0
- data/test/fixtures/rails_app/app/models/post.rb +20 -12
- data/test/fixtures/rails_app/db/schema.rb +1 -0
- data/test/lib/support/active_record_test.rb +46 -108
- data/test/lib/typus_test.rb +4 -4
- data/typus.gemspec +2 -1
- metadata +41 -30
- data/app/assets/javascripts/typus/custom.js +0 -2
- 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"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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.
|
@@ -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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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 =
|
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 =
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
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.
|
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
|
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
|
-
|
33
|
-
|
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("
|
23
|
-
tap << link_to_unless_current(Typus::I18n.t("
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
"—".html_safe
|
159
|
-
end
|
155
|
+
(related_item = item.send(field_1)) ? related_item.send(field_2) : "—".html_safe
|
160
156
|
end
|
161
157
|
|
162
158
|
end
|
@@ -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' %> (<%=
|
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>
|
@@ -6,8 +6,8 @@
|
|
6
6
|
|
7
7
|
<title><%= Typus.admin_title %> — <%= yield :title %></title>
|
8
8
|
|
9
|
-
<%= stylesheet_link_tag
|
10
|
-
<%= javascript_include_tag
|
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,
|
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:
|
11
|
-
first_name:
|
12
|
-
last_name:
|
13
|
-
password:
|
14
|
-
password_confirmation:
|
15
|
-
status:
|
16
|
-
role:
|
17
|
-
locale:
|
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
|
data/config/locales/typus.ca.yml
CHANGED
@@ -6,7 +6,7 @@ ca:
|
|
6
6
|
"Actions": "Accions"
|
7
7
|
"Active": "Actiu"
|
8
8
|
"Add": "Afegir"
|
9
|
-
"Add
|
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
|
|
data/config/locales/typus.de.yml
CHANGED
@@ -6,7 +6,7 @@ de:
|
|
6
6
|
"Actions": "Aktionen"
|
7
7
|
"Active":
|
8
8
|
"Add": "Zufügen"
|
9
|
-
"Add
|
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
|
|
data/config/locales/typus.el.yml
CHANGED
@@ -6,7 +6,7 @@ el:
|
|
6
6
|
"Actions": "Ενέργειες"
|
7
7
|
"Active": "Ενεργό"
|
8
8
|
"Add": "Προσθήκη"
|
9
|
-
"Add
|
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
|
|
data/config/locales/typus.es.yml
CHANGED
@@ -6,7 +6,7 @@ es:
|
|
6
6
|
"Actions": "Acciones"
|
7
7
|
"Active": "Activo"
|
8
8
|
"Add": "Añadir"
|
9
|
-
"Add
|
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
|
|