From 136c2f5f479207db65bdc10c3f5ef7e5a92d3536 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Thu, 10 Jan 2019 11:20:20 +0100 Subject: [PATCH 1/3] Move same code to one partial and give it buttons sorted in same way as in tree --- .../_show_actions.html.haml | 20 +------------------ .../_show_custom_button_group.html.haml | 20 +------------------ .../_table_button.html.haml | 19 ++++++++++++++++++ 3 files changed, 21 insertions(+), 38 deletions(-) create mode 100644 app/views/generic_object_definition/_table_button.html.haml diff --git a/app/views/generic_object_definition/_show_actions.html.haml b/app/views/generic_object_definition/_show_actions.html.haml index 9310d6b2f1d..89ee9c78983 100644 --- a/app/views/generic_object_definition/_show_actions.html.haml +++ b/app/views/generic_object_definition/_show_actions.html.haml @@ -21,24 +21,6 @@ %td = obj[:description] - unless @record.custom_buttons.empty? - %hr - %h3 - = _('Buttons') - %table.table.table-bordered.table-hover.table-striped - %thead - %th.table-view-pf-select - %th - = _('Text') - %th - = _('Hover Text') - %tbody - - @record.custom_buttons.each do |obj| - %tr{:title => 'hi'} - %td.table-view-pf-select - %i{:class => obj.options[:button_icon], :style => obj.options.key?(:button_color) ? "color: #{obj.options[:button_color]};" : nil} - %td - = obj[:name] - %td - = obj[:description] + = render :partial => 'table_button' , :locals => {:buttons => @record.custom_buttons.sort_by{ |button| button.name.downcase }} :javascript $('#searchbox').hide(); diff --git a/app/views/generic_object_definition/_show_custom_button_group.html.haml b/app/views/generic_object_definition/_show_custom_button_group.html.haml index 02394c843d7..2f916eb71fd 100644 --- a/app/views/generic_object_definition/_show_custom_button_group.html.haml +++ b/app/views/generic_object_definition/_show_custom_button_group.html.haml @@ -31,25 +31,7 @@ %hr = render :partial => 'layouts/info_msg', :locals => {:message => _("No Buttons found.")} - else - %hr - %h3 - = _('Buttons') - %table.table.table-bordered.table-hover.table-striped - %thead - %th.table-view-pf-select - %th - = _('Text') - %th - = _('Hover Text') - %tbody - - @record.custom_buttons.each do |obj| - %tr{:title => 'hi'} - %td.table-view-pf-select - %i{:class => obj.options[:button_icon], :style => obj.options.key?(:button_color) ? "color: #{obj.options[:button_color]};" : nil} - %td - = obj[:name] - %td - = obj[:description] + = render :partial => 'table_button', :locals => {:buttons => @record.set_data[:button_order].map{ |id| CustomButton.find_by(:id => id) }} %generic-object-definition-toolbar#generic_object_definition_show_form{'record-id' => @record.id, 'entity' => _('Custom Button Group'), diff --git a/app/views/generic_object_definition/_table_button.html.haml b/app/views/generic_object_definition/_table_button.html.haml new file mode 100644 index 00000000000..4e691b2ec20 --- /dev/null +++ b/app/views/generic_object_definition/_table_button.html.haml @@ -0,0 +1,19 @@ +%hr + %h3 + = _('Buttons') + %table.table.table-bordered.table-hover.table-striped + %thead + %th.table-view-pf-select + %th + = _('Text') + %th + = _('Hover Text') + %tbody + - buttons.each do |obj| + %tr{:title => 'hi'} + %td.table-view-pf-select + %i{:class => obj.options[:button_icon], :style => obj.options.key?(:button_color) ? "color: #{obj.options[:button_color]};" : nil} + %td + = obj[:name] + %td + = obj[:description] From 952e17e90d551dd67558a7e857e44fc4cc2aa688 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Thu, 10 Jan 2019 11:22:29 +0100 Subject: [PATCH 2/3] Change unless to if --- app/views/generic_object_definition/_show_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/generic_object_definition/_show_actions.html.haml b/app/views/generic_object_definition/_show_actions.html.haml index 89ee9c78983..611dc0efa33 100644 --- a/app/views/generic_object_definition/_show_actions.html.haml +++ b/app/views/generic_object_definition/_show_actions.html.haml @@ -1,6 +1,6 @@ #main_div = render :partial => "layouts/flash_msg" - - unless @record.custom_button_sets.empty? + - if @record.custom_button_sets.present? %hr %h3 = _('Button Groups') @@ -20,7 +20,7 @@ = obj[:name] %td = obj[:description] - - unless @record.custom_buttons.empty? + - if @record.custom_buttons.present? = render :partial => 'table_button' , :locals => {:buttons => @record.custom_buttons.sort_by{ |button| button.name.downcase }} :javascript $('#searchbox').hide(); From af2c922a6e31bd55163b6a1b0f4d2c66784edb05 Mon Sep 17 00:00:00 2001 From: Zita Nemeckova Date: Thu, 10 Jan 2019 11:25:12 +0100 Subject: [PATCH 3/3] Remove greetings from %tr --- app/views/generic_object_definition/_show_actions.html.haml | 2 +- app/views/generic_object_definition/_table_button.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/generic_object_definition/_show_actions.html.haml b/app/views/generic_object_definition/_show_actions.html.haml index 611dc0efa33..ecd3527a223 100644 --- a/app/views/generic_object_definition/_show_actions.html.haml +++ b/app/views/generic_object_definition/_show_actions.html.haml @@ -13,7 +13,7 @@ = _('Hover Text') %tbody - @record.custom_button_sets.each do |obj| - %tr{:title => 'hi'} + %tr %td.table-view-pf-select %i{:class => obj.set_data[:button_icon], :style => obj.set_data.key?(:button_color) ? "color: #{obj.set_data[:button_color]};" : nil} %td diff --git a/app/views/generic_object_definition/_table_button.html.haml b/app/views/generic_object_definition/_table_button.html.haml index 4e691b2ec20..f481dd397ca 100644 --- a/app/views/generic_object_definition/_table_button.html.haml +++ b/app/views/generic_object_definition/_table_button.html.haml @@ -10,7 +10,7 @@ = _('Hover Text') %tbody - buttons.each do |obj| - %tr{:title => 'hi'} + %tr %td.table-view-pf-select %i{:class => obj.options[:button_icon], :style => obj.options.key?(:button_color) ? "color: #{obj.options[:button_color]};" : nil} %td