]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/configuration_dynamic_fields.html.twig
Merge branch 'hotfix/1.0.3'
[galette.git] / galette / templates / default / pages / configuration_dynamic_fields.html.twig
1 {% extends 'page.html.twig' %}
2
3 {% block content %}
4 <div class="ui stackable pointing inverted menu">
5 {% for key, form in all_forms %}
6 <a href="{{ url_for('configureDynamicFields', {'form_name': key}) }}" class="item{% if form_name == key %} active{% endif %}" data-tab="{{ key }}">{{ form }}</a>
7 {% endfor %}
8 </div>
9 {% for key, form in all_forms %}
10 <div class="ui{% if form_name == key %} active{% endif %} tab segment" data-tab="{{ key }}">
11 {% if form_name == key %}
12 {% include 'elements/edit_dynamic_fields.html.twig' %}
13 {% endif %}
14 </div>
15 {% endfor %}
16 {% endblock %}
17
18 {% block javascripts %}
19 <script type="text/javascript">
20 $(function() {
21 $('.pointing.menu .item').tab({
22 auto: true,
23 path: '{{ url_for('configureDynamicFields', {'form_name': ''}) }}',
24 onLoad: function(tabPath, parameterArray, historyEvent) {
25 _addDynField();
26 _editDynField();
27 _transDynField();
28 _removeItems();
29 _bindFomanticComponents();
30 }
31 });
32 });
33
34 var _addDynField = function() {
35 var _form_name;
36 $('.addfield').click(function(e){
37 e.preventDefault();
38 var _this = $(this);
39 var _href = _this.attr('href');
40
41 $.ajax({
42 url: _href,
43 type: "GET",
44 datatype: 'json',
45 {% include "elements/js/loader.js.twig" with {
46 selector: '.addfield',
47 loader: 'button'
48 } %},
49 success: function(res){
50 var _res = $(res);
51
52 {% include "elements/js/modal.js.twig" with {
53 modal_title_twig: _T("New dynamic field")|e("js"),
54 modal_content: "_res",
55 modal_class: "tiny",
56 modal_onshow: "_addDynFieldAjaxMapper();",
57 modal_approve_text: _T("Add")|e('js'),
58 modal_approve_icon: "plus",
59 modal_approve_color: "green",
60 modal_cancel_text: _T("Close")|e("js")
61 } %}
62 },
63 error: function() {
64 {% include "elements/js/modal.js.twig" with {
65 modal_title_twig: _T("An error occurred :(")|e("js"),
66 modal_without_content: true,
67 modal_class: "mini",
68 modal_deny_only: true,
69 modal_cancel_text: _T("Close")|e("js"),
70 modal_classname: "redalert",
71 } %}
72 }
73 });
74 });
75 }
76 _addDynField();
77
78 var _addDynFieldAjaxMapper = function(){
79 $('.modal-form .ui.dropdown, .modal-form select:not(.nochosen)').dropdown();
80 $('.modal-form .ui.checkbox, .modal-form .ui.radio.checkbox').checkbox();
81 $('.modal-form a[title], .modal-form .tooltip').popup({
82 variation: 'inverted',
83 inline: false,
84 addTouchEvents: false,
85 });
86 }
87
88 {% set modal_onapprove = "
89 $('.modal-form form #redirect_uri').val(window.location.href);
90 $('.modal-form form').submit();
91 " %}
92
93 var _editDynField = function() {
94 {% include "elements/js/modal_action.js.twig" with {
95 selector: ".single-edit",
96 modal_title_twig: _T("Edit field")|e("js"),
97 modal_class: "tiny",
98 modal_content_class: "scrolling",
99 modal_onapprove: modal_onapprove,
100 modal_action_onshow: "activateHtmlEditor($('#field_information'), true);"
101 } %}
102 }
103 _editDynField();
104
105 {% set extra_success = "
106 $('.modal-form form').on('submit', function(event) {
107 event.preventDefault();
108 var _form = $(this);
109 var _data = _form.serialize();
110 $.ajax({
111 url: _form.attr('action'),
112 type: 'POST',
113 datatype: 'json',
114 data: _data,
115 error: function() {
116 $.modal({
117 title: '%error%',
118 class: 'mini',
119 actions: [{
120 text: '%close%',
121 icon: 'times',
122 class: 'icon labeled cancel'
123 }],
124 className: {
125 modal: 'ui redalert modal',
126 title: 'center aligned header',
127 content: 'center aligned content',
128 actions: 'center aligned actions'
129 }
130 }).modal('show');
131 }
132 });
133 });
134 " %}
135 var _transDynField = function() {
136 {% include "elements/js/modal_action.js.twig" with {
137 selector: ".single-translate",
138 extra_success: extra_success|replace({'%error%': _T("An error occurred :(")|e("js"), '%close%': _T("Close")|e("js")}),
139 modal_title_twig: _T("Translate labels")|e("js"),
140 modal_content_class: "scrolling",
141 modal_onapprove: modal_onapprove
142 } %}
143 }
144 _transDynField();
145 </script>
146 {% endblock %}