Projet

Général

Profil

0001-update-style-of-list-of-links.patch

Frédéric Péters, 15 janvier 2020 10:40

Télécharger (5,9 ko)

Voir les différences:

Subject: [PATCH] update style of list of links

 .../combo/manager/link-list-cell-form.html    | 49 +++++++++++++------
 combo/manager/static/css/combo.manager.css    | 38 ++++++++++++++
 combo/manager/static/js/combo.manager.js      | 15 ------
 combo/manager/views.py                        |  1 +
 4 files changed, 73 insertions(+), 30 deletions(-)
combo/data/templates/combo/manager/link-list-cell-form.html
2 2
{% load i18n %}
3 3

  
4 4
{% block cell-form %}
5
{{ form.as_p }}
5 6
{% with cell.get_items as links %}
6 7
{% if links %}
7
<table class="main">
8
  <tbody class="link-list" data-link-list-order-url="{% url 'combo-manager-link-list-order' page_pk=page.pk cell_reference=cell.get_reference %}">
9
    {% for link in links %}
10
    <tr class="link-item" data-link-item-id="{{ link.pk }}">
11
      <td><span class="handle-link-item">⣿</span> {{ link }}</td>
12
      <td>
13
        <a rel="popup" href="{% url 'combo-manager-page-list-cell-edit-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Edit" %}</a> |
14
        <a rel="popup" href="{% url 'combo-manager-page-list-cell-delete-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Delete" %}</a>
15
      </td>
16
    </tr>
17
    {% endfor %}
18
  </tbody>
19
</table>
8
<p><label>{% trans "Links:" %}</label></p>
9
<div>
10
 <ul class="objects-list list-of-links" id="list-of-links-{{cell.id}}"
11
     data-link-list-order-url="{% url 'combo-manager-link-list-order' page_pk=page.pk cell_reference=cell.get_reference %}">
12
   {% for link in links %}
13
   <li data-link-item-id="{{ link.pk }}"><span class="handle">⣿</span>
14
   <span title="{{link}}">{{ link|truncatechars:100 }}</span>
15
       <a rel="popup" title="{% trans "Edit" %}" class="link-action-icon edit" href="{% url 'combo-manager-page-list-cell-edit-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Edit" %}</a>
16
       <a rel="popup" title="{% trans "Delete" %}" class="link-action-icon delete" href="{% url 'combo-manager-page-list-cell-delete-link' page_pk=page.id cell_reference=cell.get_reference link_cell_reference=link.get_reference %}">{% trans "Delete" %}</a>
17
   </li>
18
   {% endfor %}
19
 </ul>
20
</div>
21
<script>
22
$(function () {
23
  $('#list-of-links-{{cell.id}}').sortable({
24
    handle: '.handle',
25
    update: function(event, ui) {
26
       var new_order = Object();
27
       $(this).find('li').each(function(i, x) {
28
           var suffix = $(x).data('link-item-id');
29
           new_order['pos_' + suffix] = i;
30
       });
31
       console.log('nesw order:', new_order);
32
       $.ajax({
33
           url: $(this).data('link-list-order-url'),
34
           data: new_order
35
       });
36

  
37
    }
38
  });
39
});
40
</script>
20 41
{% endif %}
21 42
{% endwith %}
22 43
<div class="buttons">
......
24 45
  <a rel="popup" href="{% url 'combo-manager-page-list-cell-add-link' page_pk=page.id cell_reference=cell.get_reference link_code=klass.add_as_link_code %}">{{ klass.add_as_link_label }}</a> {% if not forloop.last %}|{% endif %}
25 46
  {% endfor %}
26 47
</div>
27
<br />
28
{{ form.as_p }}
29 48
{% endblock %}
combo/manager/static/css/combo.manager.css
476 476
	text-align: center;
477 477
	padding: 45px 1ex 1ex 1ex;
478 478
}
479

  
480
ul.objects-list.list-of-links li {
481
	padding-left: 0;
482
}
483

  
484
ul.objects-list.list-of-links li a.link-action-icon {
485
	height: 100%;
486
	position: absolute;
487
	right: 0;
488
	top: 0;
489
	width: 3em;
490
	display: block;
491
	overflow: hidden;
492
	text-decoration: none;
493
	border: none;
494
	text-indent: -1000px;
495
	line-height: 3em;
496
}
497

  
498
ul.objects-list.list-of-links li a.link-action-icon::before {
499
	font-family: FontAwesome;
500
	text-indent: 0px;
501
	text-align: center;
502
	display: block;
503
	width: 100%;
504
}
505

  
506
ul.objects-list.list-of-links li a.link-action-icon.delete::before {
507
	content: "\f057"; /* remove-sign */
508
}
509

  
510
ul.objects-list.list-of-links li a.link-action-icon.edit {
511
	right: 3em;
512
}
513

  
514
ul.objects-list.list-of-links li a.link-action-icon.edit::before {
515
	content: "\f044";
516
}
combo/manager/static/js/combo.manager.js
220 220
     return false;
221 221
  });
222 222

  
223
  $('.link-list').sortable({
224
     handle: '.handle-link-item',
225
     stop: function(event, ui) {
226
       var new_order = Object();
227
       $('.link-item').each(function(i, x) {
228
           var suffix = $(x).data('link-item-id');
229
           new_order['pos_' + suffix] = i;
230
       });
231
       $.ajax({
232
           url: $(this).data('link-list-order-url'),
233
           data: new_order
234
       });
235
     }
236
  });
237

  
238 223
  function compute_max_height($cell) {
239 224
    var cell_id = $cell.attr('id');
240 225
    $('style#for-' + cell_id).remove();
combo/manager/views.py
398 398
    def get_context_data(self, **kwargs):
399 399
        context = super(PageEditCellView, self).get_context_data(**kwargs)
400 400
        context['cell'] = self.get_object()
401
        context['page'] = context['cell'].page
401 402
        return context
402 403

  
403 404
    def get_object(self, queryset=None):
404
-