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 %> + +
+ + +
+ +
+ <%= f.hidden_field :venue_management_main_id %> +
+ +
+ <%= f.text_field :case_no %> +
+
+
+ +
+ <%= f.datetime_picker :event_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @venue_management_memorabilia.new_record? %> +
+
+
+
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :details_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@venue_management_memorabilia.details_translations[locale] rescue nil) %> + <% end %> +
+
+
+
+ + <% end %> + + +
+ +
+ + + <% if @venue_management_memorabilia && !@venue_management_memorabilia.venue_management_links.blank? %> +
+ <% @venue_management_memorabilia.venue_management_links.each_with_index do |venue_management_link, i| %> + <%= f.fields_for :venue_management_links, venue_management_link do |f| %> + <%= render :partial => 'form_link', :object => venue_management_link, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= hidden_field_tag 'venue_management_link_field_count', @venue_management_memorabilia.venue_management_links.count %> + <%= t(:add) %> +

+
+
+
+
+ + +
+ <%= get_referer_url[:venue_managemention] rescue "" %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + + <%= link_to t('cancel'), venue_management_memorabilias_admin_venue_management_path(id: @venue_management.id), :class=>"btn" %> +
diff --git a/app/views/admin/venue_management_memorabilias/_index.html.erb b/app/views/admin/venue_management_memorabilias/_index.html.erb new file mode 100644 index 0000000..0624cde --- /dev/null +++ b/app/views/admin/venue_management_memorabilias/_index.html.erb @@ -0,0 +1,52 @@ + +<% if 'venue_management_memorabilias' == params[:action] %> +

<%= @venue_management.title %>

+<% end %> + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @memorabilias.each do |memorabilia| %> + + <% if 'venue_management_memorabilias' != params[:action] %> + + <% end %> + + + + + <% end %> + +
<%= memorabilia.venue_management_main.title %> + <%= link_to memorabilia.case_no, admin_venue_management_memorabilia_path(memorabilia.id), :target => '_blank' %> +
+ +
+
<%= memorabilia.event_date %><%= memorabilia.details %>
+ +<%= + content_tag :div, class: "bottomnav clearfix" do + content_tag :div, paginate(@memorabilias), class: "pagination pagination-centered" + end +%> +<% if @venue_management.present? %> + +
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_venue_management_memorabilia_path(id: @venue_management.id), class: "btn btn-primary" %> +
+
+ +<% end %> diff --git a/app/views/admin/venue_management_memorabilias/edit.html.erb b/app/views/admin/venue_management_memorabilias/edit.html.erb new file mode 100644 index 0000000..be230ee --- /dev/null +++ b/app/views/admin/venue_management_memorabilias/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @venue_management_memorabilia, url: admin_venue_management_memorabilia_path(@venue_management_memorabilia), html: {class: "form-horizontal main-forms"} do |f| %> +
+ <%= render :partial => 'form', locals: {f: f} %> +
+<% end %> diff --git a/app/views/admin/venue_management_memorabilias/index.html.erb b/app/views/admin/venue_management_memorabilias/index.html.erb new file mode 100644 index 0000000..be82942 --- /dev/null +++ b/app/views/admin/venue_management_memorabilias/index.html.erb @@ -0,0 +1,4 @@ + + <%= render 'index' %> + +<%= render 'layouts/delete_modal', delete_options: @delete_options %> diff --git a/app/views/admin/venue_management_memorabilias/new.html.erb b/app/views/admin/venue_management_memorabilias/new.html.erb new file mode 100644 index 0000000..1039a8d --- /dev/null +++ b/app/views/admin/venue_management_memorabilias/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @venue_management_memorabilia, url: admin_venue_management_memorabilias_path, html: {class: "form-horizontal main-forms"} do |f| %> +
+ <%= render :partial => 'form', locals: {f: f} %> +
+<% end %> diff --git a/app/views/admin/venue_managements/_index.html.erb b/app/views/admin/venue_managements/_index.html.erb index 4d43368..90dacf4 100644 --- a/app/views/admin/venue_managements/_index.html.erb +++ b/app/views/admin/venue_managements/_index.html.erb @@ -38,7 +38,9 @@ <%= link_to venue_management.venue_management_invitings.count, venue_management_invitings_admin_venue_management_path(venue_management.id) %> - 0 + + <%= link_to venue_management.venue_management_memorabilias.count, venue_management_memorabilias_admin_venue_management_path(venue_management.id) %> + <%= t('venue_management.export') %> <% end %> diff --git a/app/views/admin/venue_managements/venue_management_memorabilias.html.erb b/app/views/admin/venue_managements/venue_management_memorabilias.html.erb new file mode 100644 index 0000000..52ddb0e --- /dev/null +++ b/app/views/admin/venue_managements/venue_management_memorabilias.html.erb @@ -0,0 +1,5 @@ + + <%= render 'admin/venue_management_memorabilias/index' %> + + +<%= render 'layouts/delete_modal', delete_options: @delete_options %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 57a5038..c84e375 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -161,3 +161,7 @@ en: failure: Failure abandoned: Abandoned qualified: Qualified + vm_memorabilia: + case_no: 'Case No.' + event_date: Event Date + details: Details diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index c611669..be57a26 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -164,3 +164,7 @@ zh_tw: failure: 流標 abandoned: 廢標 qualified: 合格續行評審 + vm_memorabilia: + case_no: 相關案號 + event_date: 事件日期 + details: 事件內容 diff --git a/config/routes.rb b/config/routes.rb index a8c2f51..ce2499c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Rails.application.routes.draw do get 'venue_management_signup_field' get 'venue_management_submission_field' get 'venue_management_invitings' + get 'venue_management_memorabilias' end end resources :venue_management_items do @@ -24,6 +25,7 @@ Rails.application.routes.draw do resources :venue_management_signups resources :venue_management_item_contents resources :venue_management_invitings + resources :venue_management_memorabilias end resources :venue_managements do diff --git a/lib/venue_management/engine.rb b/lib/venue_management/engine.rb index f012f81..3e88bfe 100644 --- a/lib/venue_management/engine.rb +++ b/lib/venue_management/engine.rb @@ -47,6 +47,11 @@ module VenueManagement :priority => 3, :active_for_action => { 'admin/venue_managements' => 'venue_management_invitings' }, :available_for => 'managers' + context_link 'venue_management.set_venue_management_memorabilias', + :link_path => 'admin_venue_management_memorabilias_path', + :priority => 3, + :active_for_action => { 'admin/venue_managements' => 'venue_management_memorabilias' }, + :available_for => 'managers' end end end