Merge branch 'design_team' of github.com:Rulingcom/orbit into design_team

This commit is contained in:
Christophe Vilayphiou 2012-05-18 19:44:18 +08:00
commit db410b9c50
14 changed files with 87 additions and 24 deletions

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.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.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.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) %> <%= 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 -%> <% end -%>

View File

@ -31,9 +31,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def update_setting def update_setting
object_auth = update_setting_by_params object_auth = update_setting_by_params
if object_auth.save! if object_auth.save!
flash[:notice] = "Update Done" flash[:notice] = t("admin.object_auth.update_done")
else else
flash[:notice] = "Update Failed" flash[:notice] = t("admin.object_auth.update_failed")
end end
end end

View File

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

View File

@ -16,11 +16,9 @@
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %> <%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %> <%= search_field_tag 'user_filter' %>
</div> </div>
</li> </li>
</ul> </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'%> <%= 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> </div>
<%#= label_tag :role, t("admin.roles") %> <%#= label_tag :role, t("admin.roles") %>
<div class="clear"> <div class="clear">

View File

@ -4,7 +4,7 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
include AdminHelper include AdminHelper
def preview_and_approve def preview_and_approve
@bulletin = NewsBulletin.find params[:bulletin_id] @news_bulletin = NewsBulletin.find params[:news_bulletin_id]
end end
def approve def approve
@ -35,10 +35,27 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
end end
def update_setting 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[:category_id]
end end
protected protected
def update_setting_by_params
category = NewsBulletinCategory.find params[: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) def get_categorys(id = nil)
@news_bulletin_categorys = [] @news_bulletin_categorys = []

View File

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

View File

@ -2,7 +2,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper
def news_show_approval_link(news_bulletin) def news_show_approval_link(news_bulletin)
by_news_bulletin = (!news_bulletin.is_expired? and !news_bulletin.is_checked?) 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 by_news_bulletin and by_user
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| %> <% user.sub_roles.each do |sr| %>
<div class="for_unit" style="display:none;"> <%= sr.key %></div> <div class="for_unit" style="display:none;"> <%= sr.key %></div>
<% end %> <% 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 class="check-icon">
</div> </div>
<div class='member-avatar'> <div class='member-avatar'>

View File

@ -4,11 +4,12 @@
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "inc/permission-checkbox" %> <%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %> <%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %> <% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %> <%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true) %> <%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav"> <div class="subnav clear">
<ul class="nav nav-pills filter"> <ul class="nav nav-pills filter pull-left">
<li class="accordion-group"> <li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;"> <div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("news.news_bulletin.category") %> <%= label_tag :category, t("news.news_bulletin.category") %>
@ -17,14 +18,15 @@
</div> </div>
</li> </li>
</ul> </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> </div>
<%#= label_tag :role, t("admin.roles") %> <%#= label_tag :role, t("admin.roles") %>
<div class="clear"> <div class="clear">
<%= content_tag :div do -%> <%= 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} %> <%= render :partial => "privilege_user", :locals => {:users => @users_array} %>
<div class="form-actions pagination-centered"> <div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn' %> <%= submit_tag "Update", :class => 'btn btn-primary' %>
</div> </div>
<% end -%> <% end -%>
<% end -%> <% end -%>

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,7 +55,7 @@
<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> <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 %> <% end %>
<% if news_show_approval_link(news_bulletin) %> <% 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) %></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 %> <% end %>
</ul> </ul>

View File

@ -2,12 +2,13 @@ Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :news do namespace :news do
namespace :back_end do namespace :back_end do
match 'news_approval_setting' => "news_approvals#setting" ,:as => :news_approval_setting match 'public' => "news#public",:as => :public
match 'update_setting' => "news_approvals#update_setting" ,:as => :news_approval_update_setting 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 resources :news_bulletins do
match "approve/:news_bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put match "approve/:news_bulletin_id" => "news_approvals#preview_and_approve",:as => :approval_preview,:via => :put
match "approve/:news_bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "approve/:news_bulletin_id" => "news_approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit
member do member do