Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin panel #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions app/admin/categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ActiveAdmin.register Category do
remove_filter :gift_categorizations
filter :name
filter :created_at
filter :updated_at
permit_params :name

show do
attributes_table do
row :name
row :created_at
row :updated_at
end
active_admin_comments
end

index do
selectable_column
id_column
column :name
column :created_at
column :updated_at

actions
end

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

index do
selectable_column
id_column
column :name
column :price
column :created_at
column :updated_at
actions
end

show do
attributes_table do
row :name
row :price
row :created_at
row :updated_at
end
active_admin_comments
end

form do |f|
f.inputs 'Detalles' do
f.input :name
f.input :price
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
80 changes: 80 additions & 0 deletions app/admin/gifts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
ActiveAdmin.register Gift do
permit_params :name, :price, :valoration, :supplier_id, :image, :content, category_ids: [],
customization_ids: []

remove_filter :gift_customizations, :gift_categorizations, :purchases,
:image_attachment, :image_blob, :rich_text_content

filter :name
filter :price
filter :valoration
filter :supplier
filter :categories, multiple: true
filter :customizations, multiple: true
filter :created_at
filter :updated_at

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

index do
selectable_column
id_column
column :name
column :price
column :valoration
column :supplier
column :created_at
column :updated_at
actions
end

show do
attributes_table do
row :name
row :price
row :valoration
row :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 :created_at
row :updated_at
end
active_admin_comments
end

form do |f|
f.inputs 'Detalles' do
f.input :name
f.input :price
f.input :valoration
f.input :supplier
f.input :image, as: :file
f.input :content
f.input :categories
f.input :customizations
end
f.actions
end
end
Loading
Loading