fix new ui page get_item search and back_end_helper can add args option

This commit is contained in:
Spen 2014-01-14 10:31:10 +08:00 committed by Saurabh Bhatia
parent a108426412
commit e71a343718
2 changed files with 19 additions and 5 deletions

View File

@ -197,8 +197,8 @@ class PagesController < ApplicationController
else
model = params[:app_action].classify.constantize rescue nil
if !model.nil?
item = model.find(params[:id])
@item = Item.where(:category => [item.category_id.to_s]).first if !module_app.has_category.blank?
item = model.where(:_id=>params[:id]).first
@item = Item.where(:category => [item.category_id.to_s]).first if !module_app.has_category.blank? and !item.blank?
end
end

View File

@ -271,17 +271,31 @@ module OrbitBackendHelper
# TODO: links to other actions
# ===============================================================
def footer(args={})
if args[:link_name]
link_name = args[:link_name]
else
link_name = content_tag(:i, nil, :class => 'icon-plus') + ' ' + t(:add)
end
paginate = args.has_key?(:paginate) ? args[:paginate] : true
link = (is_manager? || is_sub_manager? rescue nil) && args.has_key?(:link) ? true : false
if paginate || link
@index_footer = content_tag :div, class: "bottomnav clearfix" do
concat content_tag :div, link_to(content_tag(:i, nil, :class => 'icon-plus') + ' ' + t(:add), args[:link].blank? ? '#' : send(args[:link]), :class => (args[:link_class] || 'btn btn-primary'), data: args[:link_data]), class: "action pull-right" if link
concat content_tag :div, link_to(link_name, args[:link].blank? ? '#' : send(args[:link]), :class => (args[:link_class] || 'btn btn-primary'), data: args[:link_data]), class: "action pull-right" if link
concat content_tag :div, paginate(@objects, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]}), class: "pagination pagination-centered" if paginate
end
end
end
def get_quick_link(quick, object, authorization, approvable)
if !quick[:link_option].blank?
link_option = ",#{quick[:link_option]}"
else
link_option = ""
end
case quick[:type]
when 'approval'
if show_approval_link(object)
@ -293,12 +307,12 @@ module OrbitBackendHelper
end
when 'edit'
if authorization && approvable
content_tag :li, link_to(t(quick[:translation] || :edit), quick[:link].nil? ? '#' : eval("#{quick[:link]}('#{object.id}')"), class: quick[:class], data: eval("#{quick[:data]}"))
content_tag :li, link_to(t(quick[:translation] || :edit), quick[:link].nil? ? '#' : eval("#{quick[:link]}('#{object.id}'#{link_option})"), class: quick[:class], data: eval("#{quick[:data]}"))
end
when 'delete'
if show_delete_link(object)
@delete_options = {title: quick[:title], warning: quick[:warning], cancel: quick[:cancel], submit: quick[:submit]}
content_tag :li, link_to(t(quick[:translation] || :delete_), '#', rel: eval("#{quick[:link]}('#{object.id}')"), class: "delete #{quick[:class] || 'text-error'}")
content_tag :li, link_to(t(quick[:translation] || :delete_), '#', rel: eval("#{quick[:link]}('#{object.id}'#{link_option})"), class: "delete #{quick[:class] || 'text-error'}")
end
when 'detail'
content_tag :li, link_to(t(quick[:translation] || :detail), '#', class: (quick[:class] || "detail-row"))