Skip to content

Commit

Permalink
Show error state on tabs and auto-switch to first tab with errors
Browse files Browse the repository at this point in the history
Automatically sets tabs with errors to red color (red background
on inactive tabs) and switches to the first tab that has errors.

Bug #51
  • Loading branch information
mfitzp committed Aug 26, 2015
1 parent 017536b commit 8efcb43
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions wooey/templates/wooey/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@
background-color: #555;
}

li.tab-error > a {
color: #A94442;
background-color: #F2DEDE;
}

li.active.tab-error > a {
color: #A94442;
background-color: #fff;
}


{% block extra_style %}
{% endblock extra_style %}
</style>
Expand Down Expand Up @@ -519,6 +530,8 @@
}

function processErrors($form, errors){
var previous_tab_error = false;

for (var key in errors){
for(var i=0;i<errors[key].length;i++) {
var error = errors[key][i];
Expand All @@ -538,10 +551,23 @@
$field = $field2;
}
}
if ($form.hasClass('form-inline') || $form.hasClass('navbar-form'))
if ($form.hasClass('form-inline') || $form.hasClass('navbar-form')) {
addInlineError($field, error);
else
} else
addUlError($field, error);

// See if we're in a tabbed view; find the parent tab and set it to error state
$tab_pane = $field.closest('.tab-pane')
if($tab_pane){
id = $tab_pane.attr('id');
obj = $('a[href="#' + id + '"]').parent()
obj.addClass('tab-error');

// If first time we've seen a tab error, change the (.active) tab
if(!previous_tab_error){
obj.tab('show');
}
}
}
}
}
Expand Down

0 comments on commit 8efcb43

Please sign in to comment.