Skip to content

Commit

Permalink
finished admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoLombardo committed Jul 24, 2024
1 parent 278841a commit 45657b0
Show file tree
Hide file tree
Showing 33 changed files with 1,127 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ gem 'faker'

gem 'kaminari'

gem 'sassc'

gem 'activeadmin'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'bullet'
Expand Down
38 changes: 38 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ GEM
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activeadmin (3.2.2)
arbre (~> 1.2, >= 1.2.1)
csv
formtastic (>= 3.1)
formtastic_i18n (>= 0.4)
inherited_resources (~> 1.7)
jquery-rails (>= 4.2)
kaminari (>= 1.2.1)
railties (>= 6.1)
ransack (>= 4.0)
activejob (7.1.3.3)
activesupport (= 7.1.3.3)
globalid (>= 0.3.6)
Expand Down Expand Up @@ -77,6 +87,9 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
arbre (1.7.0)
activesupport (>= 3.0.0)
ruby2_keywords (>= 0.0.2)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
Expand Down Expand Up @@ -105,6 +118,7 @@ GEM
crass (1.0.6)
cssbundling-rails (1.4.0)
railties (>= 6.0.0)
csv (3.3.0)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
Expand Down Expand Up @@ -155,20 +169,35 @@ GEM
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-darwin)
formtastic (5.0.0)
actionpack (>= 6.0.0)
formtastic_i18n (0.7.0)
globalid (1.2.1)
activesupport (>= 6.1)
has_scope (0.8.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
inherited_resources (1.14.0)
actionpack (>= 6.0)
has_scope (>= 0.6)
railties (>= 6.0)
responders (>= 2)
io-console (0.7.2)
irb (1.13.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jsbundling-rails (1.3.0)
railties (>= 6.0.0)
json (2.7.2)
Expand Down Expand Up @@ -286,6 +315,10 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.2.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rdoc (6.7.0)
psych (>= 4.0.0)
reek (6.3.0)
Expand Down Expand Up @@ -318,7 +351,10 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
selenium-webdriver (4.21.1)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
Expand Down Expand Up @@ -377,6 +413,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activeadmin
bootsnap
bullet
capybara
Expand All @@ -396,6 +433,7 @@ DEPENDENCIES
rails_best_practices
reek
rubocop
sassc
selenium-webdriver
sprockets-rails
sqlite3 (~> 1.4)
Expand Down
26 changes: 26 additions & 0 deletions app/admin/admin_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end

filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at

form do |f|
f.inputs do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end
34 changes: 34 additions & 0 deletions app/admin/categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ActiveAdmin.register Category do
menu label: 'Categorías'
remove_filter :gift_categorizations
filter :name, label: 'Nombre'
filter :created_at, label: 'Fecha de creación'
filter :updated_at, label: 'Última actualización'
permit_params :name

show do
attributes_table do
row 'Nombre', &:name
row 'Fecha de creación', &:created_at
row 'Última actualización', &:updated_at
end
active_admin_comments
end

index do
selectable_column
id_column
column 'Nombre', :name
column 'Fecha de creación', :created_at
column 'Última actualización', :updated_at

actions
end

form do |f|
f.inputs 'Detalles' do
f.input :name, label: 'Nombre'
end
f.actions
end
end
34 changes: 34 additions & 0 deletions app/admin/customizations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ActiveAdmin.register Customization do
permit_params :name, :price
menu label: 'Personalizaciones'
filter :name, label: 'Nombre'
filter :price, label: 'Precio'

index do
selectable_column
id_column
column 'Nombre', :name
column 'Precio', :price
column 'Fecha de creación', :created_at
column 'Última actualización', :updated_at
actions
end

show do
attributes_table do
row 'Nombre', &:name
row 'Precio', &:price
row 'Fecha de creación', &:created_at
row 'Última actualización', &:updated_at
end
active_admin_comments
end

form do |f|
f.inputs 'Detalles' do
f.input :name, label: 'Nombre'
f.input :price, label: 'Precio'
end
f.actions
end
end
34 changes: 34 additions & 0 deletions app/admin/dashboard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

ActiveAdmin.register_page 'Dashboard' do
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }

content title: proc { I18n.t('active_admin.dashboard') } do
div class: 'blank_slate_container', id: 'dashboard_default_message' do
span class: 'blank_slate' do
span I18n.t('active_admin.dashboard_welcome.welcome')
small I18n.t('active_admin.dashboard_welcome.call_to_action')
end
end

# Here is an example of a simple dashboard with columns and panels.
#
# columns do
# column do
# panel "Recent Posts" do
# ul do
# Post.recent(5).map do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end
# end

# column do
# panel "Info" do
# para "Welcome to ActiveAdmin."
# end
# end
# end
end
end
81 changes: 81 additions & 0 deletions app/admin/gifts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
ActiveAdmin.register Gift do
permit_params :name, :price, :valoration, :supplier_id, :image, :content, category_ids: [],
customization_ids: []

menu label: 'Regalos'
remove_filter :gift_customizations, :gift_categorizations, :purchases,
:image_attachment, :image_blob, :rich_text_content

filter :name, label: 'Nombre'
filter :price, label: 'Precio'
filter :valoration, label: 'Valoración'
filter :supplier, label: 'Proveedor'
filter :categories, label: 'Categorías', multiple: true
filter :customizations, label: 'Personalizaciones', multiple: true
filter :created_at, label: 'Fecha de creación'
filter :updated_at, label: 'Última actualización'

controller do
def scoped_collection
super.includes(:supplier)
end
end

index do
selectable_column
id_column
column 'Nombre', :name
column 'Precio', :price
column 'Valoración', :valoration
column 'Proveedor', :supplier
column 'Fecha de creación', :created_at
column 'Última actualización', :updated_at
actions
end

show do
attributes_table do
row 'Nombre', &:name
row 'Precio', &:price
row 'Valoración', &:valoration
row 'Proveedor', &:supplier
row 'Imagen' do |gift|
image_tag gift.image_resized_for_purchase
end
row 'Contenido' do |gift|
gift.content.to_s
end
row 'Categorías' do |gift|
dropdown_menu '' do
gift.categories.each do |category|
item category.name
end
end
end
row 'Personalizaciones' do |gift|
dropdown_menu '' do
gift.customizations.each do |customization|
item customization.name, admin_customization_path(customization)
end
end
end
row 'Fecha de creación', &:created_at
row 'Última actualización', &:updated_at
end
active_admin_comments
end

form do |f|
f.inputs 'Detalles' do
f.input :name, label: 'Nombre'
f.input :price, label: 'Precio'
f.input :valoration, label: 'Valoración'
f.input :supplier, label: 'Proveedor'
f.input :image, label: 'Imagen', as: :file
f.input :content, label: 'Contenido'
f.input :categories, label: 'Categorías'
f.input :customizations, label: 'Personalizaciones'
end
f.actions
end
end
Loading

0 comments on commit 45657b0

Please sign in to comment.