diff --git a/app/controllers/admin/venue_management_memorabilias_controller.rb b/app/controllers/admin/venue_management_memorabilias_controller.rb new file mode 100644 index 0000000..36f48b3 --- /dev/null +++ b/app/controllers/admin/venue_management_memorabilias_controller.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +class Admin::VenueManagementMemorabiliasController < OrbitAdminController + 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', + ] + @memorabilias = VenueManagementMemorabilia.order(updated_at: :desc).page(params[:page]).per(10) + end + + def new + @venue_management = VenueManagementMain.find(params[:id]) + @venue_management_memorabilia = @venue_management.venue_management_memorabilias.build + 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 diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index 6d482df..226054a 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -4,7 +4,7 @@ class Admin::VenueManagementsController < OrbitAdminController require 'axlsx' helper Admin::VenueManagementsFieldHelper before_action ->(module_app = @app_title) { set_variables module_app } - before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings] + before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias] def initialize super @@ -254,6 +254,15 @@ class Admin::VenueManagementsController < OrbitAdminController @invitings = @venue_management.venue_management_invitings.page(params[:page]).per(10) end + def venue_management_memorabilias + @table_fields = [ + 'vm_memorabilia.case_no', + 'vm_memorabilia.event_date', + 'vm_memorabilia.details', + ] + @memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10) + end + private def set_venue_management diff --git a/app/models/venue_management_main.rb b/app/models/venue_management_main.rb index 11c0c2f..628f7cd 100644 --- a/app/models/venue_management_main.rb +++ b/app/models/venue_management_main.rb @@ -37,6 +37,7 @@ class VenueManagementMain has_many :venue_management_links, :autosave => true, :dependent => :destroy has_many :venue_management_invitings, :autosave => true, :dependent => :destroy + has_many :venue_management_memorabilias, :autosave => true, :dependent => :destroy has_many :venue_management_files, :autosave => true, :dependent => :destroy has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy has_many :venue_management_signups, :autosave => true, :dependent => :destroy diff --git a/app/models/venue_management_memorabilia.rb b/app/models/venue_management_memorabilia.rb new file mode 100644 index 0000000..1066089 --- /dev/null +++ b/app/models/venue_management_memorabilia.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'orbit_form_helper' + +class VenueManagementMemorabilia + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::Enum + + field :event_date, type: Date, default: Time.now + field :case_no, type: String + field :details, localize: true + + belongs_to :venue_management_main + has_many :venue_management_links, :as => :venue_object, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :venue_management_links, :allow_destroy => true + +end diff --git a/app/views/admin/venue_management_memorabilias/_form.html.erb b/app/views/admin/venue_management_memorabilias/_form.html.erb new file mode 100644 index 0000000..8da71b3 --- /dev/null +++ b/app/views/admin/venue_management_memorabilias/_form.html.erb @@ -0,0 +1,103 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + +
+ <%= hidden_field_tag 'venue_management_link_field_count', @venue_management_memorabilia.venue_management_links.count %> + <%= t(:add) %> +
+<%= memorabilia.venue_management_main.title %> | + <% end %> +
+ <%= link_to memorabilia.case_no, admin_venue_management_memorabilia_path(memorabilia.id), :target => '_blank' %>
+
+
+
+ |
+ <%= memorabilia.event_date %> | +<%= memorabilia.details %> | +