Skip to content

Commit

Permalink
fold empty stage sections
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Sep 21, 2017
1 parent 7193f1f commit 649efaf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions app/views/stages/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,30 @@
</fieldset>

<%= Samson::Hooks.render_views(:stage_form, self, form: form) %>

<script>
// fold empty fieldsets and let users unfold them to reduce clutter
$(function(){
$("fieldset").each(function(_, fieldset){
var fieldset = $(fieldset);
var form_elements = fieldset.find('> *').not('legend');

var filled = fieldset.find(':input').filter(function(_, el){
if(el.type == "checkbox" || el.type == "radio") {
return $(el).is(':checked');
} else if(el.type == "hidden") {
return false;
} else {
return $(el).val() != "";
}
});

if(filled.size() == 0) {
fieldset.find('legend').
click(function(){ form_elements.toggle() }).click().
css('cursor', 'pointer').
append(' &#x2304;');
}
});
});
</script>
4 changes: 2 additions & 2 deletions plugins/new_relic/app/views/samson_new_relic/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</div>
<% end %>
<% else %>
Error fetching newrelic apps.
<div>Error fetching newrelic apps.</div>
<% end %>
<% else %>
Set NEWRELIC_API_KEY to use NewRelic stats (disable the new_relic plugin to hide this warning).
<div>Set NEWRELIC_API_KEY to use NewRelic stats (disable the new_relic plugin to hide this warning).</div>
<% end %>
</fieldset>

0 comments on commit 649efaf

Please sign in to comment.