category enhancements

This commit is contained in:
Harry Bomrah 2014-12-09 22:00:40 +08:00
parent 4b86270725
commit 84308c3d10
5 changed files with 19 additions and 9 deletions

View File

@ -74,10 +74,11 @@ class PagesController < ApplicationController
params[:layout_type] = params[:method] || page.layout || "index"
end
params[:url] = page.url
categories = page.categories.collect do |c|
if !c.disable
return c
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?
@ -289,13 +290,20 @@ 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_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,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

@ -24,6 +24,7 @@
</div>
</div>
<% end %>
<div class="text-error text-center">Category once created, cannot be deleted.</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">Category once created, cannot be deleted.</div>
<%= label_tag "disable" do %>
<%= f.check_box :disable %>
<%= t(:disable) %>