diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-04 10:41:59 -0500 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-04 10:41:59 -0500 |
commit | 45fe4f5022f7181aa5d6e66f03ba3c8cf281879a (patch) | |
tree | f53b0320ca57ac5ea9edfd4867bd2635c531d250 /app | |
parent | c5ab74f9adb52228ef6583353b89d855f0dc4a3a (diff) |
sort gs_parameters by entity+section
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/gs_parameters_controller.rb | 12 | ||||
-rw-r--r-- | app/views/gs_parameters/index.html.haml | 48 | ||||
-rw-r--r-- | app/views/gs_parameters/show.html.haml | 10 |
3 files changed, 56 insertions, 14 deletions
diff --git a/app/controllers/gs_parameters_controller.rb b/app/controllers/gs_parameters_controller.rb index bd8b44b..106ce76 100644 --- a/app/controllers/gs_parameters_controller.rb +++ b/app/controllers/gs_parameters_controller.rb @@ -4,9 +4,15 @@ class GsParametersController < ApplicationController before_filter :spread_breadcrumbs def index - @gs_parameters_unordered = GsParameter.scoped - @gs_parameters = GsParameter.order([:section, :name]) - @sections = @gs_parameters.pluck(:section).uniq.sort + @gs_parameters = GsParameter.order([:entity, :section, :name]) + + @entities = Hash.new() + @gs_parameters.each do |parameter| + if !@entities[parameter.entity] + @entities[parameter.entity] = Hash.new() + end + @entities[parameter.entity][parameter.section] = true + end end def show diff --git a/app/views/gs_parameters/index.html.haml b/app/views/gs_parameters/index.html.haml index 8df2bb3..9d757a0 100644 --- a/app/views/gs_parameters/index.html.haml +++ b/app/views/gs_parameters/index.html.haml @@ -2,12 +2,42 @@ - cache(['gs_parameter_all_tables', I18n.locale, @gs_parameters.count, @gs_parameters.reorder(:updated_at).first, @gs_parameters.reorder(:updated_at).last]) do - if @gs_parameters && @gs_parameters.count > 0 - - if @sections - - @sections.each do |section| - %h3= section - %table.table.table-striped - -# Template Dependency: gs_parameters/_index_core - = render "index_core", :gs_parameters => @gs_parameters.where(:section => section) - - else - %table.table.table-striped - = render "index_core", :gs_parameters => @gs_parameters + %table.table.table-striped + %thead + %tr + %th + %th + %th + %th + + %tbody + - @entities.each do |entity_name, entity| + %tr.table.info + %td{:colspan => 5} + - if !entity_name.blank? + %strong= entity_name + - entity.each do |section_name, section| + %tr.table.success + %td + %td{:colspan => 4} + %strong= section_name + - gs_parameters = @gs_parameters.where(:entity => entity_name, :section => section_name) + - cache(['gs_parameter_sub_table', I18n.locale, gs_parameters.count, gs_parameters.reorder(:updated_at).first, gs_parameters.reorder(:updated_at).last]) do + + - for gs_parameter in gs_parameters + - cache(['gs_parameters_table_single_row', I18n.locale, gs_parameter]) do + %tr + %td + %td + %td + %span.hidden-phone + = truncate(gs_parameter.name, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH')) + %span.visible-phone + = truncate(gs_parameter.name, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH')) + %td + %span.hidden-phone + = truncate(gs_parameter.value, :length => GsParameter.get('DESKTOP_MAX_STRING_LENGTH')) + %span.visible-phone + = truncate(gs_parameter.value, :length => GsParameter.get('MOBILE_MAX_STRING_LENGTH')) + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:child => gs_parameter} + diff --git a/app/views/gs_parameters/show.html.haml b/app/views/gs_parameters/show.html.haml index 706625f..85e9b98 100644 --- a/app/views/gs_parameters/show.html.haml +++ b/app/views/gs_parameters/show.html.haml @@ -4,10 +4,11 @@ %table.table.table-striped %tbody %tr + %tr %td - %strong= t('gs_parameters.show.name') + ":" + %strong= t('gs_parameters.show.entity') + ":" %td - = @gs_parameter.name + = @gs_parameter.entity %tr %td %strong= t('gs_parameters.show.section') + ":" @@ -15,6 +16,11 @@ = @gs_parameter.section %tr %td + %strong= t('gs_parameters.show.name') + ":" + %td + = @gs_parameter.name + %tr + %td %strong= t('gs_parameters.show.value') + ":" %td = @gs_parameter.value |