83 lines
3.0 KiB
Ruby
83 lines
3.0 KiB
Ruby
class Admin::VenueManagementMemorabiliasController < Admin::VenueAdminController
|
|
include Admin::VenueManagementsHelper
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
before_action :set_venue_management_memorabilia, only: [:edit, :update, :destroy]
|
|
|
|
def initialize
|
|
super
|
|
@app_title = 'venue_management'
|
|
end
|
|
|
|
def index
|
|
@table_fields = [
|
|
'venue_management.title',
|
|
'vm_memorabilia.case_no',
|
|
'vm_memorabilia.event_date',
|
|
'vm_memorabilia.details',
|
|
]
|
|
filter_memorabilia
|
|
@memorabilias = @memorabilias.order(updated_at: :desc).page(params[:page]).per(10)
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
if request.xhr?
|
|
render :partial => 'index'
|
|
end
|
|
end
|
|
def filter_memorabilia
|
|
@memorabilias = VenueManagementMemorabilia.all
|
|
@filter_fields = {}
|
|
if params[:keywords].present?
|
|
@main_ids = @memorabilias.pluck(:venue_management_main_id)
|
|
@invintings = VenueManagementInviting.where(:id.in => VenueManagementMemorabilia.all.pluck(:venue_management_inviting_id))
|
|
@venue_managements = VenueManagementMain.where(:id.in=>@main_ids)
|
|
@main_ids = search_data(@venue_managements,[:title]).pluck(:id)
|
|
if params[:keywords] == I18n.t(:empty)
|
|
@invintings = @invintings.where(:case_no=>"")
|
|
else
|
|
@invintings = search_data(@invintings,[:case_no])
|
|
end
|
|
ids = VenueManagementMemorabilia.where(:venue_management_inviting_id.in=>@invintings.pluck(:id)).pluck(:id)
|
|
ids1 = VenueManagementMemorabilia.where(:venue_management_main_id.in=>@main_ids).pluck(:id)
|
|
ids2 = VenueManagementMemorabilia.where(:venue_management_inviting_id =>nil ).pluck(:id)
|
|
@memorabilias = VenueManagementMemorabilia.where(:id.in=>(ids + ids1 + ids2))
|
|
end
|
|
end
|
|
def new
|
|
@venue_management = VenueManagementMain.find(params[:id])
|
|
@venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_main_id: params[:id])
|
|
end
|
|
|
|
def create
|
|
@venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_memorabilia_params)
|
|
@venue_management_memorabilia.save
|
|
|
|
redirect_to params['referer_url']
|
|
end
|
|
|
|
def edit
|
|
@venue_management = VenueManagementMain.find(@venue_management_memorabilia.venue_management_main_id)
|
|
end
|
|
|
|
def update
|
|
@venue_management_memorabilia.update_attributes(venue_management_memorabilia_params)
|
|
|
|
redirect_to venue_management_memorabilias_admin_venue_management_path(@venue_management_memorabilia.venue_management_main_id)
|
|
end
|
|
|
|
def destroy
|
|
@venue_management_main_id = @venue_management_memorabilia.venue_management_main_id
|
|
@venue_management_memorabilia.destroy
|
|
|
|
redirect_to venue_management_memorabilias_admin_venue_management_path(@venue_management_main_id)
|
|
end
|
|
|
|
private
|
|
|
|
def set_venue_management_memorabilia
|
|
@venue_management_memorabilia = VenueManagementMemorabilia.find(params[:id])
|
|
end
|
|
|
|
def venue_management_memorabilia_params
|
|
params.require(:venue_management_memorabilia).permit!
|
|
end
|
|
end
|