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" params[:layout_type] = params[:method] || page.layout || "index"
end end
params[:url] = page.url params[:url] = page.url
categories = []
categories = page.categories.collect do |c| page.categories.each do |c|
if !c.disable category = Category.find(c) rescue nil
return c if !category.nil? && !category.disable
categories << c
end end
end end
categories = ["all"] if categories.blank? categories = ["all"] if categories.blank?
@ -289,13 +290,20 @@ class PagesController < ApplicationController
partials = [] partials = []
subparts.each do |subpart| subparts.each do |subpart|
if subpart.kind == "module_widget" 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_current_widget subpart
OrbitHelper.set_widget_data_count subpart.data_count OrbitHelper.set_widget_data_count subpart.data_count
OrbitHelper.set_widget_categories subpart.categories
OrbitHelper.set_widget_module_app subpart.module OrbitHelper.set_widget_module_app subpart.module
OrbitHelper.set_widget_item_url subpart OrbitHelper.set_widget_item_url subpart
OrbitHelper.set_widget_title subpart.title 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 || [] OrbitHelper.set_widget_tags subpart.tags || []
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
if !custom_value.nil? if !custom_value.nil?

View File

@ -246,7 +246,7 @@ module ApplicationHelper
end end
html.html_safe html.html_safe
else 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
else else
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb") 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 controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
data = controller.send("#{params[:target_action]}") rescue nil data = controller.send("#{params[:target_action]}") rescue nil
if data.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 end
if data.blank? || data.empty? if data.blank? || data.empty?

View File

@ -87,7 +87,7 @@ module PagesHelper
end end
html.html_safe html.html_safe
else 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
end end

View File

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

View File

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