diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 6580b70f..956a2a53 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -23,7 +23,7 @@ class DefaultWidgetController< OrbitWidgetController @fields = @page_part.widget_field @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3) end - @data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field) + @data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field).desc(:created_at) case params[:type] when "typeA" @tag_class = 'default_widget_typeA' diff --git a/app/helpers/default_widget_helper.rb b/app/helpers/default_widget_helper.rb index 7f917449..913c77ee 100644 --- a/app/helpers/default_widget_helper.rb +++ b/app/helpers/default_widget_helper.rb @@ -3,20 +3,21 @@ module DefaultWidgetHelper I18n.t("#{@page_part.module_app.key}.default_widget.#{field}") end - def link_to_field(row_data,field) + def link_to_field(row_data,field,switch) method_ary = @page_part.module_app.widget_fields_link_method - if method_ary.has_key? field - url = case method_ary[field]["args"] + field = field.to_sym + if(method_ary.has_key?(field) and (switch == "true")) + url = case method_ary[field][:args] when nil # no args - get_data_link(method_ary[field]["method"]) + get_data_link(method_ary[field][:method]) when :self # passing self - get_data_link(method_ary[field]['method'],row_data.id) + get_data_link(method_ary[field][:method],row_data.id) else - ary = method_ary[field]["args"].clone + ary = method_ary[field][:args].clone object_hash = ary.each do |key,val| ary[key]= type_trans_or_to_s(row_data.send(val[0]).send(val[1])) end - get_data_link(method_ary[field]['method'],object_hash) + get_data_link(method_ary[field][:method],object_hash) end link_to row_data.send(field),url diff --git a/app/models/module_app.rb b/app/models/module_app.rb index b10d581f..5aa5a11d 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -98,7 +98,8 @@ class ModuleApp end def widget_fields_link_method - raise 'Need to link with OrbitApp [type: Hash]' + get_registration.get_link_methods + # raise 'Need to link with OrbitApp [type: Hash]' end diff --git a/app/views/default_widget/typeA.html.erb b/app/views/default_widget/typeA.html.erb index f6e0eb54..20ce3dbd 100644 --- a/app/views/default_widget/typeA.html.erb +++ b/app/views/default_widget/typeA.html.erb @@ -11,7 +11,7 @@ <% @data.each do |row_data| %>