Skip to content

Commit

Permalink
Bug 768953 - Creating a new system from the webui fails to display En…
Browse files Browse the repository at this point in the history
…vironment ribbon correctly

https://bugzilla.redhat.com/show_bug.cgi?id=768953
+ The environment selector, because only one can exist on the page at a time, has some control code around it to detect whether the "all" systems page is being viewed or the per-environment page. Fixed now.
  • Loading branch information
thomasmckay committed Jan 6, 2012
1 parent e196ff2 commit 741f0b9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/controllers/systems_controller.rb
Expand Up @@ -120,7 +120,7 @@ def environments
@panel_options[:search_env] = @environment.id
end

render :index, :locals=>{:envsys => 'true', :accessible_envs=> accesible_envs}
render :index, :locals=>{:envsys => true, :accessible_envs=> accesible_envs}
rescue Exception => error
notice error.to_s, {:level => :error, :persist => false}
render :index, :status=>:bad_request
Expand Down
20 changes: 19 additions & 1 deletion src/app/views/systems/index.html.haml
@@ -1,9 +1,27 @@

= javascript :env_select

-# Add env selector and Set the flag appropriately to indicate if there is one
-if defined? envsys
-if envsys == true
= javascript do
:javascript
$(document).ready(function() {
env_select.envsys = true
});
-else
= javascript do
:javascript
$(document).ready(function() {
env_select.envsys = false
});
.grid_16
= environment_selector(:locker_clickable=>false, :accessible_envs=>accessible_envs, :url_proc => lambda {|a| environments_systems_path(:env_id =>a[:environment].id )})
-else
= javascript do
:javascript
$(document).ready(function() {
env_select.envsys = false
});

.grid_16#main
= two_panel(@systems, @panel_options)
Expand Down
16 changes: 9 additions & 7 deletions src/public/javascripts/systems.js
Expand Up @@ -21,18 +21,20 @@ KT.panel.set_expand_cb(function(){
});

(function(){
var options = { create : 'new_system' };

if (window.env_select !== undefined) {
var options = { create : 'new_system' };

// When the env changes, update the pre-populated attributes
if (window.env_select !== undefined) {

// When the systems index page env selector changes, update the pre-populated attributes
env_select.env_changed_callback = function(env_id) {
$('#new').attr('data-ajax_url', KT.routes.new_system_path() + '?env_id=' + env_id);
if(env_select.envsys == true){
$('#new').attr('data-ajax_url', KT.routes.new_system_path() + '?env_id=' + env_id);
}
$('#system_environment_id').attr('value', env_id);
};

$.extend(options, { 'extra_params' :
[ { hash_id : 'env_id',
$.extend(options, { 'extra_params' :
[ { hash_id : 'env_id',
init_func : function(){
var state = $.bbq.getState('env_id');

Expand Down

0 comments on commit 741f0b9

Please sign in to comment.