fix calendar url

This commit is contained in:
chiu 2020-08-15 21:40:31 +08:00
parent 63925f6666
commit fe378ff474
3 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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')}<div class=\"calendar_div\"#{style_attr2}>:&nbsp;#{select_tag(calendar_type_key,options_for_select(calendar_types,calendar_type))}</div>".html_safe
check_box_tag("#{base_name}[calendar_data][key][]",arg[0],calendar_show,:onclick => onclick_func1) + "#{I18n.t('venue_management.add_to_calendar')}<div class=\"calendar_div\"#{style_attr2}>:&nbsp;#{select_tag(calendar_type_key,options_for_select(calendar_types,calendar_type))}#{tp4}</div>".html_safe
end
tp = content_tag(:div, tp , :style=>"float: left;")+ tp2 + tp3
end
tp

View File

@ -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