This extension add the reports module to Solidus Admin. The reports section was extracted into this extension.
Add solidus_reports to your Gemfile:
gem 'solidus_reports', github: 'solidusio-contrib/solidus_reports'
Bundle your dependencies and run the installation generator:
bundle
bundle exec rails g solidus_reports:install
To create a report, you need to:
Extend the ReportsController in a decorator to create the action
# app/decorators/awesome_store/spree/admin/reports_controller/add_my_report_decorator.rb
module AwesomeStore
module Spree
module Admin
module ReportsController
module AddMyReportDecorator
def my_report
#code
end
def initialize
::Spree::Admin::ReportsController.add_available_report!(:my_report)
super
end
::Spree::Admin::ReportsController.prepend self
end
end
end
end
end
Create a route in routes.rb
Spree::Core::Engine.routes.draw do
namespace :admin do
resources :reports, only: [:index] do
collection do
get :my_report
post :my_report
end
end
end
end
mount Spree::Core::Engine, at: '/'
Create a template in app/views/spree/admin/reports/my_report.html.erb
Add an entry into your Translations
# config/locales/en.yml
en:
hello: "Hello world"
spree:
my_report: My Report
my_report_description: A New Report
First bundle your dependencies, then run rake
. rake
will default to building the dummy app if it does not exist, then it will run specs, and Rubocop static code analysis. The dummy app can be regenerated by using rake test_app
.
bundle
bundle exec rake
When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:
require 'solidus_reports/factories'
Your new extension version can be released using gem-release
like this:
bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
Copyright (c) 2020 [name of extension creator], released under the New BSD License