Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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 authored August 15, 2009
6  django/contrib/admin/media/css/forms.css
@@ -345,6 +345,12 @@ li.inline-selector-item:hover {
345 345
     background-color: #C1DBFD;
346 346
 }
347 347
 
  348
+.selector-error {
  349
+    font-weight: bold;
  350
+    border: 2px solid #F00000 !important;
  351
+}
  352
+
  353
+
348 354
 .inline-detail {
349 355
     float: right;
350 356
     width: 80%;
30  django/contrib/admin/templates/admin/edit_inline/selector.html
@@ -96,19 +96,33 @@
96 96
 <script type="text/javascript">
97 97
 $(function() {
98 98
     /* Selector */
99  
-    $('.inline-detail .selector-item-detail').hide();
100  
-    $('.inline-detail .selector-item-detail:first').show();
101  
-    $('.inline-selector .inline-selector-item:first').addClass('inline-selected');
102  
-    
103  
-    $('.inline-selector-item').click(function () {
  99
+    function select_inline(inline) {
104 100
         $('.inline-detail .selector-item-detail').hide();
105 101
         $('.inline-selector .inline-selector-item').removeClass('inline-selected');
106 102
 
107  
-        $(this).addClass('inline-selected');
  103
+        $(inline).addClass('inline-selected');
108 104
         
109  
-        var div_to_show = '#' + $(this).find('a').attr('title');
  105
+        var div_to_show = '#' + $(inline).find('a').attr('title');
110 106
         $(div_to_show).show();
111  
-        
  107
+    }
  108
+    
  109
+    $('.inline-detail .selector-item-detail').hide();
  110
+    $('.inline-detail .selector-item-detail:first').show();
  111
+    $('.inline-selector .inline-selector-item:first').addClass('inline-selected');
  112
+    $('.form-row.errors').each(function() {
  113
+        var id = $(this).parents('.selector-item-detail').attr('id').substring({{ inline_admin_formset.opts.verbose_name|length}});
  114
+        $("#{{ inline_admin_formset.opts.verbose_name}}" + id + "-selector").addClass('selector-error');
  115
+    });
  116
+    
  117
+    if ($('.form-row.errors').html()) {
  118
+        select_inline('.selector-error:first');
  119
+    }
  120
+    else {
  121
+        select_inline('.inline-selector-item:first');
  122
+    }
  123
+    
  124
+    $('.inline-selector-item').click(function () {
  125
+        select_inline(this);
112 126
         return false;
113 127
     });
114 128
     

0 notes on commit 687a5af

Please sign in to comment.
Something went wrong with that request. Please try again.