Projet

Général

Profil

0001-braine-l-alleud-get-actualities-from-plone-56545.patch

Nicolas Roche, 19 octobre 2021 12:05

Télécharger (5,83 ko)

Voir les différences:

Subject: [PATCH] braine-l-alleud: get actualities from plone (#56545)

 static/braine-l-alleud/config.json            | 18 +++++------
 .../combo/json/actualites.html                | 30 ++++++++-----------
 2 files changed, 20 insertions(+), 28 deletions(-)
static/braine-l-alleud/config.json
33 33
                  "extra-css-classes" : "no-borders",
34 34
                  "label" : "Intertitre avec image",
35 35
                  "template" : "combo/cells/page-intertitle.html"
36 36
               }
37 37
            }
38 38
         },
39 39
         "JSON_CELL_TYPES.update" : {
40 40
            "actualites" : {
41
               "additional-data" : [
42
                  {
43
                     "cache_duration" : 60,
44
                     "key" : "actus",
45
                     "url" : "{{ json.data|get:slug|get:'href' }}"
46
                  }
47
               ],
48 41
               "cache_duration" : 60,
49 42
               "force_async" : false,
50 43
               "form" : [
51 44
                  {
52
                     "label" : "Identifiant du type d’actualités",
45
                     "label" : "Identifiant du connecteur Plone REST API",
46
                     "type" : "string",
47
                     "varname" : "connector"
48
                  },
49
                  {
50
                     "label" : "Identifiant de la requête",
53 51
                     "type" : "string",
54
                     "varname" : "slug"
52
                     "varname" : "query"
55 53
                  }
56 54
               ],
57 55
               "name" : "Actualités",
58
               "url" : "{{ braine_actualites_json_url }}"
56
               "url" : "{{ passerelle_url }}plone-restapi/{{ connector }}/q/{{ query }}/"
59 57
            },
60 58
            "deliberations-communales": {
61 59
               "cache_duration" : 360,
62 60
               "force_async" : false,
63 61
               "name" : "Délibérations communales",
64 62
               "url" : "{{ braine_deliberations_communales_json_url }}"
65 63
            }
66 64
         }
templates/variants/braine-l-alleud/combo/json/actualites.html
1 1
{% load dashboard thumbnail %}
2 2
{% if not in_dashboard %}
3
{% with actualites=json.data|get:slug %}
4 3
<div class="dashboard-settings">
5 4
<div class="dashboard-meta">
6
<h2>{{actualites.label}}</h2>
7
<div>{{actualites.description}}</div>
5
<h2>{{json.meta.label}}</h2>
6
<div>{{json.meta.description}}</div>
8 7
</div>
9 8
<div class="dashboard-switch">
10 9
  {% with tile=cell|as_dashboard_cell:request.user %}
11
  <input type="checkbox" id="actualites-id-{{slug}}"
10
  <input type="checkbox" id="actualites-id-{{connector}}{{query}}"
12 11
      data-add-tile-url="{% url 'combo-dashboard-add-tile' cell_reference=cell.get_reference %}"
13 12
      {% if tile %}
14 13
      checked
15 14
      data-remove-tile-url="{% url 'combo-dashboard-remove-tile' cell_reference=tile.cell.get_reference %}"
16 15
      {% endif %}
17 16
    >
18 17
  {% endwith %}
19 18
  <script>
20
  $('#actualites-id-{{slug}}').on('change', function() {
19
  $('#actualites-id-{{connector}}{{query}}').on('change', function() {
21 20
    if ($(this).is(':checked')) {
22 21
      var $checkbox = $(this);
23 22
      $.ajax({
24 23
        url: $(this).data('add-tile-url'),
25 24
        success: function(data) {
26 25
          $checkbox.data('remove-tile-url', data.cell_data.remove_url);
27 26
          $('h1#logo').addClass('dashboard-change').on('animationend', function() { $('h1#logo').removeClass('dashboard-change')});
28 27
        }
......
32 31
        url: $(this).data('remove-tile-url'),
33 32
        success: function(data) {}
34 33
      });
35 34
    }
36 35
  });
37 36
  </script>
38 37
</div>
39 38
</div>
40
{% endwith %}
41 39
{% else %}
42
{% with actualites=json.data|get:slug %}
43
{% if actus.data %}
44
<button hidden class="newsitem-category" data-slug="{{ slug }}">{{actualites.label}}</button>
45
{% endif %}
46
{% for actu in actus.data %}
47
<div class="newsitem" data-slug="{{ slug }}" data-date="{{ actu.date }}">
48
{% thumbnail actu.image "160x160" crop="50% 25%" as im %}
40
<button hidden class="newsitem-category" data-slug="{{connector}}-{{query}}">{{json.meta.label}}</button>
41
{% for actu in json.data %}
42
<div class="newsitem" data-slug="{{connector}}-{{query}}" data-date="{{ actu.created }}">
43
{% thumbnail actu.image.download "160x160" crop="50% 25%" as im %}
49 44
<img src="{{ im.url }}" alt="" />
50 45
{% endthumbnail %}
51 46
<div>
52
<h3><a href="{{actu.href}}">{{actu.title}}</a></h3>
53
<h4>{{actualites.label}} - {{ actu.date|parse_date|date:"d/m/Y" }}</h4>
54
<p>{{actu.description}}</p>
47
<h3><a href="{{actu.PLONE_id}}">{{actu.title}}</a></h3>
48
<h4>{{json.meta.label}} - {{ actu.created|slice:19|parse_date|date:"d/m/Y" }}</h4>
49
<p>{{actu.description|truncatechars:200|safe|escape}}</p>
55 50
</div>
56 51
</div>
57 52
{% endfor %}
58
{% if actus.data %}
53
{% if json.data %}
59 54
<script>
60 55
jQuery.fn.order = function(asc, fn) { // via https://jsfiddle.net/mindplay/H2mrp/
61 56
    fn = fn || function (el) {
62 57
        return $(el).text().replace(/^\s+|\s+$/g, '');
63 58
    };
64 59
    var T = asc !== false ? 1 : -1,
65 60
        F = asc !== false ? -1 : 1;
66 61
    this.sort(function (a, b) {
......
81 76
  $newsitems.appendTo($('.dashboard-cell > div'));
82 77
}
83 78
$('.newsitem').detach().appendTo($newsitems);
84 79
$('.newsitem-category').detach().attr('hidden', null).appendTo($newsitems.find('.categories'));
85 80
$('.newsitem-category').order(true);
86 81
$('.newsitem').order(false, function(el) { return $(el).data('date'); });
87 82
</script>
88 83
{% endif %}
89
{% endwith %}
90 84
{% endif %}
91
-