From: Imre Farkas <ifarkas(a)redhat.com>
---
src/app/helpers/provider_selections_helper.rb | 37 ++++++++++++++++++++++
.../views/provider_priority_groups/index.html.haml | 2 +-
.../provider_selections/edit_strategy.html.haml | 14 --------
src/app/views/provider_selections/show.html.haml | 14 ++++----
4 files changed, 44 insertions(+), 23 deletions(-)
create mode 100644 src/app/helpers/provider_selections_helper.rb
delete mode 100644 src/app/views/provider_selections/edit_strategy.html.haml
diff --git a/src/app/helpers/provider_selections_helper.rb
b/src/app/helpers/provider_selections_helper.rb
new file mode 100644
index 0000000..1e1dc4f
--- /dev/null
+++ b/src/app/helpers/provider_selections_helper.rb
@@ -0,0 +1,37 @@
+#
+# Copyright 2012 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+module ProviderSelectionsHelper
+
+ def strategy_toggle_state(strategy)
+ provider_selection_strategy =
@pool.provider_selection_strategies.find_by_name(strategy.name)
+ if provider_selection_strategy.present? &&
provider_selection_strategy.enabled
+ 'on'
+ else
+ 'off'
+ end
+ end
+
+ def strategy_actions(strategy)
+ provider_selection_strategy =
@pool.provider_selection_strategies.find_by_name(strategy.name)
+ if provider_selection_strategy.present? &&
provider_selection_strategy.enabled
+ if strategy.klass.properties.has_key?(:edit_path)
+ strategy_edit_path = send(strategy.klass.properties[:edit_path])
+ link_to(t('provider_selection.show.configure'), strategy_edit_path,
:class => 'configure_strategy_button')
+ end
+ end
+ end
+
+end
diff --git a/src/app/views/provider_priority_groups/index.html.haml
b/src/app/views/provider_priority_groups/index.html.haml
index e742820..fd2b5da 100644
--- a/src/app/views/provider_priority_groups/index.html.haml
+++ b/src/app/views/provider_priority_groups/index.html.haml
@@ -4,7 +4,7 @@
.obj_actions
.return_to
= t(:return_to)
- = link_to t('provider_selection.edit_stategy.strategies', :pool =>
@pool.name), pool_provider_selection_path(@pool)
+ = link_to t('provider_priority_groups.index.back_to_strategies', :pool
=> @pool.name), pool_provider_selection_path(@pool)
%h1.no-icon= t('provider_selection.show.provider_selection')
%section.content-section
diff --git a/src/app/views/provider_selections/edit_strategy.html.haml
b/src/app/views/provider_selections/edit_strategy.html.haml
deleted file mode 100644
index ae51a43..0000000
--- a/src/app/views/provider_selections/edit_strategy.html.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-= render :partial => 'layouts/admin_nav'
-
-%header.page-header
- .obj_actions
- .return_to
- = t(:return_to)
- = link_to t('provider_selection.edit_stategy.strategies', :pool =>
@pool.name), pool_provider_selection_path(@pool)
- %h1.no-icon= t('provider_selection.show.provider_selection')
-
-%section.content-section
- %header
- %h2=t t('provider_selection.show.edit_strategy', :name =>
@strategy.translated_name)
- .content
- = render :partial => "#{(a)strategy.name}/form"
diff --git a/src/app/views/provider_selections/show.html.haml
b/src/app/views/provider_selections/show.html.haml
index c10014c..8fc87ee 100644
--- a/src/app/views/provider_selections/show.html.haml
+++ b/src/app/views/provider_selections/show.html.haml
@@ -11,12 +11,10 @@
%header
%h2=t 'Available Strategies'
.content
- %table.flat
- %thead
- %tbody
+ %table.provider-selection-strategies
+ - ProviderSelection::Base.strategies.each do |strategy|
%tr
- %td= link_to(t('provider_selection.show.strategies.strict_order'),
pool_provider_selection_provider_priority_groups_path(@pool))
- - ProviderSelection::Base.strategies.each do |strategy|
- - if strategy.include_in_listings
- %tr
- %td= link_to(strategy.translated_name,
edit_strategy_pool_provider_selection_path(:name => strategy.name))
+ %td.status
+ = link_to('', toggle_strategy_pool_provider_selection_path(@pool,
strategy.name), :class => "status-toggle
#{strategy_toggle_state(strategy)}")
+ %td= strategy.translated_name
+ %td.right= strategy_actions(strategy)
--
1.7.11.2