adminpanel 1.2.4 → 1.2.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.
Files changed (48) hide show
  1. data/app/assets/stylesheets/adminpanel/theme.css +46 -41
  2. data/app/controllers/adminpanel/categories_controller.rb +71 -0
  3. data/app/controllers/adminpanel/users_controller.rb +69 -69
  4. data/app/helpers/adminpanel/application_helper.rb +2 -1
  5. data/app/helpers/adminpanel/class_definitions_helper.rb +10 -0
  6. data/app/helpers/adminpanel/custom_form_builder.rb +23 -24
  7. data/app/helpers/adminpanel/pluralizations_helper.rb +21 -0
  8. data/app/helpers/adminpanel/rest_actions_helper.rb +42 -34
  9. data/app/helpers/adminpanel/router_helper.rb +30 -26
  10. data/app/models/adminpanel/gallery.rb +6 -2
  11. data/app/models/adminpanel/image.rb +1 -1
  12. data/app/models/adminpanel/user.rb +15 -1
  13. data/app/views/adminpanel/categories/_categories_table.html.erb +48 -0
  14. data/app/views/adminpanel/categories/_category_form.html.erb +14 -0
  15. data/app/views/adminpanel/categories/index.html.erb +55 -0
  16. data/app/views/adminpanel/categories/new.js.erb +1 -0
  17. data/app/views/layouts/_side_menu.html.erb +91 -22
  18. data/app/views/shared/_error_messages.html.erb +3 -3
  19. data/app/views/shared/_form_fields.html.erb +14 -13
  20. data/app/views/shared/index.html.erb +1 -1
  21. data/config/locales/es.yml +5 -10
  22. data/config/routes.rb +20 -9
  23. data/lib/adminpanel/active_record_extension.rb +52 -8
  24. data/lib/adminpanel/engine.rb +4 -2
  25. data/lib/adminpanel/version.rb +1 -1
  26. data/lib/generators/adminpanel/initialize/initialize_generator.rb +20 -6
  27. data/lib/generators/adminpanel/initialize/templates/adminpanel_setup.rb +16 -0
  28. data/lib/generators/adminpanel/initialize/templates/category_template.rb +32 -0
  29. data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +11 -0
  30. data/lib/generators/adminpanel/resource/resource_generator.rb +1 -1
  31. data/lib/tasks/adminpanel/adminpanel.rake +4 -4
  32. data/spec/dummy/app/controllers/adminpanel/categories_controller.rb +1 -1
  33. data/spec/dummy/app/models/adminpanel/categorization.rb +5 -5
  34. data/spec/dummy/app/models/adminpanel/category.rb +9 -9
  35. data/spec/generators/initialize_generator_spec.rb +34 -0
  36. data/spec/generators/{resource_spec.rb → resource_generator_spec.rb} +0 -0
  37. data/spec/models/user_spec.rb +3 -3
  38. metadata +18 -19
  39. data/app/helpers/adminpanel/images_helper.rb +0 -10
  40. data/app/views/adminpanel/users/_user_form.html.erb +0 -21
  41. data/app/views/adminpanel/users/edit.html.erb +0 -6
  42. data/app/views/adminpanel/users/index.html.erb +0 -49
  43. data/app/views/adminpanel/users/new.html.erb +0 -6
  44. data/app/views/adminpanel/users/show.html.erb +0 -21
  45. data/config/locales/en.yml +0 -5
  46. data/spec/dummy/config/initializers/inflections.rb +0 -15
  47. data/spec/features/user_pages_spec.rb +0 -48
  48. data/spec/generators/initialize_spec.rb +0 -9
@@ -0,0 +1,14 @@
1
+
2
+ <%= custom_form_for(resource, :remote => true, :html => {:class => "form-horizontal", :id => "new_resource"}) do |f| -%>
3
+ <div class="row-fluid">
4
+ <div class="modal-body">
5
+ <%= render 'shared/error_messages', :object => resource %>
6
+ <%= render 'shared/form_fields', :f => f %>
7
+ <%= f.hidden_field :model, :value => model %>
8
+ </div>
9
+ </div>
10
+ <div class="modal-footer">
11
+ <button class="btn" data-dismiss="modal" aria-hidden="true"><%= I18n.t('action.close') %></button>
12
+ <%= f.submit t("action.add") + " " + @model.display_name, :disable_with => t("action.submitting"), :id =>"new-resource-button" %>
13
+ </div>
14
+ <% end -%>
@@ -0,0 +1,55 @@
1
+ <%= provide(:page_title, "Categorias") %>
2
+
3
+ <div class="row-fluid">
4
+ <div class="widget widget-padding span12" id="wizard">
5
+ <div class="widget-header">
6
+ <ul class="nav nav-tabs">
7
+ <% current_page = "no-page" %>
8
+ <% @categories.each_with_index do |category, index| %>
9
+ <% if current_page != category.model %>
10
+ <% if index == 0 %>
11
+ <li class = "active">
12
+ <% else %>
13
+ <li>
14
+ <% end %>
15
+ <% if !category.model.nil? %>
16
+ <%= link_to (category.model.capitalize), "#tab#{index}", "data-toggle" => "tab" %></li>
17
+ <% current_page = category.model %>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
21
+ </ul>
22
+ </div>
23
+
24
+ <div class="widget-body">
25
+ <div class="tab-content">
26
+ <% current_page = "no-page" %>
27
+ <% @categories.each_with_index do |categories, index| %>
28
+
29
+ <% if current_page != categories.model %>
30
+ <% if index == 0 %>
31
+ <div class="tab-pane active" id="tab<%= index %>">
32
+ <% else %>
33
+ <div class="tab-pane" id="tab<%= index %>">
34
+ <% end %>
35
+ <% current_cateogory_records = Adminpanel::Category.of_model categories.model %>
36
+ <%= render "categories_table", :categories => current_cateogory_records, :model => categories.model %>
37
+ </div>
38
+ <% current_page = categories.model %>
39
+ <% end %>
40
+ <% end %>
41
+ </div>
42
+
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+ <!-- example modal -->
48
+ <div id="example_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
49
+ <div class="modal-header" id="modal-header">
50
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
51
+ <h3 id="myModalLabel">Crear Categoría</h3>
52
+ </div>
53
+ <div id="modal-container">
54
+ </div>
55
+ </div>
@@ -0,0 +1 @@
1
+ $("#modal-container").html('<%= escape_javascript(render "category_form", :resource => resource, :model => model) %>');
@@ -1,50 +1,119 @@
1
1
  <!-- Side menu -->
2
2
  <div class="sidebar-nav nav-collapse collapse" id="sidebar-navigation">
3
- <% if signed_in? %>
4
- <div class="user_side clearfix">
5
- <h5>
6
- <%= @current_user.name.humanize %>
7
- </h5>
8
- <%= link_to (content_tag(:i, nil, :class => 'icon-cog') + ' Editar'), edit_user_path(@current_user) %>
9
- </div>
10
- <% end %>
3
+ <div class="user_side clearfix">
4
+ <h5>
5
+ <%= @current_user.name.humanize %>
6
+ </h5>
7
+ <%=
8
+ link_to(
9
+ content_tag(:i, nil, :class => 'icon-cog') + ' Editar',
10
+ edit_user_path(@current_user)
11
+ )
12
+ %>
13
+ </div>
11
14
  <div class="accordion" id="accordion2">
12
- <div class="accordion-group">
13
- <div class="accordion-heading">
14
- <%= link_to content_tag(:i, nil, :class => 'icon-user') + content_tag(:span, ' Usuarios'), users_path, :class => "accordion-toggle b_9FDDF6 #{is_current_section?('users')}" %>
15
+
16
+ <% if !Adminpanel.unincluded_modules.include?(:analytics) %>
17
+ <div class="accordion-group">
18
+ <div class="accordion-heading">
19
+ <%=
20
+ link_to(
21
+ content_tag(
22
+ :i,
23
+ nil,
24
+ :class => 'icon-dashboard') +
25
+ content_tag(:span," #{I18n.t('model.Analytics')}"),
26
+ pages_path,
27
+ :class => "accordion-toggle b_D1B2D1 #{is_current_section?('pages')}"
28
+ )
29
+ %>
30
+ </div>
15
31
  </div>
16
- </div>
32
+ <% end %>
17
33
 
18
34
  <div class="accordion-group">
19
35
  <div class="accordion-heading">
20
- <%= link_to content_tag(:i, nil, :class => 'icon-picture') + content_tag(:span, " #{t("model.Adminpanel::Gallery")}"), galleries_path, :class => "accordion-toggle b_C3F7A7 #{is_current_section?('galleries')}" %>
36
+ <%=
37
+ link_to(
38
+ content_tag(
39
+ :i,
40
+ nil,
41
+ :class => 'icon-user') +
42
+ content_tag(:span,' Usuarios'),
43
+ users_path,
44
+ :class => "accordion-toggle b_9FDDF6 #{is_current_section?('users')}"
45
+ )
46
+ %>
21
47
  </div>
22
48
  </div>
23
49
 
24
- <div class="accordion-group">
25
- <div class="accordion-heading">
26
- <%= link_to content_tag(:i, nil, :class => 'icon-tasks') + content_tag(:span, ' Secciones'), sections_path, :class => "accordion-toggle b_F6F1A2 #{is_current_section?('sections')}" %>
50
+ <% if !Adminpanel.unincluded_modules.include?(:gallery) %>
51
+ <div class="accordion-group">
52
+ <div class="accordion-heading">
53
+ <%=
54
+ link_to(
55
+ content_tag(
56
+ :i,
57
+ nil,
58
+ :class => 'icon-picture') +
59
+ content_tag(:span, " #{t('model.Gallery')}"),
60
+ galleries_path,
61
+ :class => "accordion-toggle b_C3F7A7 #{is_current_section?('galleries')}"
62
+ )
63
+ %>
64
+ </div>
27
65
  </div>
28
- </div>
66
+ <% end %>
67
+
68
+ <% if !Adminpanel.unincluded_modules.include?(:sections) %>
69
+ <div class="accordion-group">
70
+ <div class="accordion-heading">
71
+ <%=
72
+ link_to(
73
+ content_tag(:i, nil, :class => 'icon-tasks') +
74
+ content_tag(:span, ' Secciones'),
75
+ sections_path,
76
+ :class => "accordion-toggle b_F6F1A2 #{is_current_section?('sections')}"
77
+ )
78
+ %>
79
+ </div>
80
+ </div>
81
+ <% end %>
82
+
83
+ <% if !Adminpanel.unincluded_modules.include?(:categories) %>
84
+ <div class="accordion-group">
85
+ <div class="accordion-heading">
86
+ <%=
87
+ link_to(
88
+ content_tag(:i, nil, :class => 'icon-bookmark') +
89
+ content_tag(:span, " #{t('model.Categories')}"),
90
+ categories_path,
91
+ :class => "accordion-toggle b_99FFCC #{is_current_section?('categories')}"
92
+ )
93
+ %>
94
+ </div>
95
+ </div>
96
+ <% end %>
97
+
29
98
 
30
99
  <% @menu_items.each do |menu| %>
31
100
  <div class="accordion-group">
32
101
  <div class="accordion-heading">
33
- <%=
102
+ <%=
34
103
  link_to content_tag(
35
104
  :i,
36
105
  nil,
37
106
  :class => "Adminpanel::#{menu}".constantize.icon
38
107
  ) + content_tag(
39
- :span,
40
- " " + ("Adminpanel::#{menu}".constantize.plural_name)
108
+ :span,
109
+ " " + pluralize_es("Adminpanel::#{menu}".constantize.display_name)
41
110
  ),
42
111
  [route_symbol(menu)],
43
- :class => "accordion-toggle b_F5C294 #{is_current_section?(menu)}"
112
+ :class => "accordion-toggle b_F5C294 #{is_current_section?(menu)}"
44
113
  %>
45
114
  </div>
46
115
  </div>
47
116
  <% end %>
48
117
  </div>
49
118
  </div>
50
- <!-- /Side menu -->
119
+ <!-- /Side menu -->
@@ -1,13 +1,13 @@
1
1
  <% if object.errors.any? %>
2
2
  <div id="error_explanation">
3
3
  <div id="alerts" class="alert alert-error">
4
- <%= t( :errors, :count => object.errors.count, :model => t("model.#{object.class.model_name}")) %>:
4
+ <%= t( :errors, :count => object.errors.count, :model => @model.display_name) %>:
5
5
  <ul>
6
6
  <% object.errors.messages.keys.each do |field| %>
7
7
  <% object.errors.messages[field].each do |value| %>
8
8
  <li>
9
- <%= t("model.attributes.#{field}") %>
10
- <%= value %>
9
+ <%= @model.get_attribute_name(field.to_s) %>
10
+ <%= value %>
11
11
  </li>
12
12
  <% end %>
13
13
  <% end %>
@@ -14,26 +14,27 @@
14
14
 
15
15
  <% elsif properties["type"] == "adminpanel_file_field" %>
16
16
  <%= f.fields_for :images do |builder| %>
17
- <%= render 'shared/image_fields', :f => builder, :model_name => @model.display_name.capitalize %>
18
- <% end -%>
19
- <%= link_to_add_fields t("Add Image"), f, :images, @model.display_name.capitalize %>
17
+ <%= render 'shared/image_fields', :f => builder, :model_name => @model.display_name.capitalize %>
18
+ <% end -%>
19
+ <%= link_to_add_fields t("Add Image"), f, :images, @model.display_name.capitalize %>
20
20
 
21
- <% elsif properties["type"] == "belongs_to" %>
21
+ <% elsif properties["type"] == "belongs_to" %>
22
22
  <% args = properties.except("type", "name", "model") %>
23
23
  <% args.symbolize_keys! %>
24
- <%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %>
24
+ <%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %>
25
25
 
26
- <% elsif properties["type"] == "has_many" %>
27
- <%= hidden_field_tag("#{class_name_downcase(f.object)}[#{relationship_ids(properties["model"])}][]", nil) %>
28
- <% @collections["#{properties["model"]}"].each do |resource| %>
29
- <%= f.checkbox(resource, class_name_downcase(f.object) ,relationship_ids(properties["model"])) %>
26
+ <% elsif properties["type"] == "has_many" %>
27
+ <%= I18n.t('other.choose', :model => pluralize_es(properties["model"].classify.constantize.display_name)) %>
28
+ <%= hidden_field_tag("#{class_name_downcase(f.object)}[#{relationship_ids(properties["model"])}][]", nil) %>
29
+ <% @collections["#{properties["model"]}"].each do |resource| %>
30
+ <%= f.checkbox(resource, class_name_downcase(f.object) ,relationship_ids(properties["model"])) %>
30
31
  <% end %>
31
32
 
32
- <% else %>
33
+ <% else %>
33
34
  <% type = properties["type"] %>
34
35
  <% args = properties.except("type", "name") %>
35
- <%= f.send(type, attribute, args) %>
36
- <% end %>
36
+ <%= f.send(type, attribute, args) %>
37
+ <% end %>
37
38
 
38
39
  <% end %>
39
- <% end %>
40
+ <% end %>
@@ -17,7 +17,7 @@
17
17
  <div class="widget-header">
18
18
  <%= content_tag(:i, nil, :class => @model.icon) %>
19
19
  <h5>
20
- <%= @model.display_name %>
20
+ <%= pluralize_es(@model.display_name) %>
21
21
  </h5>
22
22
  </div>
23
23
  <div class="widget-body">
@@ -1,15 +1,8 @@
1
1
  es:
2
2
  model:
3
- Adminpanel::User: "Usuario"
4
- Adminpanel::Product: "Producto"
5
- Adminpanel::Gallery: "Galería de Inicio"
6
- Adminpanel::Section: "Sección"
7
- Adminpanel::Image: "Imagen"
8
- Adminpanel::Category: "Categoría"
9
- Adminpanel::Client: "Cliente"
10
- Adminpanel::Post: "Publicación"
11
- Adminpanel::Adminproject: "Proyecto"
12
- Adminpanel::Siteproject: "Proyecto"
3
+ Analytics: "Google Analytics"
4
+ Gallery: "Galería de Inicio"
5
+ Categories: "Categorías"
13
6
  attributes:
14
7
  adminproject_id: "Proyecto"
15
8
  brief: "Pequeña descripción"
@@ -51,6 +44,7 @@ es:
51
44
  action:
52
45
  add: "Agregar"
53
46
  create: "Crear"
47
+ close: "Cerrar"
54
48
  show: "Ver"
55
49
  submitting: "Enviando..."
56
50
  save: "Guardar"
@@ -84,4 +78,5 @@ es:
84
78
  password: "Contraseña"
85
79
  email: "Correo electrónico"
86
80
  other:
81
+ choose: "Selecciona %{model} pertenecientes"
87
82
  no description: "No tiene descripción aún"
data/config/routes.rb CHANGED
@@ -2,23 +2,34 @@ include Adminpanel::RouterHelper
2
2
 
3
3
  Adminpanel::Engine.routes.draw do
4
4
 
5
- adminpanel_resources.each do |file|
6
- if file
7
- resources file.to_sym
8
- end
5
+ adminpanel_resources.each do |file|
6
+ if file
7
+ resources file.to_sym
9
8
  end
9
+ end
10
10
 
11
11
  resources :sections, :except => [:new, :create, :destroy]
12
12
  match '/signout', :to => 'sessions#destroy', :via => :delete, :as => "signout"
13
13
  match '/signin', :to => 'sessions#new', :as => "signin"
14
14
  resources :users
15
- resources :galleries do
15
+ if !Adminpanel.unincluded_modules.include?(:categories)
16
+ resources :categories
17
+ end
18
+
19
+ if !Adminpanel.unincluded_modules.include?(:gallery)
20
+ resources :galleries do
16
21
  member do
17
- put :move_better, :as => "move_to_better"
18
- put :move_worst, :as => "move_to_worst"
22
+ put :move_better, :as => "move_to_better"
23
+ put :move_worst, :as => "move_to_worst"
19
24
  end
25
+ end
20
26
  end
21
27
  resources :sessions, :only => [:new, :create, :destroy]
22
28
 
23
- root :to => 'pages#index'
24
- end
29
+ if !Adminpanel.unincluded_modules.include?(:analytics)
30
+ resources :pages, :path => 'analytics', :only => [:index]
31
+ root :to => 'pages#index'
32
+ else
33
+ root :to => 'users#index'
34
+ end
35
+ end
@@ -2,14 +2,17 @@ module ActiveRecordExtension
2
2
  extend ActiveSupport::Concern
3
3
  #instance methods
4
4
  # def foo
5
-
5
+
6
6
  # end
7
7
 
8
8
  # static(class) methods
9
9
  module ClassMethods
10
10
  def form_attributes
11
11
  [{
12
- "name" => {"type" => "text_field", "name" => ":name"}
12
+ "name" => {
13
+ "type" => "text_field",
14
+ "name" => "name"
15
+ }
13
16
  }]
14
17
  end
15
18
 
@@ -17,6 +20,51 @@ module ActiveRecordExtension
17
20
  "display_name"
18
21
  end
19
22
 
23
+ def get_attribute_name(field)
24
+ form_attributes.each do |attribute|
25
+ attribute.each do |name, properties|
26
+ if name == field
27
+ return properties["name"]
28
+ end
29
+ end
30
+ end
31
+ return ":("
32
+ end
33
+
34
+
35
+ def get_attribute_name(field)
36
+ form_attributes.each do |attribute|
37
+ attribute.each do |name, properties|
38
+ if name == field
39
+ return properties["name"]
40
+ end
41
+ end
42
+ end
43
+ return ":("
44
+ end
45
+
46
+ def get_attribute_label(field)
47
+ form_attributes.each do |attribute|
48
+ attribute.each do |name, properties|
49
+ if name == field
50
+ return properties["label"]
51
+ end
52
+ end
53
+ end
54
+ return ":("
55
+ end
56
+
57
+ def get_attribute_placeholder(field)
58
+ form_attributes.each do |attribute|
59
+ attribute.each do |name, properties|
60
+ if name == field
61
+ return properties["placeholder"]
62
+ end
63
+ end
64
+ end
65
+ return ":("
66
+ end
67
+
20
68
  def display_attributes
21
69
  display_attributes = []
22
70
  form_attributes.each do |attribute|
@@ -30,10 +78,6 @@ module ActiveRecordExtension
30
78
  return display_attributes
31
79
  end
32
80
 
33
- def plural_name
34
- display_name.pluralize
35
- end
36
-
37
81
  def has_images?
38
82
  form_attributes.each do |fields|
39
83
  fields.each do |attribute, properties|
@@ -75,5 +119,5 @@ module ActiveRecordExtension
75
119
  end
76
120
  end
77
121
 
78
- # include the extension
79
- ActiveRecord::Base.send(:include, ActiveRecordExtension)
122
+ # include the extension
123
+ ActiveRecord::Base.send(:include, ActiveRecordExtension)