Show all rename fields in preview table for models with both name and label
For device/module component models, the preview table now always shows four columns: Current Name, New Name, Current Label, New Label. The New column for the non-targeted field is left empty to make clear which field the find/replace pattern applies to. This gives users full context when identifying objects and planning renames. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6c58b4e8c0
commit
f986903f6e
|
|
@ -910,6 +910,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
|
|||
)
|
||||
|
||||
rename_fields = self._get_rename_fields()
|
||||
self.has_label_field = bool(rename_fields)
|
||||
form_attrs = {
|
||||
'pk': ModelMultipleChoiceField(
|
||||
queryset=self.queryset,
|
||||
|
|
@ -1017,6 +1018,7 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
|
|||
|
||||
return render(request, self.template_name, {
|
||||
'field_name': field_name,
|
||||
'has_label_field': self.has_label_field,
|
||||
'form': form,
|
||||
'obj_type_plural': self.queryset.model._meta.verbose_name_plural,
|
||||
'selected_objects': selected_objects,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,28 @@ Context:
|
|||
<div class="row mb-3">
|
||||
<div class="col col-md-7">
|
||||
<table class="table">
|
||||
{% if has_label_field %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Current Name" %}</th>
|
||||
<th>{% trans "New Name" %}</th>
|
||||
<th>{% trans "Current Label" %}</th>
|
||||
<th>{% trans "New Label" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for obj in selected_objects %}
|
||||
{% with current_target=obj|getattr:field_name %}
|
||||
<tr{% if obj.new_name and current_target != obj.new_name %} class="success"{% endif %}>
|
||||
<td>{{ obj.name }}</td>
|
||||
<td>{% if field_name == 'name' %}{{ obj.new_name }}{% endif %}</td>
|
||||
<td>{{ obj.label }}</td>
|
||||
<td>{% if field_name == 'label' %}{{ obj.new_name }}{% endif %}</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% else %}
|
||||
<thead>
|
||||
{% with field_label=field_name|title %}
|
||||
<tr>
|
||||
|
|
@ -52,6 +74,7 @@ Context:
|
|||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="col col-md-5">
|
||||
|
|
|
|||
Loading…
Reference in New Issue