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

View File

@@ -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

View File

@@ -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

View File

@@ -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