# frozen_string_literal: true class Admin::VenueManagementInvitingsController < Admin::VenueAdminController include Admin::VenueManagementsHelper before_action ->(module_app = @app_title) { set_variables module_app } before_action :set_venue_management_inviting, only: [:edit, :update, :destroy] def initialize super @app_title = 'venue_management' end def index @table_fields = [ 'venue_management.title', 'vm_inviting.case_no', 'vm_inviting.type', 'vm_inviting.publish_times', 'vm_inviting.start_end', 'vm_inviting.rents', 'vm_inviting.royalty', 'vm_inviting.house_land_tax_payer', 'vm_inviting.contractor_manager', 'vm_inviting.bid_result', ] @tags = @module_app.tags @filter_fields = {} @filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} } filter_tags = params[:filters]["type"].to_a rescue [] @invitings = VenueManagementInviting.with_tags(filter_tags).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 new @venue_management = VenueManagementMain.find(params[:id]) @venue_management_inviting = @venue_management.venue_management_invitings.build end def create @venue_management_inviting = VenueManagementInviting.new(venue_management_inviting_params) @venue_management_inviting.save redirect_to params['referer_url'] end def edit @venue_management = VenueManagementMain.find(@venue_management_inviting.venue_management_main_id) end def update @venue_management_inviting.update_attributes(venue_management_inviting_params) redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_inviting.venue_management_main_id) end def destroy @venue_management_main_id = @venue_management_inviting.venue_management_main_id @venue_management_inviting.destroy redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_main_id) end private def set_venue_management_inviting @venue_management_inviting = VenueManagementInviting.find(params[:id]) end def venue_management_inviting_params inviting_params = params.require(:venue_management_inviting).permit! inviting_params["tags"] = [] if inviting_params["tags"].nil? return inviting_params end end