kopia lustrzana https://github.com/wagtail/wagtail
Move the document chooser HTML markup from document_chooser_panel.html entirely within the AdminDocumentChooser widget's render() method
rodzic
fe797437e7
commit
41577759a1
|
@ -349,8 +349,6 @@
|
|||
{% include "wagtailimages/images/_file_field.html" %}
|
||||
{% elif field.name == 'image_chooser' %}
|
||||
<li>{% include "wagtailimages/edit_handlers/image_chooser_panel.html" with field=field only %}</li>
|
||||
{% elif field.name == 'document_chooser' %}
|
||||
<li>{% include "wagtaildocs/edit_handlers/document_chooser_panel.html" with field=field only %}</li>
|
||||
{% else %}
|
||||
{% include "wagtailadmin/shared/field_as_li.html" %}
|
||||
{% endif %}
|
||||
|
|
|
@ -5,7 +5,6 @@ from .widgets import AdminDocumentChooser
|
|||
|
||||
|
||||
class BaseDocumentChooserPanel(BaseChooserPanel):
|
||||
field_template = "wagtaildocs/edit_handlers/document_chooser_panel.html"
|
||||
object_type_name = "document"
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,7 +1,2 @@
|
|||
{% extends "wagtailadmin/edit_handlers/chooser_panel.html" %}
|
||||
{% load i18n %}
|
||||
{% block chooser_class %}document-chooser{% endblock %}
|
||||
|
||||
{% block chosen_state_view %}
|
||||
<span class="title">{{ document.title }}</span>
|
||||
{% endblock %}
|
||||
{# Document chooser is now implemented as an entirely standard form widget - document_chooser_panel.html is redundant #}
|
||||
{% include "wagtailadmin/shared/field.html" %}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{% extends "wagtailadmin/widgets/chooser.html" %}
|
||||
{% block chooser_class %}document-chooser{% endblock %}
|
||||
|
||||
{% block chosen_state_view %}
|
||||
<span class="title">{{ document.title }}</span>
|
||||
{% endblock %}
|
|
@ -2,14 +2,29 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
import json
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from wagtail.wagtailadmin.widgets import AdminChooser
|
||||
from wagtail.wagtaildocs.models import Document
|
||||
|
||||
|
||||
class AdminDocumentChooser(AdminChooser):
|
||||
choose_one_text = _('Choose a document')
|
||||
choose_another_text = _('Choose another document')
|
||||
|
||||
def render_html(self, name, value, attrs):
|
||||
original_field_html = super(AdminDocumentChooser, self).render_html(name, value, attrs)
|
||||
|
||||
instance = self.get_instance(Document, value)
|
||||
|
||||
return render_to_string("wagtaildocs/widgets/document_chooser.html", {
|
||||
'widget': self,
|
||||
'original_field_html': original_field_html,
|
||||
'attrs': attrs,
|
||||
'value': value,
|
||||
'document': instance,
|
||||
})
|
||||
|
||||
def render_js_init(self, id_, name, value):
|
||||
return "createDocumentChooser({0});".format(json.dumps(id_))
|
||||
|
|
Ładowanie…
Reference in New Issue