Projet

Général

Profil

0001-templates-add-template-for-FC-information-retrieval-.patch

Voir les différences:

Subject: [PATCH] templates: add template for FC information retrieval (#54003)

 static/img/franceconnect-avatar.svg           | 33 +++++++
 static/includes/_franceconnect-data.scss      | 38 ++++++++
 static/includes/_publik.scss                  |  1 +
 .../select_jsonp--franceconnect-data.html     | 96 +++++++++++++++++++
 4 files changed, 168 insertions(+)
 create mode 100644 static/img/franceconnect-avatar.svg
 create mode 100644 static/includes/_franceconnect-data.scss
 create mode 100644 templates/qommon/forms/widgets/select_jsonp--franceconnect-data.html
static/img/franceconnect-avatar.svg
1
<?xml version="1.0" encoding="UTF-8"?>
2
<svg width="48" height="54" version="1.1" viewBox="0 0 48 54" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
3
 <metadata>
4
  <rdf:RDF>
5
   <cc:Work rdf:about="">
6
    <dc:format>image/svg+xml</dc:format>
7
    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
8
    <dc:title>bouton-fc-standard</dc:title>
9
   </cc:Work>
10
  </rdf:RDF>
11
 </metadata>
12
 <!-- Generator: Sketch 59.1 (86144) - https://sketch.com -->
13
 <title>bouton-fc-standard</title>
14
 <desc>Created with Sketch.</desc>
15
 <g id="Symbole" transform="translate(0 -.66667)" fill="none">
16
  <polygon id="Hexagone" points="0 14.186 0 41.147 23.96 54.667 48 41.147 48 14.186 23.96 0.66667" fill="#fff"/>
17
  <g id="Mosaique" transform="translate(5 5.6667)">
18
   <polygon points="38 32.979 31.722 21.959 24.865 10.109 19 0 19 13.838 19 44" fill="#034ea2"/>
19
   <polygon points="31.722 22 38 11.042 30.317 6.5585 24.865 10.128" fill="#0069cc"/>
20
   <polygon points="30.317 6.5585 19 2.2204e-14 24.865 10.128" fill="#ed1c24"/>
21
   <polygon points="24.865 10.128 19 2.2204e-14" fill="#0069cc"/>
22
   <polygon points="38 33.042 38 11.042 31.722 22" fill="#ed1c24"/>
23
   <polygon points="0 32.979 6.3609 21.959 13.217 10.109 19 0 19 13.838 19 44" fill="#0069cc"/>
24
   <polygon points="6.3609 22 0 11.042 7.6826 6.5585 13.217 10.128" fill="#ed1c24"/>
25
   <polygon points="7.6826 6.5585 19 2.2204e-14 13.217 10.128" fill="#034ea2"/>
26
   <polygon points="-9.2371e-14 33.042 -9.2371e-14 11.042 6.3609 22" fill="#034ea2"/>
27
  </g>
28
  <g id="Marianne" transform="translate(3 16.667)">
29
   <path d="m26.246 13.21c0.33846 0 0.67692-0.085 1.0154 0 0.25385 0.085 0.59231 0.085 0.59231 0.17-0.08461 0.51-0.84615 0.595-1.1846 1.105h-0.16923c-0.16923 0.085-0.08461 0.425-0.25385 0.425-0.16923-0.085-0.33846 0-0.59231 0.085 0.25385 0.255 0.59231 0.425 0.93077 0.34 0.08462 0 0.16923 0.085 0.16923 0.255 0 0 0.08461 0 0.08461-0.085 0.08462 0 0.08462 0 0.08462 0.085v0.255c-0.16923 0.255-0.50769 0.17-0.76154 0.17 0.50769 0.085 1.0154 0.085 1.4385 0 0.33846-0.17 0-0.765 0.25385-1.02-0.08461 0 0-0.17-0.16923-0.17 0.08462-0.085 0.25385-0.34 0.33846-0.34 0.08461 0 0.33846-0.085 0.33846-0.17s-0.25385-0.17-0.16923-0.34c0.33846-0.255 0.67692-0.595 0.50769-1.02-0.08461-0.17-0.59231-0.17-0.84615-0.255-0.33846-0.085-0.67692 0-1.0154 0.085-0.33846 0-0.59231 0.17-0.93077 0.255-0.42308 0.17-0.76154 0.425-1.1846 0.68 0.59231-0.255 1.0154-0.34 1.5231-0.51z" fill="#034ea2"/>
30
   <path d="m32.232 16.77c-0.17054-0.33638-0.42635-0.58866-0.68216-0.92504-0.25581-0.42047-0.59689-0.75685-0.68216-1.2614-0.17054-0.50457 0-0.92504 0-1.4296 0-0.92504-0.25581-1.8501-0.51162-2.691-0.17054-0.42047-0.25581-0.92504-0.42635-1.3455-0.08527-0.25228-0.17054-0.50457-0.34108-0.75685-0.08527-0.084095-0.08527-0.33638 0-0.42047 0.25581-0.16819 0.51162-0.42047 0.68216-0.58866 0.17054-0.33638 0-0.75685-0.25581-0.92504-0.42635-0.16819-0.34108 0.42047-0.68216 0.58866h-0.17054c-0.08527-0.16819 0.08527-0.25228 0.17054-0.33638 0-0.084095 0-0.16819-0.08527-0.16819-0.25581 0-0.51162-0.084095-0.59689-0.16819-0.68216-0.84095-1.5349-1.2614-2.4728-1.5978 0.25581 0.084095 0.51162 0.084095 0.76743 0.084095 0.42635 0.084095 0.93797 0 1.2791-0.16819 0.34108-0.16819 0.34108-0.58866 0.42635-0.92504 0.08527-0.084095 0-0.16819 0-0.33638 0-0.16819-0.17054-0.33638-0.25581-0.50457 0 0-0.08527-0.084095-0.17054-0.25228-0.68216-0.75685-3.3255-2.9433-8.2712-2.6069-2.1318 0.16819-4.7751 0.75685-7.8449 2.2706-0.08527 0-0.17054 0.084095-0.34108 0.084095-0.51162 0.25228-1.1938 0.67276-1.6201 1.1773-0.51162 0.58866-0.93797 1.2614-1.1085 2.0183-0.76743 0.50457-1.2791 1.2614-1.7054 2.0183-0.51162 1.0091-1.1938 1.8501-1.1938 2.9433v0.16819c0.08527 0.33638 0.08527 0.58866 0.17054 0.92504 0.17054 0.67276 0.34108 1.3455 0.42635 2.0183 0.08527 0.33638 0.17054 0.67276 0.25581 1.0091 0.17054 0.33638 0 0.75685 0.25581 1.0932 0.08527 0.16819 0.08527 0.42047 0.34108 0.50457v0.25228c0.08527 0.08409 0.08527 0.08409 0.17054 0.08409v0.25228c0.51162 0.58866 1.1085 1.0932 1.4496 1.766 0.17054 0.33638-0.59689 0.16819-0.93797 0.08409-0.59689-0.25228-1.0232-0.75685-1.5349-1.1773l-0.08527 0.0841c0.25581 0.42047 1.1938 0.92504 0.68216 1.2614-0.25581 0.16819-0.59689-0.16819-0.76743 0.08409-0.08527 0.08409 0 0.25228 0 0.33638-0.34108-0.25228-0.76743-0.084086-1.1085-0.25228-0.25581-0.084094-0.34108-0.50457-0.59689-0.50457-0.76743-0.16819-1.5349-0.33638-2.3876-0.33638h-0.17054c-0.76743-0.08409-1.5349-0.16819-2.217-0.08409v0.84094c0.68216-0.16819 1.3643-0.33638 2.0465-0.33638h0.17054c0.17054 0 0.42635-0.0841 0.59689 0-0.25581 0-0.59689 0-0.8527 0.08409-0.68216 0.084099-1.3643 0.33638-2.0465 0.58867v0.84095c0.34108 0.08409 0.76743 0.08409 1.1085 0.16819 0.42635 0.0841 0.8527 0.16819 1.2791 0.33638 0.59689 0.16819 1.0232 0.42047 1.5349 0.67276 0.25581 0.16819 0.34108 0.33638 0.59689 0.50457 0.34108 0.16819 0.76743 0.16819 1.0232 0h0.34108c0.93797-0.25228 1.8759-0.50457 2.4728-1.2614 0 0.0841 0.08527 0.0841 0.08527 0.0841-0.17054 0.50457-0.17054 1.0091-0.51162 1.5137 0 0.08409-0.08527 0.16819 0.08527 0.25228h0.08527c-0.08527 0-0.08527 0-0.08527 0.08409 0 0.0841 0.17054 0 0.25581 0.0841-0.34108 0.08409-0.59689 0.16819-0.76743 0.42047 0 0.0841 0.08527 0.0841 0.17054 0.0841-0.08527 0.08409-0.34108 0.08409-0.34108 0.16819l0.08527 0.08409c-0.08527 0-0.08527 0-0.08527 0.0841v0.16819c-0.17054 0-0.25581 0.16819-0.34108 0.16819 0.25581 0.16819 0.42635 0 0.68216 0-0.68216 0.25228-1.1938 0.67276-1.8759 0.84095-0.08527 0 0 0.16819-0.08527 0.16819 0.17054 0.08409 0.34108-0.0841 0.51162-0.0841-0.34108 0.25228-0.68216 0.42047-1.0232 0.58866l2.0465 1.1773c0.8527-0.50457 1.6201-1.0932 2.3023-1.8501l0.08527 0.08409c-0.17054 0.58866-0.51162 1.0091-1.0232 1.4296-0.34108 0.16819-0.59689 0.50457-0.8527 0.58866l1.5349 0.84094c0.34108-0.25228 0.59689-0.42047 1.0232-0.58866 0.08527 0 0.17054 0.08409 0.34108 0.08409 0.51162-0.50457 1.1085-1.0932 1.9612-0.92504 0 0.08409 0 0.08409 0.08527 0.08409 0 0 0.08527 0 0.08527-0.08409 0 0.08409 0 0.08409-0.08527 0.08409-0.25581 0.16819-0.42635 0.33638-0.68216 0.50457-0.08527 0.0841 0 0.0841 0.08527 0.0841 0.34108-0.16819 0.51162-0.33638 0.76743-0.50457-0.08527 0.08409-0.08527 0.16819-0.08527 0.25228-0.76743 0.58866-1.3643 1.1773-1.9612 1.8501l8.1007 4.6252c0.25581-0.33638 0.59689-0.84095 0.93797-1.2614 1.5349-2.1865 3.7519-5.1298 4.4341-5.8025 0.25581-0.16819 0.51162-0.16819 0.8527-0.25228 1.0232 0 2.1318 0.25228 3.155 0.33638 0.08527 0 0.25581 0.08409 0.34108 0.08409 0.34108 0.08409 0.76743 0 1.1938-0.08409 0.42635-0.16819 0.93797-0.42047 1.1085-0.92504 0.17054-0.42047 0.25581-0.92504 0-1.3455-0.42635-0.50457 0.34108-0.75685 0.59689-1.0932 0.17054-0.33638-0.17054-0.50457-0.17054-0.75685-0.08527-0.0841-0.34108-0.0841-0.42635-0.25228 0.42635-0.16819 1.1085-0.58866 0.76743-1.0932-0.17054-0.33638-0.51162-0.75685-0.17054-1.0932 0.42635-0.25228 1.1085-0.25228 1.2791-0.67276 0.51162-0.84095-0.25581-1.4296-0.59689-2.0183zm-2.6434-3.0274c-0.08527 0.08409 0.17054 0.16819 0.17054 0.33638-0.08527 0.0841-0.25581 0.16819-0.34108 0.16819-0.08527 0.0841-0.25581 0.25228-0.34108 0.33638 0.08527 0 0 0.16819 0.17054 0.16819-0.25581 0.33638 0.17054 0.92504-0.25581 1.0091-0.42635 0.16819-0.93797 0.16819-1.4496 0 0.25581-0.08409 0.59689 0.08409 0.76743-0.16819v-0.25228c0-0.08409-0.08527-0.08409-0.08527-0.08409l-0.08527 0.08409c0-0.08409-0.17054-0.25228-0.17054-0.25228-0.34108 0.08409-0.68216-0.08409-0.93797-0.33638 0.17054-0.08409 0.34108-0.16819 0.59689-0.08409 0.17054 0 0.08527-0.33638 0.25581-0.42047h0.17054c0.34108-0.50457 1.1085-0.67276 1.1938-1.0932 0-0.08409-0.34108-0.08409-0.59689-0.16819-0.34108-0.08409-0.68216 0-1.0232 0-0.51162 0.16819-0.93797 0.16819-1.3643 0.42047 0.34108-0.25228 0.76743-0.50457 1.1938-0.67276 0.34108-0.08409 0.59689-0.25228 0.93797-0.25228 0.34108-0.08409 0.76743-0.16819 1.0232-0.08409 0.34108 0.08409 0.76743 0.08409 0.8527 0.25228-0.08527 0.50457-0.34108 0.84095-0.68216 1.0932z" fill="#fff"/>
31
  </g>
32
 </g>
33
</svg>
static/includes/_franceconnect-data.scss
1
#rub_service div.template-franceconnect-data {
2
	.franceconnect--button {
3
		display: block;
4
		width: 160px;
5
		background-image: url('../img/franceconnect-avatar.svg');
6
		background-repeat: no-repeat;
7
		background-size: auto 35px;
8
		padding: 5px 2px 5px 40px;;
9
		background-position: 5px center;
10
		font-size: 85%;
11
		cursor: pointer;
12
	}
13

  
14
	div.content {
15
		position: relative;
16
		input {
17
			width: 100%;
18
		}
19
	}
20

  
21
	.franceconnect--clear {
22
		position: absolute;
23
		right: 0;
24
		bottom: 0.5em;
25
		display: none;
26
	}
27

  
28
	.franceconnect--clear::before {
29
		font-family: FontAwesome;
30
		content: "\f057";
31
		color: $link-color;
32
	}
33

  
34
	.franceconnect--error {
35
		color: $error-color;
36
		font-size: 90%;
37
	}
38
}
static/includes/_publik.scss
14 14
@import 'carrousel';
15 15
@import 'back-top';
16 16
@import 'library';
17
@import 'franceconnect-data';
templates/qommon/forms/widgets/select_jsonp--franceconnect-data.html
1
{% extends "qommon/forms/widget.html" %}
2

  
3
{% block widget-error %}
4
{{ block.super }}
5
<span class="franceconnect--error" id="form_{{widget.name}}_error" style="display: none">Une erreur s'est produite lors de la récupération des données.</span>
6
{% endblock %}
7

  
8
{% block widget-control %}
9
<input id="form_{{widget.name}}" type="hidden" name="{{widget.name}}" data-initial-display-value="{{widget.get_display_value|default_if_none:''}}" data-url="{{widget.get_select2_url}}"{% if widget.value %} value="{{ widget.value }}"{% endif %} />
10
<input id="form_{{widget.name}}_display" type="text" name="{{widget.name}}_display" style="display: none" readonly />
11
<a class="franceconnect--clear" id="form_{{widget.name}}_clear" title="Supprimer" role="button" data-field-id="form_{{widget.name}}"></a>
12
<button class="franceconnect--button" id="form_{{widget.name}}_fc_button" data-field-id="form_{{widget.name}}" role="button">Obtenir avec FranceConnect</button>
13

  
14
{% if not request.is_in_backoffice %}
15
<script>
16
$(function () {
17
  const fc_popup = function(url) {
18
       const height = 670;
19
       const width = 1000;
20
       const left = (screen.width/2)-(width/2);
21
       const top = (screen.height/2)-(height/2);
22
       const popup = window.open(url, 'FranceConnect',
23
         'scrollbars=true, width='+width+', height='+height+',top='+top+', left='+left+', resizable=no,copyhistory=no'
24
       );
25
       if (window.focus) popup.focus();
26
       return popup;
27
  };
28

  
29
  const reset_field = function() {
30
      const field_id = '#' + $(this).data('field-id');
31
      $(field_id + '_fc_button').show();
32
      $(field_id).val('');
33
      $(this).hide();
34
      $(field_id + '_display').val('');
35
      $(field_id + '_display').hide();
36
  };
37

  
38
  const fill_field = function(field_id, value, display_value) {
39
      const field_selector = '#' + field_id;
40
      $(field_selector).val(value);
41

  
42
      const $field_display_value = $(field_selector + '_display');
43
      $field_display_value.val(display_value);
44
      $field_display_value.show();
45
      $(field_selector + '_fc_button').hide();
46
      $(field_selector + '_clear').show();
47
  };
48

  
49
  let popup_window = null;
50
  let field_id = null;
51
  const $input = $('div.template-franceconnect-data #form_{{widget.name}}');
52

  
53
  if ($input.val()) {
54
     fill_field($input.attr('id'), $input.val(), $input.data('initial-display-value'));
55
  }
56

  
57
  $('.franceconnect--clear').on('click', reset_field);
58

  
59
  $.getJSON($input.data('url') + '?q=', function (response) {
60
     const init_request_url = response.data[0].init_request_url;
61
     $('.franceconnect--button').on('click', function (event) {
62
         if (popup_window) {
63
           popup_window.close();
64
         }
65
         field_id = $(this).data('field-id');
66
         let popup_url = init_request_url;
67
         const origin = 'origin=' + window.location.href;
68
         if (init_request_url.indexOf('?') != -1) {
69
           popup_url += '&' + origin;
70
         } else {
71
           popup_url += '?' + origin;
72
         }
73
         popup_window = fc_popup(popup_url);
74
         return false;
75
       });
76
  });
77

  
78
  $(window).on('message', function (event) {
79
      if (!event.originalEvent.data.error) {
80
          fill_field(field_id, event.originalEvent.data.id, event.originalEvent.data.text);
81
      } else {
82
          $('#' + field_id + '_error').show();
83
          console.error(event.originalEvent.data.error);
84
          console.error(event.originalEvent.data.data);
85
      }
86
      if (popup_window) {
87
          popup_window.close();
88
      }
89
      popup_window = null;
90
      field_id = null;
91
   });
92
});
93
</script>
94
{% endif %}
95

  
96
{% endblock %}
0
-