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 committed 2012-05-22 20:33:07 +08:00
commit f1c8bed29d
76 files changed
+348 -171

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

@@ -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();
});
@@ -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);
}
+1
View File
@@ -17,3 +17,4 @@
//= require side_bar_history
//= require rss
//= require ajax_form
//= require inc/ajax_setting
+5 -1
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() } );
}
});
});
}
+1 -10
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;
+17 -2
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;
@@ -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
@@ -1,8 +1,8 @@
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]
@ad_image = @ad_banner.ad_images.find params[:id]
+3 -1
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
+5 -3
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
+1 -1
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
+38 -10
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
@@ -157,5 +152,38 @@ class OrbitBackendController< ApplicationController
a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp)
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
+7 -7
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)
+8
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
+2 -2
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
+4 -2
View File
@@ -10,16 +10,18 @@ class Item
field :is_published, :type => Boolean, :default => false
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 })
+1 -1
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
@@ -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' %>
@@ -21,6 +21,13 @@
<%= f.text_field :transition_sec %> <%= t("admin.ad.trans_unit_sec") %>
</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') %>
+8 -3
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 %>
<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) } )%>
<%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 -%>
<% 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 ) %>
<%= 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>
+4 -1
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) %>
+4
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| %>
+4
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">
+4
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| %>
@@ -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| %>
@@ -1 +1,6 @@
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
<ol class="nav nav-list">
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
</ol>
<script type="text/javascript">
bindTreeDragHandle();
</script>
+5 -7
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 %>
+3 -1
View File
@@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#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) %>");
+1 -1
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 %>
+3 -1
View File
@@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#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) %>");
+4
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 -%>
+1 -1
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> -->
+1 -5
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 %>
+1 -3
View File
@@ -23,9 +23,7 @@
</div>
<div class="viewport">
<div id='back_sidebar' class="overview">
<ol class="nav nav-list">
<%= yield :sidebar %>
</ol>
<%= yield :sidebar %>
</div>
</div>
</nav>