Add time to announcement quick edit

Fix picture for news quick edit
Fix tags not saving when empty
Hide role in quick edit
This commit is contained in:
Christophe Vilayphiou 2012-08-14 14:38:21 +08:00
parent 77224bcc8f
commit fb53ad524a
15 changed files with 42 additions and 16 deletions

View File

@ -18,8 +18,16 @@ class Asset
belongs_to :assetable, polymorphic: true
has_and_belongs_to_many :tags, :class_name => "AssetTag"
before_save :clean_tags
def sorted_tags
tags.order_by(I18n.locale, :asc)
end
protected
def clean_tags
self.tag_ids.delete('')
end
end

View File

@ -26,6 +26,7 @@
<%= content_tag :label, :class => "checkbox inline" do -%>
<%= check_box_tag 'asset[tag_ids][]', tag.id, @asset.tag_ids.include?(tag.id) %>
<%= tag[I18n.locale] %>
<%= hidden_field_tag 'asset[tag_ids][]', '' %>
<% end %>
<% end %>
</div>

View File

@ -307,7 +307,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
params[:bulletin].delete("deadline(3i)")
params[:bulletin].delete("deadline(4i)")
params[:bulletin].delete("deadline(5i)")
end
end rescue nil
end
# def get_categories_for_index(id = nil)

View File

@ -62,7 +62,7 @@ class Bulletin
validates :title, :at_least_one => true
before_save :check_deadline, :update_avliable_language
before_save :check_deadline, :update_avliable_language, :clean_tags
before_save :fetch_dept
after_save :save_bulletin_links
@ -224,4 +224,8 @@ class Bulletin
self.cache_dept = (User.find(self.create_user_id).cache_dept rescue nil) if self.new_record?
end
def clean_tags
self.tag_ids.delete('')
end
end

View File

@ -70,8 +70,9 @@
<p>
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id) %>
<%= tag[I18n.locale] %>
<%= hidden_field_tag 'bulletin[tag_ids][]', '' %>
<% end %>
<% end %>
</p>

View File

@ -25,13 +25,13 @@
<div class="control-group">
<label class="control-label"><%= t(:start) %></label>
<div class="controls">
<%= f.date_select :postdate, {}, :class => 'input-small' %>
<%= f.datetime_select :postdate, {}, :class => 'input-small' %>
</div>
</div>
<div class="control-group">
<label class="control-label"><%= t(:end) %></label>
<div class="controls">
<%= f.date_select :deadline, {}, :class => 'input-small' %>
<%= f.datetime_select :deadline, {}, :class => 'input-small' %>
</div>
</div>
</div>
@ -47,7 +47,7 @@
</div>
</div>
<% end -%>
<div id="widget-role">
<!-- <div id="widget-role">
<div class="control-group">
<label class="control-label">Role</label>
<div class="controls">
@ -60,5 +60,5 @@
</div>
</div>
</div>
</div>
</div> -->
</div>

View File

@ -4,9 +4,10 @@
<div class="form-horizontal">
<% @tags.each do |tag| %>
<label class="checkbox inline">
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, bulletin.tag_ids.include?(tag.id)%>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, bulletin.tag_ids.include?(tag.id) %>
<%= tag[I18n.locale] %>
</label>
<%= hidden_field_tag 'bulletin[tag_ids][]', '' %>
<% end %>
</div>
</div>

View File

@ -341,7 +341,7 @@ protected
params[:news_bulletin].delete("deadline(1i)")
params[:news_bulletin].delete("deadline(2i)")
params[:news_bulletin].delete("deadline(3i)")
end
end rescue nil
end
# def get_categories_for_index(id = nil)

View File

@ -62,7 +62,7 @@ class NewsBulletin
validates :title, :at_least_one => true
before_save :check_deadline
before_save :update_avliable_language
before_save :update_avliable_language, :clean_tags
after_save :save_news_bulletin_links
after_save :save_news_bulletin_files
@ -239,6 +239,7 @@ class NewsBulletin
end
protected
def update_avliable_language
VALID_LOCALES.each do |locale|
if (title_translations[locale].blank? rescue true)
@ -255,5 +256,8 @@ class NewsBulletin
end
end
def clean_tags
self.tag_ids.delete('')
end
end

View File

@ -96,6 +96,7 @@
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'news_bulletin[tag_ids][]', tag.id, @news_bulletin.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %>
<%= hidden_field_tag 'news_bulletin[tag_ids][]', '' %>
<% end %>
<% end %>
</div>

View File

@ -48,7 +48,7 @@
</div>
<% end -%>
<div id="widget-role">
<!-- <div id="widget-role">
<div class="control-group">
<label class="control-label">Role</label>
<div class="controls">
@ -61,5 +61,5 @@
</div>
</div>
</div>
</div>
</div> -->
</div>

View File

@ -4,7 +4,7 @@
<!--<label class="control-label">Picture</label>-->
<div class="control-group">
<div class="controls upload-picture">
<img class="pull-left upload-picture" src="" />
<%= image_tag(@news_bulletin.image.url , :class => "pull-left") if @news_bulletin.image? %>
</div>
<div class="controls file-upload input-prepend">
<label class="control-label add-on btn" for="input-upload">

View File

@ -6,6 +6,7 @@
<label class="checkbox inline">
<%= check_box_tag 'news_bulletin[tag_ids][]', tag.id, news_bulletin.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %>
<%= hidden_field_tag 'news_bulletin[tag_ids][]', '' %>
</label>
<% end %>
</div>

View File

@ -22,7 +22,7 @@ class WebLink
belongs_to :web_link_category
before_save :update_avliable_language
before_save :update_avliable_language, :clean_tags
validates :title, :at_least_one => true
@ -76,4 +76,8 @@ class WebLink
end
end
def clean_tags
self.tag_ids.delete('')
end
end

View File

@ -39,6 +39,7 @@
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %>
<%= hidden_field_tag 'web_link[tag_ids][]', '' %>
<% end %>
<% end %>
</div>