Announcement modifications and tags

This commit is contained in:
Christophe Vilayphiou committed 2012-02-15 00:34:22 +08:00
1 parent f57e9f19f7
commit 3e70634add
38 files changed
+615 -143

No files matched your search

@@ -8,11 +8,15 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
def index
# @bulletins = Bulletin.all
# @bulletins = Bulletin.desc("postdate desc")
get_categorys(params[:bulletin_category_id])
get_categorys(params[:bulletin_category_id])
# @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id]
@bulletins = Bulletin.search(params[:search],params[:category_id])
@bulletins = Bulletin.search(params[:search],params[:category_id])
@bulletin_categories = BulletinCategory.all
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
respond_to do |format|
format.html # index.html.erb
@@ -0,0 +1,8 @@
class Panel::Announcement::BackEnd::TagsController < Admin::TagsController
def initialize
super
@app_title = 'announcement'
end
end
@@ -8,6 +8,7 @@ class Bulletin
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_and_belongs_to_many :tags
field :postdate , :type => Date
field :deadline , :type => Date
@@ -19,6 +20,8 @@ class Bulletin
field :is_hot, :type => Boolean, :default => false
field :is_hidden, :type => Boolean, :default => false
field :public, :type => Boolean, :default => true
mount_uploader :image, ImageUploader
belongs_to :bulletin_category
@@ -30,9 +33,6 @@ class Bulletin
accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
accepts_nested_attributes_for :title, :allow_destroy => true
accepts_nested_attributes_for :subtitle, :allow_destroy => true
accepts_nested_attributes_for :text, :allow_destroy => true
validates_presence_of :title
@@ -1,9 +0,0 @@
class BulletinImage < BulletinFile
field :name
embedded_in :bulletin
mount_uploader :file, ImageUploader
end
@@ -0,0 +1,48 @@
<tr id="<%= dom_id bulletin %>">
<td><input type="checkbox"></td>
<td>
<% if bulletin.is_top? %>
<span class="label label-success"><%= t(:top) %></span>
<% end %>
<% if bulletin.is_hot? %>
<span class="label label-important"><%= t(:hot) %></span>
<% end %>
<% if bulletin.is_hidden? %>
<span class="label"><%= t(:hidden) %></span>
<% end %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Quick Edit<b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Basic</a></li>
<li><a href="#">Picture</a></li>
<li><a href="#">Tags</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">File</a></li>
</ul>
</li>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
</ul>
</div>
</td>
<td><%= bulletin.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) %></td>
<td><%= bulletin.postdate %></td>
<td><%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %></td>
<td>
<% bulletin.tags.each do |tag| %>
<span class="label label-tags"><%= tag[I18n.locale] %></span>
<% end %>
</td>
<td>rulingcom</td>
</tr>
<%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %>
<% content_for :page_specific_javascript do %>
<script>
</script>
<% end %>
@@ -1,18 +0,0 @@
<tr id="<%= dom_id post %>">
<td></td>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%#= link_to post.title, panel_announcement_front_end_bulletin_path(post) %>
<%= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= post.postdate %></td>
<td><%= (post.deadline) ? post.deadline : t('bulletin.no_deadline') %></td>
<td>
<%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(post) %> |
<%= link_to t(:set_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => true})"), :remote => true, :method => :put, :id => "disable_#{post.id}", :style => "display:#{post.is_top? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:cancel_top), eval("panel_announcement_back_end_bulletin_path(post, :authenticity_token => form_authenticity_token, :bulletin => {:is_top => false})"), :remote => true, :method => :put, :id => "enable_#{post.id}", :style => "display:#{post.is_top? ? '' : 'none'}", :class => 'switch' %>
| <%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(post), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %>
</td>
</tr>
@@ -0,0 +1,56 @@
<div class="subnav">
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:status) %> <b class="web-symbol"></b></a>
</div>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:category) %> <b class="web-symbol"></b></a>
</div>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:tags) %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="filters">
<div class="accordion-body collapse" id="collapse-status">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Category1</a>
<a href="#" class="btn">Category2</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
<div class="accordion-body collapse" id="collapse-category">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Category1</a>
<a href="#" class="btn">Category2</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Tag1</a>
<a href="#" class="btn">Tag2</a>
<a href="#" class="btn">Tag3</a>
<a href="#" class="btn">Tag4</a>
<a href="#" class="btn">Tag5</a>
<a href="#" class="btn">Tag6</a>
<a href="#" class="btn">Tag7</a>
<a href="#" class="btn">Tag8</a>
<a href="#" class="btn">Tag9</a>
<a href="#" class="btn">Tag10</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
</div>
</div>
@@ -20,7 +20,10 @@
<%= f.label :title %>
<%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_field locale %></td>
<td>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale %>
</td>
<% end %>
<% end %>
</div>
@@ -29,7 +32,10 @@
<%= f.label :subtitle %>
<%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_area locale, :rows => 10, :cols => 40 %></td>
<td>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
</td>
<% end %>
<% end %>
</div>
@@ -38,7 +44,10 @@
<%= f.label :text %>
<%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %>
<% @site_valid_locales.each do |locale| %>
<td><%= f.text_area locale, :rows => 10, :cols => 40 %></td>
<td>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :rows => 10, :cols => 40 %>
</td>
<% end %>
<% end %>
</div>
@@ -0,0 +1,16 @@
<!-- <tr class="qe-block hide"> -->
<tr class="qe-block">
<td colspan="8">
<legend>Quick Edit - Basic / Picture / Tags / Link / File</legend>
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'form-horizontal'} do |f| %>
<%= render :partial => "quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %>
<%#= render :partial => "quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %>
<%= render :partial => "quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %>
<div class="form-actions">
<%= f.submit t(:submit), :class => 'btn btn-primary' %>
<%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %>
</div>
<% end %>
</td>
</tr>
@@ -0,0 +1,62 @@
<div id="qe-basic">
<div id="widget-category">
<div class="control-group">
<label class="control-label"><%= t(:category) %></label>
<div class="controls">
<%= f.select :bulletin_category_id, @bulletin_categories.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => 'input-large' %>
</div>
</div>
</div>
<div id="widget-title">
<%= f.fields_for :title, bulletin.title do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %>
</div>
</div>
<% end %>
<% end %>
</div>
<div id="widget-date">
<div class="control-group">
<label class="control-label"><%= t(:start) %></label>
<div class="controls">
<%= f.date_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' %>
</div>
</div>
</div>
<div id="widget-status">
<div class="control-group">
<label class="control-label"><%= t(:status) %></label>
<div class="controls">
<label class="checkbox inline"><%= f.check_box :is_hot %><%= t(:hot) %></label>
<label class="checkbox inline"><%= f.check_box :is_top %><%= t(:top) %></label>
<label class="checkbox inline"><%= f.check_box :is_hidden %><%= t(:hidden) %></label>
</div>
</div>
</div>
<div id="widget-role">
<div class="control-group">
<label class="control-label">Role</label>
<div class="controls">
<label class="radio inline"><%= f.radio_button :public, true, :class => 'privacy' %>Public</label>
<label class="radio inline"><%= f.radio_button :public, false, :class => 'privacy' %>Private</label>
<div class="well select-role" style="display:<%= bulletin.public ? 'none' : 'block' %>;">
<label class="checkbox inline"><input type="checkbox" value="student">Student</label>
<label class="checkbox inline"><input type="checkbox" value="teacher">Teacher</label>
<label class="checkbox inline"><input type="checkbox" value="staff">Staff</label>
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,62 @@
<div id="qe-file">
<div id="widget-file">
<div class="control-group">
<table class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>
<th>English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-file" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>…</td>
<td>…</td>
<td><a href="#modal-file" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
</tbody>
</table>
</div>
<div id="modal-file" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add File / Edit File</h3>
</div>
<div class="modal-body form-horizontal">
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse
<input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fn').innerHTML = this.value;">
</label>
<span id='fn' class="file-name"></span>
</div>
<div class="control-group">
<label for="file-zh-tw" class="control-label">Chinese</label>
<div class="controls">
<input type="text" value="" id="file-zh-tw" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label for="file-en" class="control-label">English</label>
<div class="controls">
<input type="text" value="" id="file-en" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div>
</div>
@@ -0,0 +1,62 @@
<div id="qe-link">
<div id="widget-link">
<div class="control-group">
<table class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>
<th>English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-link" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>…</td>
<td>…</td>
<td><a href="#modal-link" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
</tbody>
</table>
</div>
<div id="modal-link" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add Link / Edit Link</h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="http" class="control-label">http://</label>
<div class="controls">
<input type="text" value="" id="http" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group error">
<label for="link-zh-tw" class="control-label">Chinese</label>
<div class="controls">
<input type="text" value="" id="link-zh-tw" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label for="link-en" class="control-label">English</label>
<div class="controls">
<input type="text" value="" id="link-en" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div>
</div>
@@ -0,0 +1,19 @@
<div id="qe-picture">
<div id="widget-picture">
<div class="control-group">
<label class="control-label">Picture</label>
<div class="control-group">
<img class="pull-left upload-picture" src="img/default-img.png" />
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse/選擇檔案
<input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fu').innerHTML = this.form.fu.value = this.value;">
</label>
<span id='fu' class="file-name"></span>
<br>
<input name='fu' class="input-large" type="text">
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,44 @@
<!-- <div id="qe-tags">
<div id="widget-tags">
<div class="form-horizontal">
<div class="control-group error">
<label class="control-label" for="tags-zh-tw">
Chinese
</label>
<div class="controls">
<input id='tags-zh-tw' class="input-prepend" type="text">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="tags-en">
English
</label>
<div class="controls">
<input id='tags-en' class="input-prepend" type="text">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<hr>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
</div>
</div>
</div>
</div>
</div> -->
<div id="qe-tags">
<div id="widget-tags">
<div class="form-horizontal">
<% @tags.each do |tag| %>
<%= check_box_tag 'bulletin[tag_ids][]', tag.id, bulletin.tag_ids.include?(tag.id)%>
<%= tag[I18n.locale] %>
<% end %>
</div>
</div>
</div>
@@ -39,95 +39,33 @@
<br />
<br />
<h1><%= t('bulletin.list_announcement') %></h1>
<table>
<tr>
<th><%= t('bulletin.status') %></th>
<th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.action') %></th>
</tr>
<% @bulletins.each do |post| %>
<%= render :partial => 'bulletins', :locals => {:post => post} %>
<% end %>
</table>
<br />
-->
<%= render 'filter' %>
<table class="table main-list">
<thead>
<tr>
<th class="span1 strong">
<input type="checkbox">
<a href class="list-remove"><i class="icon-trash"></i></a>
</th>
<th class="span1"><%= t('bulletin.status') %></th>
<th class="span1-2"><%= t('bulletin.category') %></th>
<th class="span7 select"><%= t('bulletin.title') %></th>
<th class="span1-2"><%= t('bulletin.start_date') %></th>
<th class="span1-2"><%= t('bulletin.end_date') %></th>
<th class="span1-2"><%= t('bulletin.tags') %></th>
<th class="span1-2"><%= t('bulletin.last_modified') %></th>
</tr>
</thead>
<tbody>
<%= render :partial => 'bulletin', :collection => @bulletins %>
</tbody>
</table>
<div class="subnav">
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent=".filters" class="accordion-toggle">Status <b class="web-symbol"></b></a>
</div>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent=".filters" class="accordion-toggle">Category <b class="web-symbol"></b></a>
</div>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent=".filters" class="accordion-toggle">Tags <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="filters">
<div class="accordion-body collapse" id="collapse-status">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Category1</a>
<a href="#" class="btn">Category2</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
<div class="accordion-body collapse" id="collapse-category">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Category1</a>
<a href="#" class="btn">Category2</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Tag1</a>
<a href="#" class="btn">Tag2</a>
<a href="#" class="btn">Tag3</a>
<a href="#" class="btn">Tag4</a>
<a href="#" class="btn">Tag5</a>
<a href="#" class="btn">Tag6</a>
<a href="#" class="btn">Tag7</a>
<a href="#" class="btn">Tag8</a>
<a href="#" class="btn">Tag9</a>
<a href="#" class="btn">Tag10</a>
<a href="#" class="btn">Tag11</a>
<a href="#" class="btn">Tag12</a>
<a href="#" class="btn">Tag13</a>
<a href="#" class="btn">Tag14</a>
<a href="#" class="btn">Tag15</a>
<a href="#" class="btn">Tag16</a>
<a href="#" class="btn">Tag17</a>
<a href="#" class="btn">Tag18</a>
<a href="#" class="btn">Tag19</a>
<a href="#" class="btn">Tag20</a>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>
</div>
</div>
</div>
<div class="form-actions">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
</div>
@@ -1,24 +1,6 @@
<br />
<br />
<br />
<br />
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('bulletin.index'), panel_announcement_back_end_bulletins_path, :class => 'seclink2' %></li>
</ul>
<% end -%>
<%= flash_messages %>
<h1><%= t('bulletin.new_announcement') %></h1>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
<br />
<br />
<br />
<%= link_back %>
+4 -3
View File
@@ -5,9 +5,10 @@ Rails.application.routes.draw do
namespace :back_end do
root :to => "bulletins#index"
resources :bulletins
resources :bulletin_categorys, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
resources :bulletin_categorys, :controller => 'bulletin_categorys' do
match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit
end
resources :tags
end
namespace :front_end do
root :to => "bulletins#index"