From fe378ff474c5dd7757c996cc5e423b2031b776f5 Mon Sep 17 00:00:00 2001 From: chiu Date: Sat, 15 Aug 2020 21:40:31 +0800 Subject: [PATCH] fix calendar url --- app/controllers/admin/venue_admin_controller.rb | 1 + app/helpers/venue_admin_helper.rb | 5 ++++- app/models/concerns/venue_link_file.rb | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/venue_admin_controller.rb b/app/controllers/admin/venue_admin_controller.rb index ec1d341..f564785 100644 --- a/app/controllers/admin/venue_admin_controller.rb +++ b/app/controllers/admin/venue_admin_controller.rb @@ -5,6 +5,7 @@ class Admin::VenueAdminController < OrbitAdminController before_action :set_calendar_types,only: [:edit,:new] def set_calendar_types @calendar_types = CalendarType.all.collect{|v| [v.title,v.id.to_s]} + @module_pages = Page.where(:module => 'venue_management').collect{|p| [p.name,p.id] } end def initialize(*) super diff --git a/app/helpers/venue_admin_helper.rb b/app/helpers/venue_admin_helper.rb index c3884fb..06b1c9f 100644 --- a/app/helpers/venue_admin_helper.rb +++ b/app/helpers/venue_admin_helper.rb @@ -6,6 +6,7 @@ module VenueAdminHelper tp = org_datetime_picker(*arg,**args) venue = @template.instance_variable_get(:@venue) if !venue.nil? + module_pages = @template.instance_variable_get(:@module_pages) base_name = @object.class.to_s.underscore calendar_types = @template.instance_variable_get(:@calendar_types) style_attr = '' @@ -34,9 +35,11 @@ module VenueAdminHelper end calendar_type_key = "#{base_name}[calendar_data][type][#{arg[0]}]" calendar_type = @object['calendar_data']['type'][arg[0]] rescue nil + tp4 = select_tag("#{base_name}[calendar_data][page_id][#{arg[0]}]",options_for_select([["----- Select a page -----",nil]]+module_pages,(@object['calendar_data']['page_id'][arg[0]] rescue nil))) tp3 = content_tag(:div, :style => "float: left;flex-wrap: wrap;display: inline-flex;margin-left: 1em;align-items: center;") do - check_box_tag("#{base_name}[calendar_data][key][]",arg[0],calendar_show,:onclick => onclick_func1) + "#{I18n.t('venue_management.add_to_calendar')}
: #{select_tag(calendar_type_key,options_for_select(calendar_types,calendar_type))}
".html_safe + check_box_tag("#{base_name}[calendar_data][key][]",arg[0],calendar_show,:onclick => onclick_func1) + "#{I18n.t('venue_management.add_to_calendar')}
: #{select_tag(calendar_type_key,options_for_select(calendar_types,calendar_type))}#{tp4}
".html_safe end + tp = content_tag(:div, tp , :style=>"float: left;")+ tp2 + tp3 end tp diff --git a/app/models/concerns/venue_link_file.rb b/app/models/concerns/venue_link_file.rb index 04f0619..c5860bc 100644 --- a/app/models/concerns/venue_link_file.rb +++ b/app/models/concerns/venue_link_file.rb @@ -26,8 +26,12 @@ module VenueLinkFile self.field v.name+'_reminder_day', type: Integer end end - self.field :calendar_data,type: Hash,default: {type:{},key:[]} + self.field :calendar_data,type: Hash,default: {type:{},key:[],page_id: {}} self.field :calendar_dict,type: Hash,default: {} + def to_calendar_param + venue_main = self.class.to_s == 'VenueManagementMain' ? self : VenueManagementMain.find(self.venue_management_main_id) + self.case_no+'-'+self.id.to_s+'?method=show_'+self.class.to_s.underscore.gsub('venue_management_','').gsub('main','data') + end def calendar_id(field) self.calendar_dict[field] end @@ -54,7 +58,7 @@ module VenueLinkFile title_tp[locale] = venue_main['title'][locale] + ' ' + self.get_trans(key) note_tp[locale] = self.case_no.blank? ? {} : I18n.t('vm_inviting.case_no') +': ' + self.case_no end - update_dict = {key: key,model_class: self.class.to_s,model_id: self.id,update_user_id: current_user_id,calendar_type_id: calendar_data['type'][key],all_day: true,start: self.send(key),end: self.send(key),title_translations: title_tp,note_translations: note_tp} + update_dict = {key: key,model_class: self.class.to_s,model_id: self.id,update_user_id: current_user_id,calendar_type_id: calendar_data['type'][key],all_day: true,start: self.send(key),end: self.send(key),title_translations: title_tp,note_translations: note_tp,module_key: 'venue_management',model_page_id: calendar_data['page_id'][key]} if key_id.nil? self.calendar_dict[key] = Event.create(update_dict.merge(create_user_id: current_user_id)).id else