On Tue, Mar 29, 2011 at 12:16:11PM +0200, tsedovic(a)redhat.com wrote:
From: Tomas Sedovic <tsedovic(a)redhat.com>
In the New Hardware Profile page, the pane with the matching profiles were not
being displayed correctly.
---
.../admin/hardware_profiles_controller.rb | 33 ++++++++++++++------
.../hardware_profiles_controller_spec.rb | 1 +
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/app/controllers/admin/hardware_profiles_controller.rb
b/src/app/controllers/admin/hardware_profiles_controller.rb
index a236d59..783c0e8 100644
--- a/src/app/controllers/admin/hardware_profiles_controller.rb
+++ b/src/app/controllers/admin/hardware_profiles_controller.rb
@@ -8,17 +8,26 @@ class Admin::HardwareProfilesController < ApplicationController
def index
@params = params
- @search_term = params[:q]
- if @search_term.blank?
- load_hardware_profiles
- return
- end
+ respond_to do |format|
+ format.js do
+ build_hardware_profile(params[:hardware_profile])
+ matching_provider_hardware_profiles
+ render :partial => 'matching_provider_hardware_profiles' and return
+ end
+ format.html do
+ @search_term = params[:q]
+ if @search_term.blank?
+ load_hardware_profiles
+ return
+ end
- search = HardwareProfile.search do
- keywords(params[:q])
- with(:frontend, true)
+ search = HardwareProfile.search do
+ keywords(params[:q])
+ with(:frontend, true)
+ end
+ @hardware_profiles = search.results
+ end
end
- @hardware_profiles = search.results
end
def show
@@ -43,6 +52,10 @@ class Admin::HardwareProfilesController < ApplicationController
end
def new
+ respond_to do |format|
+ format.js { render :partial => 'matching_provider_hardware_profiles' }
+ format.html { render :action => 'new'}
+ end
end
def create
@@ -185,7 +198,7 @@ class Admin::HardwareProfilesController < ApplicationController
end
def create_hwpp(hwpp, params)
- hwpp.nil? ? hardwareProfileProperty = HardwareProfileProperty.new :
hardwareProfileProperty = hwpp
+ hardwareProfileProperty = hwpp.nil? ? HardwareProfileProperty.new : hwpp
hardwareProfileProperty.name = params[:name]
hardwareProfileProperty.kind = "fixed"
diff --git a/src/spec/controllers/hardware_profiles_controller_spec.rb
b/src/spec/controllers/hardware_profiles_controller_spec.rb
index f9410dc..c7bb49f 100644
--- a/src/spec/controllers/hardware_profiles_controller_spec.rb
+++ b/src/spec/controllers/hardware_profiles_controller_spec.rb
@@ -11,6 +11,7 @@ describe Admin::HardwareProfilesController do
it "should provide ui to view all hardware profiles" do
UserSession.create(@admin)
+ @request.accept = "text/html"
get :index
response.should be_success
assigns[:hardware_profiles].size.should == HardwareProfile.count
ACK. The New Hardware Profile page works properly and all tests pass.
Thanks!
-- Matt