Compare commits

...

8 Commits
master ... ydu

Author SHA1 Message Date
spen 4fbea06642 fix show pagination 2014-11-24 10:32:41 +08:00
spen ce2ec4fc1a add sync_data 2014-08-21 17:27:52 +08:00
spen 39386930ef update back end index list 2014-07-25 15:04:57 +08:00
spen ca2b66a210 Merge branch 'ydu' of gitlab.tp.rulingcom.com:root/orbit-announcement into ydu 2014-06-17 09:55:30 +08:00
spen a39d979a54 fix field 2014-06-16 15:04:22 +08:00
spen d88b2a4e32 ydu 2014-06-16 15:04:21 +08:00
spen 768f03954f fix field 2014-05-20 17:49:18 +08:00
spen 64b80092f6 ydu 2014-05-13 16:29:23 +08:00
11 changed files with 267 additions and 6 deletions

View File

@ -25,7 +25,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
if is_manager? or is_admin?
@bulletins = get_sorted_and_filtered("bulletin", :category_id.in => category_ids)
else
@bulletins = get_sorted_and_filtered("bulletin", {:category_id.in => category_ids, :create_user_id => current_user.id})
end
respond_to do |format|
format.html # index.html.erb
format.js { }
@ -70,7 +75,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@tags = get_tags
is_authorized_sub_manager = @bulletin.category.auth_sub_manager.authorized_user_ids rescue nil
if !(is_manager? || is_admin? || is_authorized_sub_manager.include?(current_user.id))
if !(is_manager? || is_admin? || (is_authorized_sub_manager.include?(current_user.id) and @bulletin.create_user_id == current_user.id))
redirect_to :action => :index
else
# @summary_variable = @bulletin.summary_variable

View File

@ -167,4 +167,24 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@part = PagePart.find params[:part_id]
end
def sync_data
@create_users = ( params[:dept].blank? or !params[:dept].kind_of?(Array)) ? [] : User.where(:sid.in => params[:dept]).collect{|p| p.id}
@page_num = params[:page_num].blank? ? '10' : params[:page_num]
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.nin => ['53abbd0b45ef444e6a0001a0','53abbd2045ef444e6a00095d','53abbd0745ef444e6a000001'], :create_user_id.in => @create_users).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
end
def show_sync_data
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
if @bulletin and !@bulletin.disable?
if @bulletin.enabled_for_lang(I18n.locale.to_s)
impressionist(@bulletin)
else
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
end
else
render :nothing => true, :status => 403
end
end
end

View File

@ -67,6 +67,11 @@ class Bulletin
self.category.title
end
def bulletin_create_dept
unit_field = User.get_member_list_attribute_field("staff","unit")
User.get_member_list_attribute_value(self.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
end
def get_bulletin_category
self.category
end

View File

@ -1,4 +1,8 @@
<% set_default_index do
<%
@unit_field = User.get_member_list_attribute_field("staff","unit")
set_default_index do
objects @bulletins
quick_edit_link type: 'edit',
link: 'edit_panel_announcement_back_end_bulletin_path'
@ -49,6 +53,11 @@
translation: 'last_modified',
hide: 'phone',
sort: 'last_modified'
field db_field: 'update_user_id',
translation: 'announcement.default_widget.bulletin_create_dept',
display_option: 'User.get_member_list_attribute_value(object.create_user_id,@unit_field.id).get_value_by_locale(I18n.locale) rescue nil',
sort: 'last_modified'
filter_field type: 'array',
values: @statuses,
translation: 'status'

View File

@ -4,8 +4,11 @@
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<% unit = @bulletin.cache_dept[I18n.locale.to_s] rescue nil %>
<span><%= link_to unit,panel_announcement_front_end_index_bulletins_by_unit_path(:name=>unit) unless unit.blank? %></span>
<%
unit_field = User.get_member_list_attribute_field("staff","unit")
unit = User.get_member_list_attribute_value(@bulletin.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
%>
<span><%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %></span>
</div>
</div>
<div class="news_paragraph">

View File

@ -0,0 +1,110 @@
<% # encoding: utf-8 %>
<style type="text/css">
.h1{
font: 22px/1.5 'open sans','微軟正黑體',sans-serif;
margin: 0 0 10px;
padding: 0;
}
.info {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #DDDDDD;
font: 13px/1 'arial',sans-serif;
margin: 0 0 20px;
overflow: hidden;
padding: 10px;
}
.info span {
margin: 0 7px 0 0;
border-right: 1px solid #ddd;
padding: 0 10px 0 0;
}
.news_paragraph{
margin: 0 0 20px;
}
.linkAndFile{
border-top: 1px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
border-radius: 5px 5px 0 0;
clear: both;
overflow: hidden;
padding: 10px 10px 0 10px;
}
.fb{
border-bottom : 1px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
border-radius: 0 0 5px 5px;
clear: both;
overflow: hidden;
padding: 5px 10px 5px 10px;
}
.linkAndFile>div{
border-bottom: 1px solid #CCCCCC;
display: block;
margin: 0 0 5px;
overflow: hidden;
padding: 0 0 5px;
}
.icons-link, .icons-paperclip{
float: left;
margin: 0 10px 0 0;
}
.showLink, .showFile {
float: left;
}
.showLink a, .showFile a{
margin: 0 10px 0 0;
}
.fb a{
margin: 0 5px 0 0;
}
.showLink:before, .showFile:before {
content: "●";
margin: 0 10px 0 5px;
color: #333;
}
</style>
<h1 class="h1"><%= @bulletin.title %></h1>
<div class="info">
<div class="info1">
<span class="category"><%= t('announcement.categories') %> : <%= @bulletin.category.title rescue nil %></span>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<%
unit_field = User.get_member_list_attribute_field("staff","unit")
unit = User.get_member_list_attribute_value(@bulletin.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
%>
<span><%= t('announcement.default_widget.bulletin_create_dept') + ": " + unit unless unit.blank? %></span>
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
</div>
</div>
<div class="news_paragraph">
<%= @bulletin.text.html_safe rescue '' %>
</div>
<div class="linkAndFile">
<% if @bulletin.bulletin_links.size > 0 %>
<div>
<i class="icons-link"></i>
<div class="showLink">
<% @bulletin.bulletin_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %>
</div>
</div>
<% end %>
<% if @bulletin.bulletin_files.size > 0 %>
<div>
<i class="icons-paperclip"></i>
<div class="showFile">
<% @bulletin.bulletin_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %>
</div>
</div>
<% end %>
</div>
<%= share_links(@bulletin, 'announcement') %>

View File

@ -0,0 +1,103 @@
<% # encoding: utf-8 %>
<style type="text/css">
th {
background: #fff;
border-bottom: 2px solid #333;
padding: 10px 5px;
font: 15px/1 '微軟正黑體',sans-serif;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
td {
padding: 10px 5px;
font: 13px/1.5 'arial',sans-serif;
vertical-align: top;
text-align: left;
border-bottom: 1px solid #eee;
}
tr{
background: #fafafa
}
.odd{
background: #fff;
}
td a {
text-decoration: none;
color: #333;
}
td a:hover {
color: #000;
}
.pagination{
margin: 10px 0;
}
.pagination ul{
margin: 0;
padding: 0;
}
.pagination li:first-child {
border-radius: 5px 0 0 5px;
}
.pagination li {
background: none repeat scroll 0 0 #FFFFFF !important;
border: 1px solid #ccc;
border-right: 0px solid #ccc;
display: block;
float: left;
font: 13px/30px 'open sans',sans-serif !important;
padding: 0 10px !important;
}
.pagination li:last-child {
border-radius: 0 5px 5px 0;
border-right: 1px solid #ccc;
}
.pagination li a {
color: #333;
text-decoration: none;
}
.pagination li a:hover {
color: #000;
}
</style>
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
<table class="table table-bordered">
<tr>
<th><%= t('announcement.categories') %></th>
<th><%= t('announcement.default_widget.title') %></th>
<th><%= t('announcement.default_widget.postdate') %></th>
<th><%= t('announcement.default_widget.bulletin_create_dept') %></th>
</tr>
<% @bulletins.each_with_index do |post, i| %>
<tr <%= (i % 2 == 0) ? 'class=odd' : '' %>>
<td><%= post.category.title rescue nil %></td>
<td><a href="JavaScript:newPopup('<%= panel_announcement_widget_show_sync_data_path(post) %>');"><%= post.title %></a></td>
<td><%= display_date(post.postdate) %></td>
<%
unit_field = User.get_member_list_attribute_field("staff","unit")
unit = User.get_member_list_attribute_value(post.create_user_id,unit_field.id).get_value_by_locale(I18n.locale) rescue nil
%>
<td><%= unit %></td>
</tr>
<% end %>
</table>
<%= paginate( @bulletins, :param_name => :page_main, :params => {:inner => 'false'} ) rescue nil if params[:show_page] == 'true' %>

View File

@ -18,6 +18,7 @@ en:
postdate: Post Date
subtitle: Subtitle
title: Title
bulletin_create_dept: Unit
editing_announcement: Edit Announcement
editing_announcement_category: Edit Category
file: Attachment

View File

@ -18,6 +18,7 @@ zh_tw:
postdate: 張貼日期
subtitle: 副標題
title: 標題
bulletin_create_dept: 單位
editing_announcement: 編輯類別
editing_announcement_category: 編輯類別
error:

View File

@ -40,6 +40,8 @@ Rails.application.routes.draw do
match "reload_web_links" => "bulletins#reload_web_links"
match "bulletins_side_bar" => "bulletins#bulletins_side_bar"
match "bulletins_search_block" => "bulletins#bulletins_search_block"
match "sync_data" => "bulletins#sync_data",:as => :sync_data,:via => :get
match "show_sync_data/:id" => "bulletins#show_sync_data",:as => :show_sync_data,:via => :get
end
namespace :api do
get "categories_tags.json" => "bulletins#get_categories_tags"

View File

@ -41,6 +41,7 @@ module Announcement
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:category,:id]}}
field :subtitle
field :bulletin_create_dept
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
end