Merge branch 'design_team' into ldap

Conflicts:
	vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_approvals_controller.rb
	vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_news_bulletin.html.erb
This commit is contained in:
Christophe Vilayphiou 2012-05-22 20:33:07 +08:00
commit f1c8bed29d
76 changed files with 348 additions and 171 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -0,0 +1,7 @@
jQuery(document).ajaxStart(function(){
$('<div class="modal-backdrop fade in" id="sys_modal"><img src="/assets/ajax-loader.gif" style="margin-top: 25%;margin-left: 50%;"></div>').appendTo('body');
});
jQuery(document).ajaxComplete(function(){
$("#sys_modal").hide().remove();
});

View File

@ -40,11 +40,11 @@ $(".nav-tabs").find(".icons-pencil").click(function(){
data: { body: content_holder.html() },
success: function(json) {
$(selector).attr("contenteditable",false)
alert("<%= I18n.t("admin.contenteditable.update_done") %>");
alert("<%= I18n.t('admin.contenteditable.update_done') %>");
//content_holder.effect('highlight', {'color': '#0f0'}, 3000);
},
error: function() {
alert("<%= I18n.t("admin.contenteditable.update_failed") %>");
alert("<%= I18n.t('admin.contenteditable.update_failed') %>");
//content_holder.effect('highlight', {'color': '#f00'}, 3000);
content_holder.html(content);
}

View File

@ -17,3 +17,4 @@
//= require side_bar_history
//= require rss
//= require ajax_form
//= require inc/ajax_setting

View File

@ -34,6 +34,10 @@ $('.part_kind').live('click', function() {
});
$(document).ready(function(){
bindTreeDragHandle();
});
var bindTreeDragHandle = function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
@ -52,4 +56,4 @@ $(document).ready(function(){
$.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
}
});
});
}

View File

@ -1,14 +1,5 @@
var history_edited = false;
$('#back_sidebar a, #back_main a.nav').live('click',
function () {
$.getScript(this.href);
history.pushState(null, document.title, this.href);
history_edited = true;
return false;
}
);
$('#back_main a.reload').live('click',
function () {
$.getScript(this.href);
@ -18,7 +9,7 @@ $('#back_main a.reload').live('click',
}
);
$('#back_main .form').live('submit', function () {
$('#back_main form').live('submit', function () {
$.post(this.action, $(this).serialize(), null, 'script');
history_edited = true;
return false;

View File

@ -18,6 +18,18 @@
padding: 3px 0px;
display: block;
}
.nav-list>li>ol {
margin-left: 0;
}
.nav-list>li>.with_action {
padding-left: 0;
}
.nav-list>li>.with_action>.quick-edit {
margin: 0 0 0 3px !important;
}
.nav-list>li>.with_action>i {
display: none;
}
/*
#back_sidebar h1 {
background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent;
@ -126,7 +138,7 @@
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #DDDDDD;
border-radius: 5px 5px 5px 5px;
margin: 0 0 0 3px;
margin: 0 0 0 20px;
padding: 0;
z-index:1;
position: absolute;
@ -155,7 +167,7 @@ ol.nav>li>.icons-moves {
}
.sortable i {
position: absolute;
left: -20px;
left: 0px;
top: 6px;
margin-right: 0;
opacity: 0.3;
@ -166,6 +178,9 @@ ol.nav>li>.icons-moves {
opacity: 0.7;
filter: alpha(opacity=70);
}
.with_action {
padding-left: 20px;
}
.placeholder {
background-color: rgba(0,136,204,.6);
border-radius: 3px;

View File

@ -1,7 +1,7 @@
class Admin::AdBannersController < OrbitBackendController
layout "new_admin"
before_filter :authenticate_user!
before_filter :for_app_manager,:except => [:index,:show]
before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview]
before_filter :for_app_sub_manager
def rename

View File

@ -1,7 +1,7 @@
class Admin::AdImagesController < ApplicationController
class Admin::AdImagesController < OrbitBackendController
layout 'new_admin'
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :for_app_sub_manager
def edit
@ad_banner = AdBanner.find params[:ad_banner_id]

View File

@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController
end
def delete
@item = Link.find(params[:id])
@item.destroy
respond_to do |format|
format.html {}
format.js { destroy }
format.js { @item = @item.parent }
end
end

View File

@ -51,7 +51,7 @@ class Admin::PagesController < ApplicationController
def create
@item = Page.new(params[:page])
if @item.module_app.key == 'page_content'
if @item.module_app && @item.module_app.key == 'page_content'
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
end
@ -99,14 +99,16 @@ class Admin::PagesController < ApplicationController
format.html {
redirect_to admin_items_url( :parent_id => @item.parent_id )
}
format.js {}
format.js { redirect_to admin_items_url }
end
end
def delete
@item = Page.find(params[:id])
@item.destroy
respond_to do |format|
format.html {}
format.js { destroy }
format.js { @item = @item.parent }
end
end

View File

@ -157,7 +157,7 @@ class ApplicationController < ActionController::Base
end
def get_homepage
Item.first(:conditions => {:parent_id => nil})
Page.root
end
def layout_by_resource

View File

@ -32,13 +32,8 @@ class OrbitBackendController< ApplicationController
end
def get_sorted_and_filtered(object_class, query=nil)
objects = get_objects(object_class, query)
object_class = object_class.classify.constantize
if query
objects = object_class.all.where(query)
else
objects = object_class.all
end
if !params[:sort].blank?
options = params[:sort_options]
options = [options] if !options.class.eql?(Array)
@ -79,7 +74,7 @@ class OrbitBackendController< ApplicationController
when 'categories'
a = Array.new
objects.each do |object|
a << object if value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s)
a << object if (value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) rescue nil)
end
objects = a.uniq
when 'tags'
@ -93,7 +88,7 @@ class OrbitBackendController< ApplicationController
end if value.size > 0
end
end
Kaminari.paginate_array(objects).page(params[:page]).per(10)
Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
end
def get_string_value_from_object(object)
@ -104,9 +99,9 @@ class OrbitBackendController< ApplicationController
if s
case s.class.to_s
when "String"
s.downcase
s.downcase rescue ''
when "I18nVariable"
s[I18n.locale].downcase
s[I18n.locale].downcase rescue ''
else
nil
end
@ -158,4 +153,37 @@ class OrbitBackendController< ApplicationController
a.flatten
end
def get_viewable(object_class)
objects = get_objects(object_class)
Kaminari.paginate_array(objects).page(params[:page]).per(10)
end
def get_objects(object_class, query=nil)
object_class = object_class.classify.constantize
if query
objects = object_class.all.where(query)
else
objects = object_class.all
end
objects
end
def filter_authorized_objects(objects)
if(!is_admin? || !is_manager?)
objects.delete_if{ |object|
if object.is_pending == true
if check_permission(:manager)
object.create_user_id != current_user.id
else
!object.send("#{object.class.to_s.underscore}_category").authed_users('fact_check').include?(current_user) rescue false
end
else
false
end
}
end
objects
end
end

View File

@ -11,14 +11,14 @@ module Admin::ItemHelper
no_nested = 'no-nest'
end
ret << "<li id='#{node.id}' class='#{no_nested}'>"
ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'>"
ret << (link_to node.i18n_variable[I18n.locale], dest)
# ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'><i class='icons-moves'></i>"
ret << (link_to node.i18n_variable[I18n.locale], dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>"
ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page')
ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page')
ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page')
ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete')
ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)"), :class => 'js_history') if node._type.eql?('Page')
ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node._type.eql?('Page')
ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node._type.eql?('Page')
ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history')
ret << "</div>"
ret << "</div>"
ret << render_children(node)

View File

@ -204,4 +204,12 @@ module ApplicationHelper
is_manager? || is_admin?
end
def display_date_time(object)
object.strftime("%Y-%m-%d %H:%M")
end
def display_date(object)
object.strftime("%Y-%m-%d")
end
end

View File

@ -34,10 +34,10 @@ class Asset
protected
def set_key
if title.new_record?
if title && title.new_record?
title.key = 'title'
end
if description.new_record?
if description && description.new_record?
description.key = 'description'
end
end

View File

@ -11,15 +11,17 @@ class Item
field :enabled_for, :type => Array, :default => nil
field :menu_enabled_for, :type => Array, :default => nil
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
validates_uniqueness_of :name, :scope => :parent_id
validates_presence_of :name
validates_associated :parent, :children
before_destroy :destroy_children
after_rearrange :rebuild_path
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
def self.find_by_name(item_name)
Item.first(:conditions => { :name => item_name, :is_published => true })

View File

@ -13,7 +13,7 @@ class Link < Item
protected
def add_http
unless self.url[/^http?s:\/\//]
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end

View File

@ -7,6 +7,10 @@
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<%= f.label :transition_sec, t('admin.ad.transition_sec') %>
<%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %>
<%if at_least_module_manager%>
<%= f.label :best_size, t('admin.ad.best_size') %>
<%= f.text_field :best_size %> Ex: 500px x 300px
<% end -%>
<br>
<%= f.submit t("admin.ad.update_banner"), :class => 'btn' %>
<%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %>

View File

@ -22,6 +22,13 @@
</div>
</div>
<div class="control-group">
<%= f.label :best_size, t('admin.ad.best_size'),:class => "control-label" %>
<div class="controls">
<%= f.text_field :best_size %> Ex: 500px x 300px
</div>
</div>
<div class="control-group">
<%= f.label :ad_fx, t('admin.ad.ab_fx') %>
<div class="controls">

View File

@ -13,11 +13,16 @@
<ul id="banner_tab" class="nav nav-tabs">
<% @ad_banners.each do |ab| %>
<%= content_tag :li ,:class => (ab == @active ? 'active' : nil) do %>
<%if at_least_module_manager%>
<i class="icons-pencil"></i>
<%= link_to(ab.title,"##{ab.title.dehumanize}",:contenteditable=>"false",:data=>{:toggle=>"tab" ,'edit-url' =>(admin_rename_ad_banner_path ab) } )%>
<% else %>
<%= link_to(ab.title,"##{ab.title.dehumanize}",:data=>{:toggle=>"tab" } )%>
<% end -%>
<% end -%>
<%= content_tag :li,link_to(t("admin.ad.new_banner"),"#new-a-banner",:data=>{:toggle=>"modal"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %>
<% end -%>
<%= content_tag :li,link_to(t("admin.ad.new_banner"),"#new-a-banner",:data=>{:toggle=>"modal"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) if at_least_module_manager%>
</ul>

View File

@ -80,7 +80,10 @@
<!--請程式務必將圖片尺寸加入到行內裡-->
<%= image_tag @ad_image.file rescue ''%>
</div>
<span class="alert widgetInfo"><%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) if !@ad_image.ad_banner.best_size.empty?%></span>
<% if !@ad_image.ad_banner.best_size.empty?%>
<span class="alert widgetInfo"><%= t("admin.ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %>
</span>
<% end -%>
<div class="controls file-upload input-prepend">
<label class="control-label add-on btn" for="input-upload">
<%= t(:browse) %>

View File

@ -1,3 +1,7 @@
<% content_for :side_bar do %>
<%= render 'admin/sites/side_bar' %>
<% end %>
<h1><%= t('admin.editing_design') %></h1>
<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>

View File

@ -1,3 +1,7 @@
<% content_for :side_bar do %>
<%= render 'admin/sites/side_bar' %>
<% end %>
<%= form_for :news_bulletins, :url => delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table class="table main-list">

View File

@ -1,3 +1,7 @@
<% content_for :side_bar do %>
<%= render 'admin/sites/side_bar' %>
<% end %>
<h1><%= t('admin.new_design') %></h1>
<%= form_for :design, :url => admin_designs_path, :html => {:multipart => true} do |f| %>

View File

@ -1,3 +1,7 @@
<% content_for :side_bar do %>
<%= render 'admin/sites/side_bar' %>
<% end %>
<div class="main2">
<%= form_tag '',:multipart => true,:action=>"post" do |f| %>

View File

@ -1 +1,6 @@
<ol class="nav nav-list">
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
</ol>
<script type="text/javascript">
bindTreeDragHandle();
</script>

View File

@ -1,9 +1,7 @@
$('#back_main').empty();
switch ("<%= escape_javascript(@item._type)%>") {
case 'Link':
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>");
break;
case 'Page':
<% case @item._type %>
<% when 'Page' %>
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
break;
};
<% when 'Link' %>
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>");
<% end %>

View File

@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>");

View File

@ -4,7 +4,7 @@
<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= f.submit t('create'), :class => 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>

View File

@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>");

View File

@ -10,3 +10,7 @@
<% end -%>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('designs') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %>
<% end -%>

View File

@ -5,4 +5,4 @@
per_page: number of items to fetch per page
remote: data-remote
-%>
<li class="page gap"><%= raw(t 'views.pagination.truncate') %></li>
<!-- <li class="page gap"><%= raw(t 'views.pagination.truncate') %></li> -->

View File

@ -26,7 +26,7 @@
<%= content_tag :li, link_to(t('announcement.add_new'), new_panel_news_back_end_news_bulletin_path), :class => active_for_action('news_bulletins', 'new') %>
<%= content_tag :li, link_to(t('announcement.categories'), panel_news_back_end_news_bulletin_categorys_path), :class => active_for_action('news_bulletin_categorys', 'index') || active_for_ob_auths_object("NewsBulletinCategory") %>
<%= content_tag :li, link_to(t('announcement.tags'), panel_news_back_end_tags_path), :class => active_for_action('/panel/news/back_end/tags', 'index') %>
<%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_news_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %>
<%= content_tag :li, link_to(t('announcement.bulletin.approval_setting'), panel_news_back_end_approval_setting_path), :class => active_for_action('news_approvals', 'setting') if (is_manager? rescue nil) %>
<%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "news"}))), :class => active_for_app_auth('news') if (is_admin? rescue nil) %>
<% end -%>
@ -45,10 +45,6 @@
<% end -%>
<%= content_tag :li, :class => active_for_controllers('designs') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banners') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %>

View File

@ -23,9 +23,7 @@
</div>
<div class="viewport">
<div id='back_sidebar' class="overview">
<ol class="nav nav-list">
<%= yield :sidebar %>
</ol>
</div>
</div>
</nav>

View File

@ -91,6 +91,7 @@ en:
ab_fx: FX
all_banners: AdBanner list
banner_best_size: Banner Best Size
best_size: Best size
new_banner: New banner
new_image: New image
showing: Showing
@ -216,6 +217,10 @@ en:
options: Options
orig_upload_file: Original filename
page: Page
page_context:
edit: Edit
ob_auth:
edit: Category authorization
page_part_kinds:
text: Text Area
public_r_tag: System Widget

View File

@ -88,6 +88,7 @@ zh_tw:
ab_fx: 轉場特效
all_banners: 輪播清單
banner_best_size: Banner 尺寸
best_size: 最佳尺寸
cate_auth: 分類授權
delete_banner: 刪除整組輪播
new_banner: 新增輪播

View File

@ -8,7 +8,7 @@ defaults: &defaults
development:
<<: *defaults
database: prototype_r4_ldap0229
database: prototype_r4_development
test:
<<: *defaults
@ -22,4 +22,4 @@ production:
# password: <%= ENV['MONGOID_PASSWORD'] %>
# database: <%= ENV['MONGOID_DATABASE'] %>
<<: *defaults
database: prototype_r4_ldap0229
database: prototype_r4_development

View File

@ -32,7 +32,11 @@ module OrbitCoreLib
end
def get_object_auth_by_title(title)
self.object_auths.where({title: title }).first
oa = self.object_auths.where({title: title }).first
if oa.nil? && (self.class::ObjectAuthTitlesOptions.include? title)
oa = self.object_auths.create title: title
end
oa
end
def authed_users(title=nil)

View File

@ -20,8 +20,8 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
else
@bulletin_category = @bulletin_categorys.first
end
preload_object_auth = @bulletin_category.object_auths.where(title: 'fact_check').empty?? (@bulletin_category.object_auths.create! :title=> 'fact_check') : @bulletin_category.object_auths.where(title: 'fact_check')
@users_array = preload_object_auth.first.privilege_users rescue []
preload_object_auth = @bulletin_category.get_object_auth_by_title('fact_check')
@users_array = preload_object_auth.privilege_users rescue []
respond_to do |format|
format.html
format.js
@ -31,9 +31,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = "Update Done"
flash[:notice] = t("admin.object_auth.update_done")
else
flash[:notice] = "Update Failed"
flash[:notice] = t("admin.object_auth.update_failed")
end
end

View File

@ -36,7 +36,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10)
@bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin") : Bulletin.all.page(params[:page]).per(10)
@bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin") : get_viewable("bulletin")
@bulletin_categories = BulletinCategory.all
@bulletin_link = BulletinLink.new
@ -45,12 +45,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin_file = BulletinFile.new
@file_url = panel_announcement_back_end_bulletins_path
if(!is_admin? || !is_manager?)
@bulletins.delete_if{ |bulletin|
bulletin.is_pending == true && ((!bulletin.bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) || bulletin.create_user_id!=current_user.id)
}
end
respond_to do |format|
format.html # index.html.erb
format.js { }

View File

@ -38,7 +38,6 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
def preview_content
@bulletin = Bulletin.find params[:id]
get_categorys
render :show
end
protected

View File

@ -160,13 +160,13 @@ class Bulletin
protected
def set_key
if title.new_record?
if title && title.new_record?
title.key = 'title'
end
if subtitle.new_record?
if subtitle && subtitle.new_record?
subtitle.key = 'subtitle'
end
if text.new_record?
if text && text.new_record?
text.key = 'text'
end
end

View File

@ -29,10 +29,10 @@ class BulletinFile
protected
def set_key
if filetitle.new_record?
if filetitle && filetitle.new_record?
filetitle.key = 'filetitle'
end
if description.new_record?
if description && description.new_record?
description.key = 'description'
end
end

View File

@ -16,11 +16,9 @@
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<div class="clear">

View File

@ -60,8 +60,8 @@
</ul>
</div>
</td>
<td><%= bulletin.postdate %></td>
<td><%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %></td>
<td><%= display_date_time(bulletin.postdate) %></td>
<td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t('bulletin.no_deadline') %></td>
<td>
<div class="label-group">
<div class="label-td">

View File

@ -5,7 +5,7 @@
</li>
<li>
<b><%= t('announcement.postdate') %></b>
<%= @bulletin.postdate %>
<%= display_date_time(@bulletin.postdate) %>
</li>
<li>
<b><%= t('announcement.title') %></b>
@ -42,7 +42,7 @@
</li>
<li>
<b><%= t('announcement.最後修改時間') %></b>
<%= @bulletin.updated_at %>
<%= display_date(@bulletin.updated_at) %>
</li>

View File

@ -22,7 +22,7 @@
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
</td>
<td><%= post.postdate %></td>
<td><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>

View File

@ -2,10 +2,11 @@
<h1 class="h1"><%= @bulletin.title[I18n.locale] %></h1>
<div class="info">
<div class="info1">
<span class="date"><%= @bulletin.postdate %></span>
&nbsp;|&nbsp;
<a href="" class="unit"><%= User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue '' %></a>
<span><%= dislpay_view_count(@bulletin) %></span>
<span class="pull-right"><%= dislpay_view_count(@bulletin) %></span>
<span class="date"><%= display_date_time(@bulletin.postdate) %></span>
<% unit = User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue nil %>
<%= " | " if unit %>
<a href="" class="unit"><%= unit %></a>
</div>
</div>
<div class="news_image">

View File

@ -15,7 +15,7 @@
<td><%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
<td><%= display_date_time(post.postdate) %></td>
</tr>
<% end %>

View File

@ -4,7 +4,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
include AdminHelper
def preview_and_approve
@news_bulletin = NewsBulletin.find params[:news_bulletin_id]
@news_bulletin = NewsBulletin.find params[:news_category][:id]
end
def approve
@ -14,20 +14,14 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
def setting
@sys_users = User.all(conditions: {admin: false})
@news_bulletin_categorys = NewsBulletinCategory.all
if params.has_key?(:category_id)
first_category = NewsBulletinCategory.find params[:category_id]
if params[:commit] == 'Update'
privilege_users = params[:users].collect{|key,value| User.find key } rescue []
preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check')
preload_object_auth = preload_object_auth_ary.first
preload_object_auth.privilege_users = privilege_users
preload_object_auth.save!
end
@options_from_collection_for_select_news_bulletin_categorys = @news_bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] }
if params.has_key? :news_category
@news_bulletin_categorys = NewsBulletinCategory.find params[:news_category][:id]
else
first_category = @news_bulletin_categorys.first
@news_bulletin_categorys = @news_bulletin_categorys.first
end
preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check')
@users_array = preload_object_auth.first.privilege_users rescue []
preload_object_auth = @news_bulletin_categorys.get_object_auth_by_title('fact_check')
@users_array = preload_object_auth.privilege_users rescue []
respond_to do |format|
format.html
format.js
@ -35,10 +29,27 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
end
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t("admin.object_auth.update_done")
else
flash[:notice] = t("admin.object_auth.update_failed")
end
end
def user_list
@news_bulletin_category = NewsBulletinCategory.find params[:news_category][:id]
end
protected
def update_setting_by_params
category = NewsBulletinCategory.find params[:news_category][:id]
privilege_users = params[:users].collect{|key,value| User.find key } rescue []
object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check')
object_auth = object_auth_ary.first
object_auth.privilege_users = privilege_users
object_auth
end
def get_categorys(id = nil)
@news_bulletin_categorys = []

View File

@ -42,10 +42,6 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
@news_bulletin_link = NewsBulletinLink.new
@link_url = panel_news_back_end_news_bulletins_path
@news_bulletins.delete_if{ |news_bulletin|
news_bulletin.is_pending == true && ((!news_bulletin.bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) || news_bulletin.create_user_id!=current_user.id)
}
@news_bulletin_file = NewsBulletinFile.new
@file_url = panel_news_back_end_news_bulletins_path

View File

@ -36,9 +36,8 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
end
def preview_content
@news_bulletins = NewsBulletin.find params[:id]
@news_bulletin = NewsBulletin.find params[:id]
get_categorys
render :show
end
protected

View File

@ -2,7 +2,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper
def news_show_approval_link(news_bulletin)
by_news_bulletin = (!news_bulletin.is_expired? and !news_bulletin.is_checked?)
by_user = (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager?
by_user = (news_bulletin.news_bulletin_category.authed_users('fact_check').include?(current_user) or is_manager? or is_admin?)
by_news_bulletin and by_user
end

View File

@ -160,13 +160,13 @@ class NewsBulletin
protected
def set_key
if title.new_record?
if title && title.new_record?
title.key = 'title'
end
if subtitle.new_record?
if subtitle && subtitle.new_record?
subtitle.key = 'subtitle'
end
if text.new_record?
if text && text.new_record?
text.key = 'text'
end
end

View File

@ -29,10 +29,10 @@ class NewsBulletinFile
protected
def set_key
if filetitle.new_record?
if filetitle && filetitle.new_record?
filetitle.key = 'filetitle'
end
if description.new_record?
if description && description.new_record?
description.key = 'description'
end
end

View File

@ -0,0 +1,44 @@
<% if news_bulletin_category -%>
<div class="modal hide fade in" id="news_bulletin_category-<%=news_bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.approval_user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
<% news_bulletin_category.get_object_auth_by_title('fact_check').auth_users.each do |user| %>
<div class="checkbox clear checked">
<div class='member-avatar'>
<% if user.avatar? %>
<%= image_tag(user.avatar.thumb.url,:class => "member-img") %>
<% else %>
<%= image_tag "person.png",:class => "member-img" %>
<% end %>
</div>
<%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%>
</div>
<% end -%>
<divl>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
</div>
<div>
<script type="text/javascript" src="/static/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#news_bulletin_category-<%=news_bulletin_category.id%>").on("show", function () {
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -6,7 +6,7 @@
<% user.sub_roles.each do |sr| %>
<div class="for_unit" style="display:none;"> <%= sr.key %></div>
<% end %>
<%= content_tag :div,:data=>{'original-title'=>t('news.news_bulletin.approval_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.key}.join(',')}"},:class=>"checkbox clear" do %>
<%= content_tag :div,:data=>{'original-title'=>t('news.news_bulletin.approval_setting_window_title'),:content => "#{user.sub_roles.collect{|sr| sr.i18n_variable[I18n.locale]}.join(',')}"},:class=>"checkbox clear" do %>
<div class="check-icon">
</div>
<div class='member-avatar'>

View File

@ -4,27 +4,29 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true) %>
<div class="subnav">
<ul class="nav nav-pills filter">
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("news.news_bulletin.category") %>
<%= select_tag "category_id", options_from_collection_for_select(@news_bulletin_categorys, "id", "key") %>
<%= select "news_category",'id', @options_from_collection_for_select_news_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_news_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag :action => "update_setting" do %>
<% form_tag panel_news_back_end_approval_setting_path do %>
<%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions pagination-centered">
<%= submit_tag "Update", :class => 'btn' %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
@ -32,9 +34,21 @@
<script type="text/javascript" charset="utf-8">
var availableTags = [];
$(function() {
$(document).ready(function() {
$('#category_id').change(function() {
$(this).parents('form').submit();
$(".prevent_enter_submit_form").bind("keypress", function(e) {
if (e.keyCode == 13) {
return false;
}
});
$('#news_category_id').change(function() {
$.ajax({
type: 'GET',
dataType: "script",
url:$(this).parents("from").attr("href"),
data:$(this).parents("form").serialize()
});
});
});
</script>

View File

@ -1 +1,2 @@
$("#users_checkbox_ary").replaceWith('<%= (render :partial => 'privilege_user', :locals => {:users => @users_array}).html_safe%>');
$("#users_checkbox_ary").replaceWith('<%= escape_javascript(render :partial => "privilege_user", :locals => {:users => @users_array})%>');
permissionCheckbox();

View File

@ -0,0 +1 @@
alert( "<% flash.each do |key, msg| %><%= msg %><% end%>");

View File

@ -0,0 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_list',:locals => {:news_bulletin_category => @news_bulletin_category})) %>");
var start_modal_with_id = "news_bulletin_category-<%=@news_bulletin_category.id%>"

View File

@ -55,14 +55,14 @@
<li class="dropdown"><%= link_to t('news_bulletin.delete'), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<% end %>
<% if news_show_approval_link(news_bulletin) %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin) ,:class=>"preview_trigger" %></li><%#= #TODO add ancher so user can quick access into that part %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
</ul>
</div>
</td>
<td><%= news_bulletin.postdate %></td>
<td><%= (news_bulletin.deadline) ? news_bulletin.deadline : t('news_bulletin.no_deadline') %></td>
<td><%= display_date(news_bulletin.postdate) %></td>
<td><%= (news_bulletin.deadline) ? display_date(news_bulletin.deadline) : t('news_bulletin.no_deadline') %></td>
<td>
<div class="label-group">
<div class="label-td">

View File

@ -5,7 +5,7 @@
</li>
<li>
<b><%= t('news.postdate') %></b>
<%= @news_bulletin.postdate %>
<%= display_date(@news_bulletin.postdate) %>
</li>
<li>
<b><%= t('news.title') %></b>
@ -42,7 +42,7 @@
</li>
<li>
<b><%= t('news.最後修改時間') %></b>
<%= @news_bulletin.updated_at %>
<%= display_date(@news_bulletin.updated_at) %>
</li>

View File

@ -17,12 +17,12 @@
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td><%= image_tag post.image rescue nil %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
<td><%= display_date(post.postdate) %></td>
</tr>
<% end %>
</tbody>

View File

@ -3,9 +3,10 @@
<div class="info">
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) %></span>
<span class="date"><%= @news_bulletin.postdate %></span>
&nbsp;|&nbsp;
<a href="" class="unit"><%= @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue '' %></a>
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
<% unit = @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue nil %>
<%= " | " if unit %>
<a href="" class="unit"><%= unit %></a>
</div>
</div>
<div class="news_image">

View File

@ -18,7 +18,7 @@
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
<td><%= display_date(post.postdate) %></td>
</tr>
<% end %>
</tbody>

View File

@ -2,9 +2,10 @@ Rails.application.routes.draw do
namespace :panel do
namespace :news do
namespace :back_end do
match 'news_approval_setting' => "news_approvals#setting" ,:as => :news_approval_setting
match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting
match 'public' => "news#public",:as => :public
match 'approval_setting' => "news_approvals#setting" ,:as => :approval_setting,:via => :get
match 'approval_setting' => "news_approvals#update_setting" ,:as => :approval_setting,:via => :post
match 'approval_setting' => "news_approvals#user_list" ,:as => :approval_user_list,:via => :put
resources :news_bulletins do
match "approve/:news_bulletin_id" => "news_approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:news_bulletin_id" => "news_approvals#approve",:as => :approve,:via => :post

View File

@ -18,6 +18,6 @@
<%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %>
<%end -%>
</td>
<td><%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %></td>
<td><%= display_date_time(page_context.updated_at) %></td>
<td><%= User.find(page_context.create_user_id).name %></td>
</tr>

View File

@ -10,6 +10,6 @@
</div>
</td>
<td><%= view_page_context.version %></td>
<td><%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %></td>
<td><%= display_date(view_page_context.updated_at) %></td>
<td><%= User.find(view_page_context.create_user_id).name %></td>
</tr>

View File

@ -21,7 +21,7 @@
</li>
<li>
<b><%= t('page_content.最後修改時間') %></b>
<%= @page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %>
<%= display_date(@page_context.updated_at) %>
</li>

View File

@ -69,10 +69,10 @@ class WebLink
protected
def set_key
if name.new_record?
if name && name.new_record?
name.key = 'name'
end
if context.new_record?
if context && context.new_record?
context.key = 'context'
end
end

View File

@ -13,7 +13,7 @@
</li>
<li>
<b><%= t('announcement.postdate') %></b>
<%= @bulletin.postdate %>
<%= display_date(@bulletin.postdate) %>
</li>
<li>
<b><%= t('announcement.title') %></b>
@ -50,7 +50,7 @@
</li>
<li>
<b><%= t('announcement.最後修改時間') %></b>
<%= @bulletin.updated_at %>
<%= display_date(@bulletin.updated_at) %>
</li>

View File

@ -13,7 +13,7 @@
</li>
<li>
<b><%= t('announcement.postdate') %></b>
<%= @bulletin.postdate %>
<%= display_date(@bulletin.postdate) %>
</li>
<li>
<b><%= t('announcement.title') %></b>
@ -50,7 +50,7 @@
</li>
<li>
<b><%= t('announcement.最後修改時間') %></b>
<%= @bulletin.updated_at.strftime("%Y-%m-%d %H:%I:%S") %>
<%= display_date_time(@bulletin.updated_at) %>
</li>

View File

@ -38,10 +38,13 @@ module Impressionist
end
def update_impressionist_counter_cache
# cache_options = self.class.impressionist_counter_cache_options
# column_name = cache_options[:column_name].to_sym
# count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count
# update_attribute(column_name, count)
cache_options = self.class.impressionist_counter_cache_options
column_name = cache_options[:column_name].to_sym
count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count
update_attribute(column_name, count)
update_attribute(column_name, self.send(cache_options[:column_name]) + 1)
end
# OLD METHODS - DEPRECATE IN V0.5

View File

@ -27,6 +27,7 @@ class Impression
private
def update_impressions_counter_cache
if self.referrer
impressionable_class = self.impressionable_type.constantize
if impressionable_class.impressionist_counter_cache_options
@ -35,3 +36,4 @@ class Impression
end
end
end
end