fix error
This commit is contained in:
parent
12e68a6b3b
commit
53ab1b77bd
|
@ -60,7 +60,7 @@ class Admin::CalendarsController < OrbitAdminController
|
||||||
# GET /events/new
|
# GET /events/new
|
||||||
# GET /events/new.json
|
# GET /events/new.json
|
||||||
def new
|
def new
|
||||||
@event = Event.new
|
@event = Event.new(start: params[:startDate],end: params[:endDate])
|
||||||
categories = user_authenticated_categories rescue []
|
categories = user_authenticated_categories rescue []
|
||||||
if categories.first == "all"
|
if categories.first == "all"
|
||||||
@categories = CalendarType.all
|
@categories = CalendarType.all
|
||||||
|
@ -130,13 +130,13 @@ class Admin::CalendarsController < OrbitAdminController
|
||||||
# PUT /events/1.json
|
# PUT /events/1.json
|
||||||
def update
|
def update
|
||||||
@event = Event.find(params[:id])
|
@event = Event.find(params[:id])
|
||||||
p = event_page_params
|
p1 = event_page_params
|
||||||
p["update_user_id"] = current_user.id
|
p1["update_user_id"] = current_user.id
|
||||||
bulletin = @event.bulletin
|
bulletin = @event.bulletin
|
||||||
if !bulletin.nil?
|
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])
|
bulletin.update_attributes(calendar_start_date: p1[:start],calendar_end_date: p1[:end],calendar_all_day: p1[:all_day],calendar_type_id: p1[:calendar_type_id])
|
||||||
end
|
end
|
||||||
if @event.update_attributes!(p)
|
if @event.update_attributes(p1)
|
||||||
e = @event.to_json
|
e = @event.to_json
|
||||||
e = JSON.parse(e)
|
e = JSON.parse(e)
|
||||||
e["can_edit"] = true
|
e["can_edit"] = true
|
||||||
|
|
|
@ -44,6 +44,7 @@ class Event
|
||||||
if !m.nil?
|
if !m.nil?
|
||||||
if self.key.nil?
|
if self.key.nil?
|
||||||
m.event_id = nil
|
m.event_id = nil
|
||||||
|
m.add_to_calendar = false
|
||||||
else
|
else
|
||||||
m.calendar_dict.delete(self.key)
|
m.calendar_dict.delete(self.key)
|
||||||
if !m['calendar_data'].nil?
|
if !m['calendar_data'].nil?
|
||||||
|
@ -56,11 +57,15 @@ class Event
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
before_save do
|
||||||
|
self['title_translations'] = self['title_translations'].merge({I18n.locale.to_s =>self['title']})
|
||||||
|
self['note_translations'] = self['title_translations'].merge({I18n.locale.to_s =>self['note']})
|
||||||
|
end
|
||||||
########################################
|
########################################
|
||||||
validates_presence_of :title, :message => "Please fill the title of the Event", :if => lambda { self['title_translations'].blank? }
|
validates_presence_of :title, :message => "Please fill the title of the Event", :if => lambda { self['title_translations'].blank? }
|
||||||
validates_presence_of :title_translations, :message => "Please fill the title of the Event", :if => lambda { self['title'].blank? }
|
validates_presence_of :title_translations, :message => "Please fill the title of the Event", :if => lambda { self['title'].blank? }
|
||||||
def title
|
def title
|
||||||
tp = self['title_translations'][I18n.locale]
|
tp = self['title_translations'][I18n.locale] rescue nil
|
||||||
tp.blank? ? self['title'] : tp
|
tp.blank? ? self['title'] : tp
|
||||||
end
|
end
|
||||||
def note
|
def note
|
||||||
|
@ -76,7 +81,7 @@ class Event
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def bulletin
|
def bulletin
|
||||||
Bulletin.find(self.bulletin_id) rescue nil
|
model_class=='Bulletin' ? (Bulletin.find(self.model_id) rescue nil) : nil
|
||||||
end
|
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)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<%= javascript_include_tag 'jquery.base64' %>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.controls[data-toggle^="buttons-"] input[type="checkbox"] {
|
.controls[data-toggle^="buttons-"] input[type="checkbox"] {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
|
@ -13,6 +14,32 @@
|
||||||
.controls[data-toggle^="buttons-"] .checkbox.inline.btn{
|
.controls[data-toggle^="buttons-"] .checkbox.inline.btn{
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
div[contentEditable=true]:empty:before{
|
||||||
|
content: attr(data-ph);
|
||||||
|
color: grey;
|
||||||
|
padding-left: 3%;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: serif;
|
||||||
|
}
|
||||||
|
div[contentEditable=true] {
|
||||||
|
background: white;
|
||||||
|
color: black;
|
||||||
|
border: 0.1em solid #cccccc;
|
||||||
|
font-size: 1.15em;
|
||||||
|
padding: 0.3em 0 0.3em 3%;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
div[contentEditable=true]:focus {
|
||||||
|
border-color: rgba(82, 168, 236, 0.8);
|
||||||
|
outline: 0;
|
||||||
|
outline: thin dotted \9;
|
||||||
|
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||||
|
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<% if @event.errors.any? %>
|
<% if @event.errors.any? %>
|
||||||
<div id="error_explanation">
|
<div id="error_explanation">
|
||||||
|
@ -27,13 +54,15 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label t("title"), :class=>"control-label" %>
|
<%= f.label t("title"), :class=>"control-label" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :title %>
|
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment"><%= @event.title.to_s.html_safe %></div>
|
||||||
|
<%= f.hidden_field :title %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label t("calendar.note"), :class=>"control-label" %>
|
<%= f.label t("calendar.note"), :class=>"control-label" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_area :note, :rows => 3 %>
|
<div data-ph="<%= t('calendar.press_enter') %>" contenteditable="true" class="calendar-comment"><%= @event.note.to_s.html_safe %></div>
|
||||||
|
<%= f.hidden_field :note %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -55,14 +84,14 @@
|
||||||
<%= f.label t("start_date"), :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">
|
||||||
<%= f.datetime_picker :start, :class => "input-large", data: {"fv-validation" => "required;","fv-messages" => "Cannot be empty;"}, :placeholder => data_format, :new_record => @event.new_record?, :format => data_format %>
|
<%= f.datetime_picker :start, :class => "input-large", data: {"fv-validation" => "required;","fv-messages" => "Cannot be empty;"}, :placeholder => data_format, :new_record => false, :format => data_format %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label t("end_date"), :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">
|
||||||
<%= f.datetime_picker :end, :class => "input-large", :placeholder => data_format, :new_record => @event.new_record?, :format=> data_format %>
|
<%= f.datetime_picker :end, :class => "input-large", :placeholder => data_format, :new_record => false, :format=> data_format %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -103,14 +132,34 @@
|
||||||
<div class="control-group last">
|
<div class="control-group last">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<% if action_name == "edit" %>
|
<% if action_name == "edit" %>
|
||||||
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
|
<%= f.button t("calendar.save"),:type=> 'button', :class=>"btn btn-primary", :onclick => 'before_submit(this)' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= f.submit t(:create_), :class=>"btn btn-primary" %>
|
<%= f.button t(:create_),:type=> 'button', :class=>"btn btn-primary", :onclick => 'before_submit(this)' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="" class="btn btn-close">Cancel</a>
|
<a href="" class="btn btn-close">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
function getFormData($form){
|
||||||
|
var unindexed_array = $form.serializeArray();
|
||||||
|
var indexed_array = {};
|
||||||
|
|
||||||
|
$.map(unindexed_array, function(n, i){
|
||||||
|
indexed_array[n['name']] = n['value'];
|
||||||
|
});
|
||||||
|
|
||||||
|
return indexed_array;
|
||||||
|
}
|
||||||
|
function before_submit(ele){
|
||||||
|
var self = $(ele).parents('form')
|
||||||
|
var length = self.find('*[contenteditable="true"]').length
|
||||||
|
for (var i=0;i<length;i++){
|
||||||
|
var tp1 = self.find('*[contenteditable="true"]').eq(i)
|
||||||
|
var tp2 = tp1.parents('.controls').eq(0).find('input[type="hidden"]')
|
||||||
|
tp2.val(tp1.html())
|
||||||
|
}
|
||||||
|
self.submit()
|
||||||
|
}
|
||||||
$('body').ready(function(){
|
$('body').ready(function(){
|
||||||
if ($('.default_picker,.time_picker,.date_picker').find('input').length!=0){
|
if ($('.default_picker,.time_picker,.date_picker').find('input').length!=0){
|
||||||
$('.default_picker,.time_picker,.date_picker').find('.iconbtn').css('display','none')
|
$('.default_picker,.time_picker,.date_picker').find('.iconbtn').css('display','none')
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
en:
|
en:
|
||||||
calendar:
|
calendar:
|
||||||
|
press_enter: Press enter to add a newline
|
||||||
all: All
|
all: All
|
||||||
calendar: Calendar
|
calendar: Calendar
|
||||||
calendars: Calendars
|
calendars: Calendars
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
calendar:
|
calendar:
|
||||||
|
press_enter: 按下enter可以換行
|
||||||
calendar: 行事曆
|
calendar: 行事曆
|
||||||
calendars: 我的行事曆
|
calendars: 我的行事曆
|
||||||
color: 顏色
|
color: 顏色
|
||||||
|
|
Loading…
Reference in New Issue