Ticket #7028: improved-raw-id-admin-feedback.diff
File improved-raw-id-admin-feedback.diff, 3.1 KB (added by , 17 years ago) |
---|
-
contrib/admin/media/js/admin/RelatedObjectLookups.js
26 26 return false; 27 27 } 28 28 29 function dismissRelatedLookupPopup(win, chosenId ) {29 function dismissRelatedLookupPopup(win, chosenId, chosenName) { 30 30 var name = win.name.replace(/___/g, '.'); 31 31 var elem = document.getElementById(name); 32 var nameElem = document.getElementById("view_lookup_" + name); 32 33 if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) { 33 34 elem.value += ',' + chosenId; 34 35 } else { 35 36 document.getElementById(name).value = chosenId; 36 37 } 38 if(nameElem) { 39 nameElem.innerHTML = chosenName; 40 } 37 41 win.close(); 38 42 } 39 43 -
contrib/admin/templatetags/admin_list.py
196 196 # Convert the pk to something that can be used in Javascript. 197 197 # Problem cases are long ints (23L) and non-ASCII strings. 198 198 result_id = repr(force_unicode(getattr(result, pk)))[1:] 199 result_name = str(result) 199 200 yield mark_safe(u'<%s%s><a href="%s"%s>%s</a></%s>' % \ 200 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s ); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))201 (table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s, %r); return false;"' % (result_id or '', result_name)), conditional_escape(result_repr), table_tag)) 201 202 else: 202 203 yield mark_safe(u'<td%s>%s</td>' % (row_class, conditional_escape(result_repr))) 203 204 -
contrib/admin/widgets.py
102 102 (related_url, url, name)) 103 103 output.append('<img src="%simg/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>' % settings.ADMIN_MEDIA_PREFIX) 104 104 if value: 105 output.append(self.label_for_value(value)) 105 # TODO: "id_" is hard-coded here. This should instead use the correct 106 # API to determine the ID dynamically. 107 output.append(self.label_for_value(value, "id_%s" % name)) 106 108 return mark_safe(u''.join(output)) 107 109 108 def label_for_value(self, value ):109 return ' <strong >%s</strong>' % \110 truncate_words(self.rel.to.objects.get(pk=value), 14)110 def label_for_value(self, value, name): 111 return ' <strong id="view_lookup_%s">%s</strong>' % \ 112 (name, truncate_words(self.rel.to.objects.get(pk=value), 14)) 111 113 112 114 class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): 113 115 """