From 4415093ce27b84627fa8b656a38589a63a540f25 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 10 Dec 2014 18:09:50 +0800 Subject: [PATCH] lot of fixes and experience enhancement --- app/controllers/admin/authorizations_controller.rb | 2 +- app/controllers/admin/import_controller.rb | 2 +- app/controllers/pages_controller.rb | 11 ++--------- app/helpers/orbit_helper.rb | 9 ++++++++- app/views/admin/authorizations/index.html.erb | 12 ++++++++++-- app/views/admin/categories/_index.html.erb | 2 +- app/views/admin/categories/_select_form.html.erb | 2 +- app/views/admin/categories/index.html.erb | 2 +- app/views/orbit_bar/index.html.erb | 9 ++++++++- config/locales/en.yml | 2 ++ config/locales/zh_tw.yml | 3 +++ 11 files changed, 38 insertions(+), 18 deletions(-) diff --git a/app/controllers/admin/authorizations_controller.rb b/app/controllers/admin/authorizations_controller.rb index 8d1c82c..3c27621 100644 --- a/app/controllers/admin/authorizations_controller.rb +++ b/app/controllers/admin/authorizations_controller.rb @@ -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) diff --git a/app/controllers/admin/import_controller.rb b/app/controllers/admin/import_controller.rb index e65970b..4176946 100644 --- a/app/controllers/admin/import_controller.rb +++ b/app/controllers/admin/import_controller.rb @@ -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 diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b70eafb..dc3e5b4 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -290,20 +290,13 @@ class PagesController < ApplicationController partials = [] subparts.each do |subpart| if subpart.kind == "module_widget" - subpart_categories = [] - subpart.categories.each do |c| - category = Category.find(c) rescue nil - if !category.nil? && !category.disable - subpart_categories << c - end - end - subpart_categories = ["all"] if subpart_categories.blank? + OrbitHelper.set_current_widget subpart OrbitHelper.set_widget_data_count subpart.data_count 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 || ["all"] + 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? diff --git a/app/helpers/orbit_helper.rb b/app/helpers/orbit_helper.rb index 2b87dfc..cd133a6 100644 --- a/app/helpers/orbit_helper.rb +++ b/app/helpers/orbit_helper.rb @@ -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 diff --git a/app/views/admin/authorizations/index.html.erb b/app/views/admin/authorizations/index.html.erb index ccc06a6..8725323 100644 --- a/app/views/admin/authorizations/index.html.erb +++ b/app/views/admin/authorizations/index.html.erb @@ -49,9 +49,17 @@

Sub Managers

- This category is disabled. + <%= t(:category_disabled) %>
- \ No newline at end of file + + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index c45c6e3..659ca3a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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." diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index c501af4..9f99e3c 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -5,6 +5,9 @@ zh_tw: zh_tw_: 繁體中文 zh_cn: 简体中文 en: 英文 + category_notice: 類別一但被建立,就不能刪除喔! + category_disabled: 此類別已被關閉 + access: denied: ajax_401_error: 使用者已逾時或是登出,請重新登入