add code to work as a plone popup
This commit is contained in:
parent
1d37c8a059
commit
64a6744bd2
|
@ -0,0 +1,36 @@
|
|||
{% extends "thesaurus/term_list.html" %}
|
||||
|
||||
{% block aftercontent %}
|
||||
|
||||
<script>
|
||||
function thesaurus_popup_init() {
|
||||
$('#term-content a, #thesaurus-terms a').unbind('click').click(function() {
|
||||
$.ajax({
|
||||
url: $(this).attr('href'),
|
||||
success: function(data, status) {
|
||||
$('#entry-points').hide();
|
||||
$('#term-content').empty();
|
||||
$(data).find('table').appendTo($('#term-content'));
|
||||
$('#term-content').find('button').show().click(function() {
|
||||
var orig_link = $('a[rel=#' + $(this).parents('.overlay-ajax').attr('id') + ']');
|
||||
var orig_input = $(orig_link).parent().find('input')[0];
|
||||
var orig_ac_input = $(orig_link).parent().find('input')[1];
|
||||
$(orig_input).val($(orig_input).val() + ' ' + $(this).data('term-id'));
|
||||
var labelbox = create_labelbox(
|
||||
orig_ac_input,
|
||||
$(this).data('term-id'),
|
||||
$(this).parent().find('h2').text());
|
||||
$(orig_link).before(labelbox);
|
||||
$('.close').click();
|
||||
});
|
||||
thesaurus_popup_init();
|
||||
$('#term-content').show();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
thesaurus_popup_init();
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
@ -21,6 +22,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td><h2>{{object.term}}</h2>
|
||||
<button data-term-id="{{object.tabellio_id}}" style="display: none">{% trans 'Select' %}</button>
|
||||
{% if object.alternativeterm_set.count %}
|
||||
<div>
|
||||
<h3>Employé pour (équivalences)</h3>
|
||||
|
@ -36,7 +38,7 @@
|
|||
<p>{{ object.historical_note }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div id="entry-points">
|
||||
<h2>Points d'entrée</h2>
|
||||
|
||||
<ul>
|
||||
<ul id="thesaurus-terms">
|
||||
{% for term in object_list %}
|
||||
<li><a href="{% url 'term' pk=term.pk %}">{{ term.term }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="term-content">
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -3,6 +3,8 @@ from django.contrib import admin
|
|||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', 'pfwb_thesaurus.views.home', name='home'),
|
||||
url(r'^term/(?P<pk>\w+)$', 'pfwb_thesaurus.views.term', name='term'),
|
||||
url(r'^thesaurus/plone-popup/$', 'pfwb_thesaurus.views.plone_popup'),
|
||||
url(r'^thesaurus/term/(?P<pk>\w+)$', 'pfwb_thesaurus.views.term', name='term'),
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
|
|
@ -29,6 +29,12 @@ class HomeView(ListView):
|
|||
home = HomeView.as_view()
|
||||
|
||||
|
||||
class PlonePopupView(HomeView):
|
||||
template_name = 'thesaurus/plone_popup.html'
|
||||
|
||||
plone_popup = PlonePopupView.as_view()
|
||||
|
||||
|
||||
class TermView(DetailView):
|
||||
model = Term
|
||||
|
||||
|
|
Reference in New Issue