This commit is contained in:
BoHung Chiu 2022-07-13 15:00:21 +08:00
parent e76355a658
commit 592eab19a2
2 changed files with 23 additions and 14 deletions

View File

@ -34,6 +34,12 @@ class CalendarsController < ApplicationController
def widget def widget
part = OrbitHelper.get_current_widget part = OrbitHelper.get_current_widget
@calendar_setting = CalendarSetting.first @calendar_setting = CalendarSetting.first
begin
extra_before_html = render_to_string(partial: 'calendars/calendar_variable', locals: {:@calendar_setting=>@calendar_setting})
rescue => e
extra_before_html = ""
puts e, e.backtrace
end
{ {
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i == "modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
2 ? 'active' : '')}}, 2 ? 'active' : '')}},
@ -44,7 +50,8 @@ class CalendarsController < ApplicationController
'widget_title' => part.title, 'widget_title' => part.title,
'widget_title_class' => part.title.blank? ? 'center' : '', 'widget_title_class' => part.title.blank? ? 'center' : '',
'calendar_title' => get_calendar_title, 'calendar_title' => get_calendar_title,
'default_column' => widget_default_column 'default_column' => widget_default_column,
'extra_before_html' => extra_before_html
} }
} }
end end

View File

@ -1,4 +1,5 @@
<script> <script>
if(window.calendar_variable == undefined){
window.calendar_variable = {}; window.calendar_variable = {};
window.calendar_variable.from = "<%=t('calendar.from')%>"; window.calendar_variable.from = "<%=t('calendar.from')%>";
window.calendar_variable.to = "<%=t('calendar.to')%>"; window.calendar_variable.to = "<%=t('calendar.to')%>";
@ -13,4 +14,5 @@
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[0...3]}.to_s.html_safe%>; window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[0...3]}.to_s.html_safe%>;
<% end %> <% end %>
<% end %> <% end %>
}
</script> </script>