Added group_categories creation page in admin panel

• Added:
- group_categories creation page in admin panel
This commit is contained in:
mgabdev 2020-08-05 23:03:14 -05:00
parent f3ff407ba0
commit 7dd1e0cd0b
6 changed files with 75 additions and 0 deletions

@ -0,0 +1,43 @@
class Settings::GroupCategoriesController < Admin::BaseController
before_action :set_category, except: [:index, :new, :create]
def index
@categories = GroupCategories.all
end
def new
@category = GroupCategories.new
end
def create
@category = GroupCategories.new(resource_params)
if @category.save
log_action :create, @category
redirect_to settings_group_categories_path, notice: I18n.t('promotions.created_msg')
else
render :new
end
end
def destroy
# : todo :
# don't destroy if any groups have this category
@category.destroy!
log_action :destroy, @category
flash[:notice] = I18n.t('promotions.destroyed_msg')
redirect_to settings_group_categories_path
end
private
def set_category
@category = GroupCategories.find(params[:id])
end
def resource_params
params.permit(:text)
end
end

@ -0,0 +1,5 @@
%tr
%td= group_categories.created_at
%td= group_categories.text
%td
= table_link_to 'trash', t('group_categories.delete'), settings_group_categories_path(group_categories), method: :delete

@ -0,0 +1,20 @@
- content_for :page_title do
= t('group_categories.title')
= form_tag settings_group_categories_url, method: 'POST', class: 'simple_form' do
.fields-group
.input.string.optional
= text_field_tag :text, params[:text], class: 'string optional', placeholder: I18n.t("group_categories.text")
.actions
%button= t('group_categories.create')
.table-wrapper
%table.table
%thead
%tr
%th= t('categories.created_at')
%th= t('categories.text')
%th
%tbody
= render @categories

@ -74,6 +74,11 @@ en:
title: Promotions
monthly_funding:
title: Monthly Funding
group_categories:
create: Create
delete: Delete
text: Text
title: Group Categories
admin:
account_actions:
action: Perform action

@ -51,6 +51,7 @@ SimpleNavigation::Configuration.run do |navigation|
s.item :moderation, safe_join([fa_icon('id-card-o fw'), t('verifications.moderation.title')]), settings_verifications_moderation_url, if: -> { current_user.admin? }
s.item :promotions, safe_join([fa_icon('star fw'), t('promotions.title')]), settings_promotions_url, if: -> { current_user.admin? }
s.item :monthly_funding, safe_join([fa_icon('money fw'), t('monthly_funding.title')]), settings_expenses_url, if: -> { current_user.admin? }
s.item :group_categories, safe_join([fa_icon('users fw'), t('group_categories.title')]), settings_group_categories_url, if: -> { current_user.admin? }
end
n.item :logout, safe_join([fa_icon('sign-out fw'), t('auth.logout')]), destroy_user_session_url, link_html: { 'data-method' => 'delete' }

@ -97,6 +97,7 @@ Rails.application.routes.draw do
resources :promotions, only: [:index, :new, :create, :edit, :update, :destroy]
resources :expenses, only: [:index, :new, :create, :edit, :update, :destroy]
resources :group_categories, only: [:index, :new, :create, :edit, :update, :destroy]
namespace :verifications do
get :moderation, to: 'moderation#index', as: :moderation