From 24e47521f1a57c73dc349de35909af7e1f8a4a1f Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 17 Jan 2013 17:50:47 +0100 Subject: group by table --- app/controllers/call_routes_controller.rb | 2 ++ app/views/call_routes/_index_core.html.haml | 2 -- app/views/call_routes/index.html.haml | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 41abe6d..b0c173d 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -4,6 +4,8 @@ class CallRoutesController < ApplicationController before_filter :spread_breadcrumbs def index + @call_routes = CallRoute.order(['`table`', :position]) + @tables = @call_routes.pluck('`table`').uniq.sort end def show diff --git a/app/views/call_routes/_index_core.html.haml b/app/views/call_routes/_index_core.html.haml index 9e7b94e..aa22437 100644 --- a/app/views/call_routes/_index_core.html.haml +++ b/app/views/call_routes/_index_core.html.haml @@ -1,6 +1,5 @@ %table %tr - %th= t('call_routes.index.table') %th= t('call_routes.index.name') %th= t('call_routes.index.endpoint_type') %th= t('call_routes.index.endpoint_id') @@ -8,7 +7,6 @@ - reset_cycle - for call_route in call_routes %tr{:class => cycle('odd', 'even')} - %td= call_route.table %td= call_route.name %td= call_route.endpoint_type %td= call_route.endpoint_id diff --git a/app/views/call_routes/index.html.haml b/app/views/call_routes/index.html.haml index 687a9dc..c83606b 100644 --- a/app/views/call_routes/index.html.haml +++ b/app/views/call_routes/index.html.haml @@ -1,6 +1,11 @@ - title t("call_routes.index.page_title") - if @call_routes && @call_routes.count > 0 - = render "index_core", :call_routes => @call_routes - -= render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} \ No newline at end of file + %table + - @tables.each do |table| + %tr + %td{:colspan => 3} + %h3= table + = render "index_core", :call_routes => @call_routes.where(:table => table) + += render :partial => 'shared/create_link', :locals => {:child_class => CallRoute} -- cgit v1.2.3