Enhance tag up down in a list. Real display for tag list. Enable to remove a tag from a list.
--- a/web/hdabo/static/hdabo/css/style.css Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/static/hdabo/css/style.css Thu Jun 09 16:06:04 2011 +0200
@@ -323,4 +323,26 @@
font-size: 14px;
}
+.complete_sheet {
+ margin-left: 5px;
+ margin-right: 5px;
+}
+.left_sheet {
+ width: 38%;
+ float: left;
+}
+.left_sheet p {
+ margin-bottom: 5px;
+}
+.right_sheet {
+ width: 60%;
+ /*margin-left: 5px;*/
+ float: right;
+}
+.large_25 {
+ width: 25px;
+}
+.text_centered {
+ text-align: center;
+}
Binary file web/hdabo/static/hdabo/img/arrow_right.png has changed
Binary file web/hdabo/static/hdabo/img/red_cross.png has changed
Binary file web/hdabo/static/hdabo/img/tag_remove.png has changed
--- a/web/hdabo/static/hdabo/js/hdabo.js Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/static/hdabo/js/hdabo.js Thu Jun 09 16:06:04 2011 +0200
@@ -1,9 +1,55 @@
-function init_tags_events()
+function init_tags_events()
{
// Up and down management for tag table lines
$(".up,.down").click(function(){
tag_up_down(this);
});
+ // Remove tag for a datasheet's list
+ $(".remove_tag_from_list").click(function(){
+ if(confirm("Confirmez-vous la suppression du tag \"" + $(this).attr('alt') + "\" de la liste courante ?")){
+ remove_tag_from_list(this);
+ }
+ });
+}
+
+function remove_tag_from_list(btn)
+{
+ var url = remove_tag_from_list_url;
+ var id_tag = $(btn).attr('id');
+ $.ajax({
+ url: url,
+ type: 'POST',
+ data: {csrfmiddlewaretoken:global_csrf_token,
+ datasheet_id:$('#datasheet_id').val(),
+ tag_id:id_tag
+ },
+ // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
+ //dataType: 'json',
+ success: function(msg, textStatus, XMLHttpRequest) {
+ $('#tag_table_container').html(msg);
+ init_tags_events();
+ }
+ });
+}
+
+function remove_tag_from_list(btn)
+{
+ var url = remove_tag_from_list_url;
+ var id_tag = $(btn).attr('id');
+ $.ajax({
+ url: url,
+ type: 'POST',
+ data: {csrfmiddlewaretoken:global_csrf_token,
+ datasheet_id:$('#datasheet_id').val(),
+ tag_id:id_tag
+ },
+ // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
+ //dataType: 'json',
+ success: function(msg, textStatus, XMLHttpRequest) {
+ $('#tag_table_container').html(msg);
+ init_tags_events();
+ }
+ });
}
function tag_up_down(arrow)
@@ -15,13 +61,16 @@
}
var url = tag_up_down_url;
var id_tag = $(arrow).attr('id');
+ // This indicates the position (from 0) of the tag in the list. NB : it is different from the TagSheet.order in the database.
+ var pos_tag = $(arrow).attr('pos');
$.ajax({
url: url,
type: 'POST',
data: {csrfmiddlewaretoken:global_csrf_token,
datasheet_id:$('#datasheet_id').val(),
tag_id:id_tag,
- move:mv
+ move:mv,
+ tag_pos:pos_tag
},
// bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
//dataType: 'json',
--- a/web/hdabo/templates/partial/list_for_orga.html Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/templates/partial/list_for_orga.html Thu Jun 09 16:06:04 2011 +0200
@@ -7,7 +7,8 @@
<script type="text/javascript">
var global_csrf_token = "{{ csrf_token }}";
- var tag_up_down_url = "{% url hdabo.views.tag_up_down %}";
+ var tag_up_down_url = "{% url hdabo.views.TagUpDown %}";
+ var remove_tag_from_list_url = "{% url hdabo.views.RemoveTagFromList %}";
$(document).ready(function(){
init_tags_events();
--- a/web/hdabo/templates/partial/one_sheet.html Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/templates/partial/one_sheet.html Thu Jun 09 16:06:04 2011 +0200
@@ -1,30 +1,36 @@
{% block one_sheet %}
-<table>
-{% csrf_token %}
-<input type="hidden" name="datasheet_id" value="{{ds.id}}" id="datasheet_id" />
-<tr><td><b>title</b></td><td><p class="sheet_title">{{ds.title}}</p></td></tr>
-<tr><td><b>description</b></td><td>{{ds.description}}</td></tr>
-<tr><td><b>url</b></td><td><a href="{{ds.url}}" target="_blank">{{ds.url}}</a></td></tr>
-<tr><td><b>domain_text</b></td><td>{{ds.domains_text}}</td></tr>
-<tr><td><b>primary_periods_text</b></td><td>{{ds.primary_periods_text}}</td></tr>
-<tr><td><b>college_periods_text</b></td><td>{{ds.college_periods_text}}</td></tr>
-<tr><td><b>highschool_periods_text</b></td><td>{{ds.highschool_periods_text}}</td></tr>
-<tr><td><b>primary_themes_text</b></td><td>{{ds.primary_themes_text}}</td></tr>
-<tr><td><b>college_themes_text</b></td><td>{{ds.college_themes_text}}</td></tr>
-<tr><td><b>highschool_themes_text</b></td><td>{{ds.highschool_themes_text}}</td></tr>
-<tr><td><b>town_text</b></td><td>{{ds.town_text}}</td></tr>
-<tr><td><b>format</b></td><td>{{ds.format}}</td></tr>
-<tr><td><b>original_creation_date</b></td><td>{{ds.original_creation_date}}</td></tr>
-<tr><td><b>original_modification_date</b></td><td>{{ds.original_modification_date}}</td></tr>
-<tr><td><b>modification_datetime</b></td><td>{{ds.modification_datetime}}</td></tr>
-<tr><td><b>validation_date</b></td><td>{{ds.validation_date}}</td></tr>
-<tr><td><b>validated</b></td><td>{{ds.validated}}</td></tr>
-<tr><td><b>validator</b></td><td>{{ds.validator}}</td></tr>
-<tr>
- <td><b>tags</b></td>
- <td id="tag_table_container">
- {% include "partial/tag_table.html" %}
- </td>
-</tr>
-</table>
+<div class="complete_sheet">
+ <div class="left_sheet">
+ <p><b>id hda</b><br/>{{ds.hda_id}}</p>
+ <p><b>Titre</b><br><span class="sheet_title">{{ds.title}}</span></p>
+ <p><b>Description</b><br/>{{ds.description}}</p>
+ <p><b>Url</b><br/><a href="{{ds.url}}" target="_blank">{{ds.url}}</a></p>
+ <p><b>Domaine artistique</b><br/>{{ds.domains_text}}</p>
+ <p><b>Périodes Primaire</b><br/>{{ds.primary_periods_text}}</p>
+ <p><b>Périodes Collège</b><br/>{{ds.college_periods_text}}</p>
+ <p><b>Périodes Lycée</b><br/>{{ds.highschool_periods_text}}</p>
+ <p><b>Liste de référence du primaire</b><br/>{{ds.primary_themes_text}}</p>
+ <p><b>Thèmes Collège</b><br/>{{ds.college_themes_text}}</p>
+ <p><b>Thèmes Lycée</b><br/>{{ds.highschool_themes_text}}</p>
+ <p><b>Ville</b><br/>{{ds.town_text}}</p>
+ <p><b>Format</b><br/>{{ds.format}}</p>
+ <table><tr><th>Date de création</th><th>Date de modification</th></tr>
+ <tr><td>{{ds.original_creation_date|date:"d/m/Y"}}</td><td>{{ds.modification_datetime|date:"d/m/Y"}}</td></tr></table>
+ {# <p><b>original_modification_date</b><br/>{{ds.original_modification_date|date:"d/m/Y"}}</p> #}
+ </div>
+ <div class="right_sheet">
+ <p><input type="radio" name="gr_validated{{ds.hda_id}}" value="not_validated" {% if not ds.validated %}checked{% endif %} />En cours
+ <input type="radio" name="gr_validated{{ds.hda_id}}" value="validated" {% if ds.validated %}checked{% endif %} />Validé
+ {% if ds.validated %}
+ par : <input type="text" name="validator" value="{{ds.validated}}"/>
+ le {{ds.validation_date}}
+ {% endif %}
+ </p>
+ {% csrf_token %}
+ <input type="hidden" name="datasheet_id" value="{{ds.id}}" id="datasheet_id" />
+ <div id="tag_table_container">
+ {% include "partial/tag_table.html" %}
+ </div>
+ </div>
+</div>
{% endblock %}
--- a/web/hdabo/templates/partial/tag_table.html Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/templates/partial/tag_table.html Thu Jun 09 16:06:04 2011 +0200
@@ -1,53 +1,63 @@
{% block tag_table %}
<table id="tag_table"><tr>
<th>#</th>
- {% if valid != "2" %}
+ {% if valid != "2" and ordered_tags %}
+ <th class="updown_td">M</th>
<th class="updown_td">D</th>
- <th class="updown_td">M</th>
{% endif %}
<th>id</th>
<th>label</th>
{% comment %}<th>original_label</th>{% endcomment %}
- <th>alias</th>
- <th>wikipedia_url</th>
- <th>url_status</th>
- <th>dbpedia_uri</th>
- <th>wikipedia_activated</th></tr>
+ <th class="text_centered">Lien W</th>
+ <th>Facette</th>
+ <th class="text_centered">Désactiver<br/>le lien W</th>
+ <th class="text_centered">Supprimer<br/>le lien W</th>
+ <th>Alias</th>
+ <th class="large_25 text_centered">Retirer le tag de la liste</th></tr>
{% if ordered_tags %}
{# ordered_tags is a list of TaggedSheet #}
{% for t in ordered_tags %}
<tr class="imageline {% cycle 'hdabooddline' 'hdaboevenline' %}">
- <td>{{t.order}}</td>
+ <td>{{forloop.counter}}-{{t.order}}</td>
{% if valid != "2" %}
- <td class="updown_td">{% if not forloop.first %}<img src="{{STATIC_URL}}hdabo/img/arrow_up.png" class="up" alt="up" id={{t.tag.id}}>{% endif %}</td>
- <td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down" id={{t.tag.id}}>{% endif %}</td>
+ <td class="updown_td">{% if not forloop.first %}<img src="{{STATIC_URL}}hdabo/img/arrow_up.png" class="up" alt="up" id={{t.tag.id}} pos="{{forloop.counter0}}">{% endif %}</td>
+ <td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down" id={{t.tag.id}} pos="{{forloop.counter0}}">{% endif %}</td>
{% endif %}
<td>{{t.tag.id}}</td>
<td>{{t.tag.label}}</td>
{% comment %}<td>{{t.tag.original_label}}</td>{% endcomment %}
+ <td class="text_centered"><a href="{% if t.tag.wikipedia_url %}{{t.tag.wikipedia_url}}{% else %}#{% endif %}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a></td>
+ <td><select name="facette">
+ <option value="" selected></option>
+ <option value="datation">Datation</option>
+ <option value="localisation">Localisation</option>
+ <option value="createur">Créateur</option>
+ <option value="ecole">Ecole/Mouvement</option>
+ <option value="discipline">Discipline artistique</option>
+ </select></td>
+ <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id={{t.tag.id}} {% if t.tag.wikipedia_activated %}checked{% endif %}/></td>
+ <td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/red_cross.png" class="remove_wp_link" id="{{t.tag.id}}" /></td>
<td>{{t.tag.alias}}</td>
- <td>{{t.tag.wikipedia_url}}</td>
- <td>{{t.tag.url_status}}</td>
- <td>{{t.tag.dbpedia_uri}}</td>
- <td>{{t.tag.wikipedia_activated}}</td></tr>
+ <td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/tag_remove.png" class="remove_tag_from_list" id="{{t.tag.id}}" alt="{{t.tag.label}}" /></td></tr>
{% endfor %}
{% else %}
{# ds is a DataSheet #}
{% for t in ds.tags.all %}
<tr class="imageline {% cycle 'hdabooddline' 'hdaboevenline' %}">
<td>{{forloop.counter}}</td>
- {% if valid != "2" %}
- <td class="updown_td">{% if not forloop.first %}<img src="{{STATIC_URL}}hdabo/img/arrow_up.png" class="up" alt="up">{% endif %}</td>
- <td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down">{% endif %}</td>
+ {% if valid != "2" and ordered_tags %}
+ <td class="updown_td">{% if not forloop.first %}<img src="{{STATIC_URL}}hdabo/img/arrow_up.png" class="up" alt="up" id="{{t.id}}" pos="{{forloop.counter0}}">{% endif %}</td>
+ <td class="updown_td">{% if not forloop.last %}<img src="{{STATIC_URL}}hdabo/img/arrow_down.png" class="down" alt="down" id="{{t.id}}" pos="{{forloop.counter0}}">{% endif %}</td>
{% endif %}
<td>{{t.id}}</td>
<td>{{t.label}}</td>
{% comment %}<td>{{t.original_label}}</td>{% endcomment %}
- <td>{{t.alias}}</td>
- <td>{{t.wikipedia_url}}</td>
- <td>{{t.url_status}}</td>
- <td>{{t.dbpedia_uri}}</td>
- <td>{{t.wikipedia_activated}}</td></tr>
+ <td class="text_centered"><a href="{% if t.wikipedia_url %}{{t.wikipedia_url}}{% else %}#{% endif %}" target="_blank"><img src="{{STATIC_URL}}hdabo/img/arrow_right.png" ></a></td>
+ <td>facette</td>
+ <td class="text_centered"><input type="checkbox" class="activate_wp_cb" id="{{t.id}}" {% if t.tag.wikipedia_activated %}checked{% endif %} /></td>
+ <td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/red_cross.png" class="remove_wp_link" id="{{t.id}}" /></td>
+ <td>{{t.tag.alias}}</td>
+ <td class="text_centered"><img src="{{STATIC_URL}}hdabo/img/tag_remove.png" class="remove_tag_from_list" id="{{t.id}}" alt="{{t.label}}" /></td></tr>
{% endfor %}
{% endif %}
</table>
--- a/web/hdabo/urls.py Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/urls.py Thu Jun 09 16:06:04 2011 +0200
@@ -20,5 +20,6 @@
url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/$', 'hdabo.views.list_for_orga'),
url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/$', 'hdabo.views.list_for_orga'),
url(r'^list/(?P<orga_id>[\w-]+)/(?P<valid>[\w-]+)/(?P<start_index>[\w-]+)/(?P<length>[\w-]+)/$', 'hdabo.views.list_for_orga'),
- url(r'^tagupdown$', 'hdabo.views.tag_up_down'),
+ url(r'^tagupdown$', 'hdabo.views.TagUpDown'),
+ url(r'^removetagfromlist$', 'hdabo.views.RemoveTagFromList'),
)
--- a/web/hdabo/views.py Tue Jun 07 13:45:23 2011 +0200
+++ b/web/hdabo/views.py Thu Jun 09 16:06:04 2011 +0200
@@ -75,36 +75,38 @@
context_instance=RequestContext(request))
#@login_required
-def tag_up_down(request):
+def TagUpDown(request):
ds_id = request.POST["datasheet_id"]
tag_id = request.POST["tag_id"]
+ # tag_pos indicates the position (from 0) of the tag in the list. NB : it is different from the TagSheet.order in the database.
+ tag_pos = int(request.POST["tag_pos"])
# move can be "u" or "d", for up and down
move = request.POST["move"]
# First we get the datasheet's TaggedSheets
- ds_tags = TaggedSheet.objects.filter(datasheet=Datasheet.objects.filter(id=ds_id)[0])
- # We get the current TaggedSheet ans its's order
- ts = ds_tags.filter(tag=Tag.objects.filter(id=tag_id))[0]
+ ordered_tags = TaggedSheet.objects.filter(datasheet=Datasheet.objects.filter(id=ds_id)[0]).order_by('order')
+ # We get the current TaggedSheet and its's order
+ #ts = ordered_tags.filter(tag=Tag.objects.filter(id=tag_id))[0]
+ ts = ordered_tags[tag_pos]
tag_order = ts.order
+ # We get the other TaggedSheet that will be moved
if move == "u" :
- next_order = tag_order - 1
+ other_ts = ordered_tags[tag_pos-1]
elif move == "d" :
- next_order = tag_order + 1
+ other_ts = ordered_tags[tag_pos+1]
else :
- next_order = None
- # We get the other TaggedSheet that will be moved
- other_ts = ds_tags.filter(order=next_order)[0]
+ other_ts = None
# We switch the orders
- ts.order = next_order
- other_ts.order = tag_order
- ts.save()
- other_ts.save()
+ if other_ts :
+ ts.order = other_ts.order
+ other_ts.order = tag_order
+ ts.save()
+ other_ts.save()
- return get_tag_table(request=request, ds_id=ds_id, valid=0)
-
+ return GetTagTable(request=request, ds_id=ds_id, valid=0)
#@login_required
-def get_tag_table(request=None, ds_id=None, valid=None):
+def GetTagTable(request=None, ds_id=None, valid=None):
ordered_tags = TaggedSheet.objects.filter(datasheet=Datasheet.objects.filter(id=ds_id)[0]).order_by('order')
@@ -113,4 +115,19 @@
context_instance=RequestContext(request))
+#@login_required
+def RemoveTagFromList(request=None):
+
+ ds_id = request.POST["datasheet_id"]
+ tag_id = request.POST["tag_id"]
+ # First we get the datasheet's TaggedSheets
+ ds_tags = TaggedSheet.objects.filter(datasheet=Datasheet.objects.filter(id=ds_id)[0])
+ # We get the current TaggedSheet and we delete it
+ ts = ds_tags.filter(tag=Tag.objects.filter(id=tag_id))[0]
+ ts.delete()
+ # We decrement the others tags's order
+
+ return GetTagTable(request=request, ds_id=ds_id, valid=0)
+
+