Merge pull request #9 from exstake/fiat-balances-dashboard
add fiat balances dashboard
This commit is contained in:
8
app/controllers/admin/fiat_balances_controller.rb
Normal file
8
app/controllers/admin/fiat_balances_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
module Admin
|
||||
class FiatBalancesController < Admin::ApplicationController
|
||||
def valid_action?(name, resource = resource_class)
|
||||
["destroy"].exclude?(name.to_s) && super
|
||||
end
|
||||
end
|
||||
end
|
||||
53
app/dashboards/fiat_balance_dashboard.rb
Normal file
53
app/dashboards/fiat_balance_dashboard.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
require "administrate/base_dashboard"
|
||||
|
||||
class FiatBalanceDashboard < Administrate::BaseDashboard
|
||||
# ATTRIBUTE_TYPES
|
||||
# a hash that describes the type of each of the model's fields.
|
||||
#
|
||||
# Each different type represents an Administrate::Field object,
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
id: Field::Number,
|
||||
user: Field::BelongsTo,
|
||||
amount_formatted: Field::String,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [:id, :user, :amount_formatted].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [:user, :id, :amount_formatted, :created_at, :updated_at].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [:user, :amount_formatted].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
# a hash that defines filters that can be used while searching via the search
|
||||
# field of the dashboard.
|
||||
#
|
||||
# For example to add an option to search for open resources by typing "open:"
|
||||
# in the search field:
|
||||
#
|
||||
# COLLECTION_FILTERS = {
|
||||
# open: ->(resources) { resources.where(open: true) }
|
||||
# }.freeze
|
||||
COLLECTION_FILTERS = {}.freeze
|
||||
|
||||
# Overwrite this method to customize how fiat balances are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(fiat_balance)
|
||||
# "FiatBalance ##{fiat_balance.id}"
|
||||
# end
|
||||
end
|
||||
@@ -24,5 +24,7 @@ class FiatBalance < ApplicationRecord
|
||||
|
||||
monetize :amount_cents
|
||||
|
||||
validates :amount, presence: true
|
||||
def amount_formatted
|
||||
amount.format
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,17 +4,34 @@ pt-BR:
|
||||
user_document:
|
||||
one: Documentos de Usuário
|
||||
other: Documentos de Usuários
|
||||
|
||||
admin_user:
|
||||
one: Administrador
|
||||
other: Administradores
|
||||
|
||||
currency:
|
||||
one: Moeda
|
||||
other: Moedas
|
||||
|
||||
balance:
|
||||
one: Saldo
|
||||
other: Saldos
|
||||
|
||||
fiat_balance:
|
||||
one: Saldo Fiat
|
||||
other: Saldos Fiat
|
||||
|
||||
attributes:
|
||||
user:
|
||||
first_name: Primeiro nome
|
||||
last_name: Último nome
|
||||
full_name: Nome completo
|
||||
|
||||
balance:
|
||||
amount: Quantia
|
||||
|
||||
fiat_balance:
|
||||
amount_formatted: Quantia
|
||||
|
||||
currency:
|
||||
name: Nome
|
||||
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :users
|
||||
resources :balances
|
||||
resources :fiat_balances
|
||||
resources :currencies
|
||||
resources :admin_users
|
||||
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe(FiatBalance, type: :model) do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
describe "associations" do
|
||||
it { is_expected.to(belong_to(:user)) }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user