Merge branch 'master' of gitlab.tp.rulingcom.com:saurabh/orbit4-5 into gravity

This commit is contained in:
Harry Bomrah 2014-12-10 18:11:28 +08:00
commit e34b3599a2
19 changed files with 98 additions and 18 deletions

View File

@ -58,10 +58,20 @@ $(document).ready(function() {
$("#remove_users").removeClass("hide");
}
}
var is_category_disabled = function(id){
var obj = app_categories.filter(function(c){return c.id == id})[0];
return obj.disable;
}
$("select[name=anything]").on("change",function(){
$(".select_user_modal").removeClass("hide");
$("#disabled_message_span").addClass("hide");
var value_to_filter = $(this).val();
if(value_to_filter != ""){
if(is_category_disabled(value_to_filter)){
$(".select_user_modal").addClass("hide");
$("#disabled_message_span").removeClass("hide");
}
lis.each(function(){
var categories = $(this).data("categories");
if(categories.indexOf(value_to_filter) == -1){

View File

@ -7,7 +7,7 @@ class Admin::AuthorizationsController < OrbitAdminController
if @module_apps && @module_apps.include?(@module_app)
reload_users
if (@module_app.categorizable || @module_app.categories.present?)
@objects = @module_app.categories rescue nil
@objects = @module_app.categories.order_by(:disable.asc) rescue nil
end
elsif @module_apps && @module_app.key == "authorization"
redirect_to admin_authorizations_path(@module_apps.first.key)

View File

@ -26,7 +26,7 @@ class Admin::ImportController < OrbitAdminController
msg = "Failed to connect to RSS2 (#{uri.to_s})"
end
render :json=>{"status"=>msg}
render :json=>{"status"=>msg}.to_json
end
def clean_old_data

View File

@ -4,6 +4,7 @@ class OrbitAdminController < ApplicationController
include OrbitBackendHelper
before_action :authenticate_user, :log_user_action, :load_authorized_categories
before_action :check_for_nil_categories, :only => [:new, :edit]
layout "back_end"
def sort
@ -81,4 +82,11 @@ class OrbitAdminController < ApplicationController
@current_user_is_sub_manager = current_user.is_sub_manager?(@module_app) rescue false
end
def check_for_nil_categories
@user_authorized_categories = @module_app.categories.enabled.authorized(current_user)
if @current_user_is_sub_manager && @user_authorized_categories.blank?
render_403
end
end
end

View File

@ -41,7 +41,7 @@ class PagePartsController < ApplicationController
app = ModuleApp.find_by_key(module_name) rescue nil
app = OrbitWidget.find_by_key(module_name) if app.nil?
@categories = app.categories rescue []
@categories = app.categories.enabled rescue []
@tags = app.tags rescue []
@widget_methods = app.widget_methods
@widget_settings = app.widget_settings
@ -100,7 +100,7 @@ class PagePartsController < ApplicationController
module_name = module_name.downcase.singularize
app = ModuleApp.find_by_key(module_name) rescue nil
app = OrbitWidget.find_by_key(module_name) if app.nil?
@categories = app.categories rescue []
@categories = app.categories.enabled rescue []
@tags = app.tags rescue []
@widget_methods = app.widget_methods
@widget_settings = app.widget_settings

View File

@ -74,12 +74,19 @@ class PagesController < ApplicationController
params[:layout_type] = params[:method] || page.layout || "index"
end
params[:url] = page.url
categories = []
page.categories.each do |c|
category = Category.find(c) rescue nil
if !category.nil? && !category.disable
categories << c
end
end
categories = ["all"] if categories.blank?
@manifest = @key
OrbitHelper.set_params params,current_user
OrbitHelper.set_site_locale locale
OrbitHelper.set_this_module_app module_app.singularize
OrbitHelper.set_page_categories page.categories || []
OrbitHelper.set_page_categories categories || ["all"]
OrbitHelper.set_page_tags page.tags || []
OrbitHelper.set_page_role_status page.role_status || []
OrbitHelper.set_member_sort_position page.member_sort_position
@ -164,7 +171,7 @@ class PagesController < ApplicationController
end
else
if !module_app.key.eql?("page_content")
categories = module_app.categories.collect do |cat|
categories = module_app.categories.enabled.collect do |cat|
{
"title" => cat.title,
"id" => cat.id.to_s
@ -203,7 +210,7 @@ class PagesController < ApplicationController
@pages = Page.where(:page_id.ne => "" , :page_id.exists => true)
@modules = ModuleApp.all.frontend_enabled
@module_app = ModuleApp.find_by_key(@page.module) rescue nil
@categories = @module_app.categories rescue []
@categories = @module_app.categories.enabled rescue []
if @module_app.key.eql?("page_content")
@categories = []
end
@ -283,13 +290,13 @@ class PagesController < ApplicationController
partials = []
subparts.each do |subpart|
if subpart.kind == "module_widget"
OrbitHelper.set_current_widget subpart
OrbitHelper.set_widget_data_count subpart.data_count
OrbitHelper.set_widget_categories subpart.categories
OrbitHelper.set_widget_module_app subpart.module
OrbitHelper.set_widget_item_url subpart
OrbitHelper.set_widget_title subpart.title
OrbitHelper.set_widget_categories subpart.categories || []
OrbitHelper.set_widget_categories subpart.categories || ["all"]
OrbitHelper.set_widget_tags subpart.tags || []
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
if !custom_value.nil?

View File

@ -246,7 +246,7 @@ module ApplicationHelper
end
html.html_safe
else
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
return "<div class='well'>No content to show.</div>".html_safe
end
else
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb")
@ -257,7 +257,7 @@ module ApplicationHelper
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
data = controller.send("#{params[:target_action]}") rescue nil
if data.nil?
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
return "<div class='well'> No content to show. </div>".html_safe
end
if data.blank? || data.empty?

View File

@ -87,7 +87,8 @@ module OrbitBackendHelper
def select_category(f, module_app)
render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app, :categories=>module_app.categories.enabled.authorized(current_user) }
@user_authorized_categories = module_app.categories.enabled.authorized(current_user) if @user_authorized_categories.nil?
render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app, :categories=> @user_authorized_categories }
end
def select_tags(f, module_app)
@ -193,6 +194,10 @@ module OrbitBackendHelper
render "public/401"
end
def render_403
render "public/403"
end
def need_access_right
render_401 if !has_access?
end

View File

@ -280,7 +280,14 @@ module OrbitHelper
end
def self.set_widget_categories(categories)
@widget_categories = categories
@widget_categories = []
categories.each do |c|
category = Category.find(c) rescue nil
if !category.nil? && !category.disable
@widget_categories << c
end
end
@widget_categories = ["all"] if @widget_categories.blank?
end
def self.widget_categories

View File

@ -87,7 +87,7 @@ module PagesHelper
end
html.html_safe
else
return "<div class='well'>It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :( </div>".html_safe
return "<div class='well'>No content to show.</div>".html_safe
end
end

View File

@ -49,8 +49,17 @@
<h4 class="pull-left">Sub Managers</h4>
<div class="pull-right">
<label>Categories :
<%= select_tag "anything", options_from_collection_for_select(@objects, "id", "title"), :prompt => "Select Category" if !@objects.nil? %>
<%#= select_tag "anything", options_from_collection_for_select(@objects, "id", "title"), :prompt => "Select Category" if !@objects.nil? %>
<% if !@objects.nil? %>
<select id="anything" name="anything">
<option value="">Select Category</option>
<% @objects.each do |obj| %>
<option value="<%= obj.id %>" <%= obj.disable ? "class=alert-error" : "" %>><%= obj.title %></option>
<% end %>
</select>
<% end %>
</label>
<span id="disabled_message_span" class="alert alert-error pull-right hide"><%= t(:category_disabled) %></span>
</div>
</div>
<ul id="card-list-submanagers" class="checkbox-card clearfix">
@ -87,6 +96,7 @@
<script type="text/javascript">
var lis = $("ul#card-list-submanagers li");
var app_categories = <%= @objects.collect{|c| {"id" => c.id.to_s, "disable" => c.disable}}.to_json.html_safe %>;
</script>

View File

@ -4,7 +4,7 @@
<% @module_apps.each do |mod| %>
<%
@mod = mod
categories = mod.categories
categories = mod.categories.order_by(:disable.asc)
%>
<% icon_name = OrbitApp::Module::Registration.find_by_key(mod.key).get_icon_class rescue 'icons-daniel-bruce-2' %>
<p class="tag-lead lead muted"><i class="<%= icon_name %>"></i> <%= mod.title %> <span class="badge pull-right"><%= categories.count %></span></p>

View File

@ -24,6 +24,7 @@
</div>
</div>
<% end %>
<div class="text-error text-center"><%= t(:category_notice) %></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><%= t(:close) %></button>

View File

@ -25,6 +25,7 @@
</div>
<% end %>
<% end %>
<div class="text-error text-center"><%= t(:category_notice) %></div>
<%= label_tag "disable" do %>
<%= f.check_box :disable %>
<%= t(:disable) %>

View File

@ -143,4 +143,11 @@
<% end %>
</ul>
</div>
</div>
</div>
<script type="text/javascript">
$("#open-orbit-login").on("change",function(){
if($(this).is(":checked")){
$("#user_user_id").focus();
}
})
</script>

View File

@ -26,6 +26,8 @@ en:
zh_tw_: Traditional Chinese
zh_cn: Simplified Chinese
_locale: English
category_notice: "Category once created, cannot be deleted."
category_disabled: "This category is disabled."
access:
denied:
ajax_401_error: "User session has been expired,please login again."

View File

@ -5,6 +5,9 @@ zh_tw:
zh_tw_: 繁體中文
zh_cn: 简体中文
en: 英文
category_notice: 類別一但被建立,就不能刪除喔!
category_disabled: 此類別已被關閉
access:
denied:
ajax_401_error: 使用者已逾時或是登出,請重新登入

18
public/403.html Normal file
View File

@ -0,0 +1,18 @@
<style type="text/css">
body {
margin: 0;
padding: 40px 0 0 0;
background-color: #F3F3F3;
}
</style>
<!-- Error Pages Start Here -->
<div id="error-page">
<div class="card">
<div class="figure code-401"></div>
<div class="message">
<h2>Categories not present.</h2>
<p>You dont have any categories assigned or your assigned categories are disabled. Contact manager or admin.</p>
</div>
</div>
</div>
<!-- Error Pages End Here -->

1
public/version-orbit-4-5 Normal file
View File

@ -0,0 +1 @@
version = "4.5"