Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[soc2009/admin-ui] Fix for ticket #11718: "When there is an error in …

…a SelectorInline, there is no way to tell which inline has the error"

The selector with the error is now highlighted and selected on reload. 


git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/admin-ui@11461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 687a5af25a6dd9223b6b1ac6804460e123fd6312 1 parent ed30463
Zain Memon zain authored
6 django/contrib/admin/media/css/forms.css
View
@@ -345,6 +345,12 @@ li.inline-selector-item:hover {
background-color: #C1DBFD;
}
+.selector-error {
+ font-weight: bold;
+ border: 2px solid #F00000 !important;
+}
+
+
.inline-detail {
float: right;
width: 80%;
30 django/contrib/admin/templates/admin/edit_inline/selector.html
View
@@ -96,19 +96,33 @@
<script type="text/javascript">
$(function() {
/* Selector */
- $('.inline-detail .selector-item-detail').hide();
- $('.inline-detail .selector-item-detail:first').show();
- $('.inline-selector .inline-selector-item:first').addClass('inline-selected');
-
- $('.inline-selector-item').click(function () {
+ function select_inline(inline) {
$('.inline-detail .selector-item-detail').hide();
$('.inline-selector .inline-selector-item').removeClass('inline-selected');
- $(this).addClass('inline-selected');
+ $(inline).addClass('inline-selected');
- var div_to_show = '#' + $(this).find('a').attr('title');
+ var div_to_show = '#' + $(inline).find('a').attr('title');
$(div_to_show).show();
-
+ }
+
+ $('.inline-detail .selector-item-detail').hide();
+ $('.inline-detail .selector-item-detail:first').show();
+ $('.inline-selector .inline-selector-item:first').addClass('inline-selected');
+ $('.form-row.errors').each(function() {
+ var id = $(this).parents('.selector-item-detail').attr('id').substring({{ inline_admin_formset.opts.verbose_name|length}});
+ $("#{{ inline_admin_formset.opts.verbose_name}}" + id + "-selector").addClass('selector-error');
+ });
+
+ if ($('.form-row.errors').html()) {
+ select_inline('.selector-error:first');
+ }
+ else {
+ select_inline('.inline-selector-item:first');
+ }
+
+ $('.inline-selector-item').click(function () {
+ select_inline(this);
return false;
});
Please sign in to comment.
Something went wrong with that request. Please try again.