add announcemnet connect feature(not finished)

This commit is contained in:
chiu 2020-05-28 19:12:31 +08:00
parent ed088e74be
commit 3b6d3480ed
5 changed files with 40 additions and 14 deletions

View File

@ -118,6 +118,10 @@ class Admin::CalendarsController < OrbitAdminController
@event = Event.find(params[:id]) @event = Event.find(params[:id])
p = event_page_params p = event_page_params
p["update_user_id"] = current_user.id p["update_user_id"] = current_user.id
bulletin = @event.bulletin
if !bulletin.nil?
bulletin.update_attributes(calendar_start_date: p[:start],calendar_end_date: p[:end],calendar_all_day: p[:all_day],calendar_type_id: p[:calendar_type_id])
end
if @event.update_attributes(p) if @event.update_attributes(p)
e = @event.to_json e = @event.to_json
e = JSON.parse(e) e = JSON.parse(e)
@ -136,6 +140,10 @@ class Admin::CalendarsController < OrbitAdminController
# DELETE /events/1.json # DELETE /events/1.json
def destroy def destroy
@event = Event.find(params[:id]) @event = Event.find(params[:id])
bulletin = @event.bulletin
if !bulletin.nil?
bulletin.update_attributes(event_id: nil,add_to_calendar: '0')
end
@event.destroy @event.destroy
render :json => {"success"=>true}.to_json render :json => {"success"=>true}.to_json
# respond_to do |format| # respond_to do |format|

View File

@ -11,19 +11,21 @@ class Event
field :note field :note
field :start, type: DateTime field :start, type: DateTime
field :end, type: DateTime field :end, type: DateTime
field :all_day, type: Boolean field :all_day, type: Boolean,default: false
field :recurring, type: Boolean field :recurring, type: Boolean,default: false
field :frequency field :frequency
field :period field :period
field :create_user_id field :create_user_id
field :update_user_id field :update_user_id
field :bulletin_id
belongs_to :calendar_type belongs_to :calendar_type
attr_accessor :agenda_start, :agenda_end, :get_agenda_events attr_accessor :agenda_start, :agenda_end, :get_agenda_events
validates_presence_of :title, :message => "Please fill the title of the Event" validates_presence_of :title, :message => "Please fill the title of the Event"
def bulletin
Bulletin.find(self.bulletin_id) rescue nil
end
def self.format_date(date_time) def self.format_date(date_time)
Time.at(date_time.to_i).to_formatted_s(:db) Time.at(date_time.to_i).to_formatted_s(:db)
end end

View File

@ -9,13 +9,13 @@
</div> </div>
<% end %> <% end %>
<div class="control-group"> <div class="control-group">
<%= f.label :title, :class=>"control-label" %> <%= f.label t("title"), :class=>"control-label" %>
<div class="controls"> <div class="controls">
<%= f.text_field :title %> <%= f.text_field :title %>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :note, :class=>"control-label" %> <%= f.label t("calendar.note"), :class=>"control-label" %>
<div class="controls"> <div class="controls">
<%= f.text_area :note, :rows => 3 %> <%= f.text_area :note, :rows => 3 %>
</div> </div>
@ -24,12 +24,12 @@
<label class="control-label"></label> <label class="control-label"></label>
<div class="controls"> <div class="controls">
<label> <label>
<%= f.check_box :all_day,:id=>"all_day_check", :checked => @all_day %> All Day <%= f.check_box :all_day,:id=>"all_day_check", :checked => @all_day %> <%= t('calendar.all_day') %>
</label> </label>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :start, :class=>"control-label" %> <%= f.label t("start_date"), :class=>"control-label" %>
<%#= f.datetime_select :start %> <%#= f.datetime_select :start %>
<div class="controls"> <div class="controls">
<div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick"> <div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick">
@ -44,7 +44,7 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :end, :class=>"control-label" %> <%= f.label t("end_date"), :class=>"control-label" %>
<%#= f.datetime_select :end %> <%#= f.datetime_select :end %>
<div class="controls"> <div class="controls">
<div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick"> <div data-date-format="yyyy/MM/dd hh:mm" data-language="en" data-picktime="true" class="input-append datetimepick">
@ -60,7 +60,7 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label "Calendar", :class=>"control-label" %> <%= f.label t("calendar.calendar"), :class=>"control-label" %>
<div class="controls"> <div class="controls">
<%= f.select :calendar_type_id, @categories.collect{|t| [ t.title, t.id ]} %> <%= f.select :calendar_type_id, @categories.collect{|t| [ t.title, t.id ]} %>
</div> </div>
@ -69,15 +69,15 @@
<label class="control-label"></label> <label class="control-label"></label>
<div class="controls"> <div class="controls">
<label> <label>
<%= f.check_box :recurring, :id=>"recurring_checkbox", :checked => @recurring %> Recurring <%= f.check_box :recurring, :id=>"recurring_checkbox", :checked => @recurring %> <%= t("calendar.recurring") %>
</label> </label>
</div> </div>
</div> </div>
<div id="recurring_panel" <%= (@recurring ? '' : "style=display:none;") %> > <div id="recurring_panel" <%= (@recurring ? '' : "style=display:none;") %> >
<div class="control-group"> <div class="control-group">
<%=f.label :period, "Repeats",:class=>"control-label" %> <%=f.label :period, t("calendar.repeats"),:class=>"control-label" %>
<div class="controls"> <div class="controls">
<%=f.select :period, Event::REPEATS,{},:class=>"span5" %> <%=f.select :period, Event::REPEATS.map{|v| [t("calendar.#{v.downcase}"),v]},{},:class=>"span5" %>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">

View File

@ -9,3 +9,11 @@ en:
select_calendar: "Select Calendar" select_calendar: "Select Calendar"
categories: Categories categories: Categories
new_category: New Category new_category: New Category
all_day: All Day
note: Note
repeats: Repeats
recurring: Recurring
daily: Daily
weekly: Weekly
monthly: Monthly
yearly: Yearly

View File

@ -7,3 +7,11 @@ zh_tw:
save: 儲存 save: 儲存
select_calendar: 選取行事曆 select_calendar: 選取行事曆
categories: 類別 categories: 類別
all_day: 全天
note: 註記
repeats: 重複
recurring: 週期性
daily: 每天
weekly: 每週
monthly: 每月
yearly: 每年