From 22ab0909ad6b5d614074fc32da810450c61bde71 Mon Sep 17 00:00:00 2001 From: bohung Date: Thu, 24 Nov 2022 17:31:30 +0800 Subject: [PATCH] Add filter to backend page. --- .../admin/property_hires_controller.rb | 3 ++ .../admin/property_hires/_index.html.erb | 46 +++++++++++++++++ app/views/admin/property_hires/index.html.erb | 50 ++----------------- 3 files changed, 53 insertions(+), 46 deletions(-) create mode 100644 app/views/admin/property_hires/_index.html.erb diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 8b2f6c7..41ebbf3 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -11,6 +11,9 @@ class Admin::PropertyHiresController < OrbitAdminController .with_tags(filters("tag")) @properties = search_data(@properties,[:title]).page(params[:page]).per(10) + if request.xhr? + render :partial => "index" + end end def fields_display_order uid = params[:id].split("-").last diff --git a/app/views/admin/property_hires/_index.html.erb b/app/views/admin/property_hires/_index.html.erb new file mode 100644 index 0000000..7aac958 --- /dev/null +++ b/app/views/admin/property_hires/_index.html.erb @@ -0,0 +1,46 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @properties.each do |property| %> + + + + + + + <% end %> + +
+ <% if can_edit_or_delete?(property) %> + <%= property.title %> + + <% else %> + <%= property.title %> + <% end %> + + <%= property.category.title rescue nil %> + + <%= property.get_location_name %> + + <% if property.can_be_hired %> + Yes + <% else %> + No + <% end %> +
+
+ <%= content_tag(:div, paginate(@properties), class: "pagination pagination-centered") %> +
\ No newline at end of file diff --git a/app/views/admin/property_hires/index.html.erb b/app/views/admin/property_hires/index.html.erb index 7aac958..65d2e2b 100644 --- a/app/views/admin/property_hires/index.html.erb +++ b/app/views/admin/property_hires/index.html.erb @@ -1,46 +1,4 @@ - - - - <% @table_fields.each do |f| %> - <%= thead(f) %> - <% end %> - - - - <% @properties.each do |property| %> - - - - - - - <% end %> - -
- <% if can_edit_or_delete?(property) %> - <%= property.title %> - - <% else %> - <%= property.title %> - <% end %> - - <%= property.category.title rescue nil %> - - <%= property.get_location_name %> - - <% if property.can_be_hired %> - Yes - <% else %> - No - <% end %> -
-
- <%= content_tag(:div, paginate(@properties), class: "pagination pagination-centered") %> -
\ No newline at end of file +<%= render_filter @filter_fields, "index_table" %> + + <%= render 'index'%> + \ No newline at end of file