Permalink
Browse files

populate select options on fieldset open, change to regular select, r…

…efs #29
  • Loading branch information...
1 parent 0cf0420 commit a40d524418e66c7c8317f34c478fd7eedd3d26ff obfuscurity committed Aug 9, 2012
@@ -98,7 +98,7 @@ fieldset.collapse.in#dashboard_form {
margin: 0;
}
-.collapse.in select {
+.collapse.in#import_form select {
min-height: 150px;
min-width: 400px;
margin-bottom: 20px;
@@ -86,6 +86,7 @@ var resetFieldsetFormAndButtons = function(target) {
};
// Invert "Import Graphs" button mode when activated
+// Populate "Import Saved Graphs" select field
$(window).on('click', 'a.import.btn', function() {
if ($('fieldset.in.collapse').length > 0) {
$('form#graph_select ul li select option').remove();
@@ -107,10 +108,24 @@ $(window).on('click', 'a.import.btn', function() {
});
// Invert "Add to Dashboard" button mode when activated
+// Populate "Add to Selected Dashboards" select field
$(window).on('click', 'a.dashboard.btn', function() {
if ($('fieldset.in.collapse').length > 0) {
resetFieldsetFormAndButtons($(this).attr('data-target'));
$(this).text('Cancel Dashboard').addClass('btn-inverse');
+ $('#dashboard_select ul li select option').remove();
+ $.ajax({
+ accepts: {json: 'application/json'},
+ cache: false,
+ dataType: 'json',
+ error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
+ url: '/dashboards'
+ }).done(function(results) {
+ for (var i in results) {
+ console.log(results[i]);
+ $('#dashboard_select ul li select').append('<option value="' + results[i].uuid + '">' + results[i].name + '</option>');
+ }
+ });
} else {
$(this).text('Add to Dashboard').removeClass('btn-inverse');
}
@@ -139,25 +154,6 @@ $(window).on('click', 'button.dashboard_submit', function() {
return false;
});
-// Populate our "Add to Dashboard" dropdown list
-$('div.append.btn-group').on('click', 'button.append.dropdown-toggle', function() {
- // only execute on dropdown open, not on close
- if ($('div.append.btn-group.open').length === 0) {
- $('div.append.btn-group ul.append.dropdown-menu li').remove();
- $.ajax({
- accepts: {json: 'application/json'},
- cache: false,
- dataType: 'json',
- error: function(xhr, textStatus, errorThrown) { console.log(errorThrown); },
- url: '/dashboards'
- }).done(function(results) {
- for (var i in results) {
- $('div.append.btn-group ul.append.dropdown-menu').append('<li class="append"><a id="' + results[i].uuid + '" href="#">' + results[i].name + '</a></li>');
- }
- });
- }
-});
-
// Add current view to selected dashboard
// Redirect to dashboard on success
$('div.append.btn-group ul.append.dropdown-menu').on('click', 'li.append', function() {
@@ -43,9 +43,9 @@
#dashboard_select
%ul
%li
- %select{ :id => "dashboard_select", :name => "dashboard_select", :multiple => "multiple" }
+ %select{ :id => "dashboard_select", :name => "dashboard_select" }
%li
- %button{ :class => "dashboard_submit btn btn-primary" } Add to Existing Dashboard
+ %button{ :class => "dashboard_submit btn btn-primary" } Add to Selected Dashboard
#dashboard_new
%form{ :id => "dashboard_new", :method => "post", :action => "/dashboards" }
%ul

0 comments on commit a40d524

Please sign in to comment.