/
paper_reviewing_questions.html
106 lines (95 loc) · 4.19 KB
/
paper_reviewing_questions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{% from 'message_box.html' import message_box %}
{% from '_sortable_list.html' import sortable_list %}
<div class="manage-paper-reviewing-questions">
<div class="toolbar space-after hide-if-locked">
<a class="i-button arrow icon-plus highlight" data-toggle="dropdown">
{%- trans %}Add new question{% endtrans -%}
</a>
<ul class="dropdown">
{% for name, field_type in field_types.iteritems() %}
<li>
<a data-ajax-dialog class="js-action-button"
data-href="{{ url_for('.create_reviewing_question', event, review_type=review_type, field_type=name) }}"
data-title="{% trans %}Add custom reviewing question{% endtrans %}">
{% trans name=field_type.friendly_name %}
{{ name }}
{% endtrans %}
</a>
</li>
{% endfor %}
</ul>
</div>
{% if questions %}
{% call(question) sortable_list(questions, id="reviewing-questions-list", classes='tiles disable-if-locked') %}
<a class="icon-edit js-action-button hide-if-locked"
data-title="{% trans %}Edit custom field{% endtrans %}"
data-href="{{ url_for('.edit_reviewing_question', event, review_type=review_type, question_id=question.id) }}"
data-title="{% trans %}Edit the reviewing question{% endtrans %}"
data-ajax-dialog>
</a>
<a class="js-delete-reviewing-question icon-remove hide-if-locked"
data-title="{% trans %}Confirm deletion{% endtrans %}"
data-href="{{ url_for('.delete_reviewing_question', event, review_type=review_type, question_id=question.id) }}"
data-method="DELETE"
data-title="{% trans %}Confirm deletion{% endtrans %}"
data-confirm="{% trans %}Are you sure you want to delete the reviewing question?{% endtrans %}"
data-ajax-dialog>
</a>
{% endcall %}
{% else %}
{%- call message_box('info') %}
{% if review_type == 'layout' %}
{%- trans %}There are no custom layout reviewing questions yet.{% endtrans %}
{% else %}
{%- trans %}There are no custom content reviewing questions yet.{% endtrans %}
{% endif %}
{%- endcall %}
{% endif %}
<div class="toolbar space-before f-j-end">
<button class="i-button big" data-button-back>{% trans %}Close{% endtrans %}</button>
</div>
</div>
<script>
(function() {
'use strict';
var $container = $('.manage-paper-reviewing-questions');
$container.find('.toolbar').dropdown();
$container.on('ajaxDialog:closed', '.js-action-button', function(evt, data) {
if (data) {
$container.trigger('ajaxDialog:reload');
}
});
$container.on('indico:confirmed', '.js-delete-reviewing-question', function(evt) {
evt.preventDefault();
var $this = $(this);
$.ajax({
url: $this.data('href'),
method: $this.data('method'),
complete: IndicoUI.Dialogs.Util.progress(),
error: handleAjaxError,
success: function() {
$container.trigger('ajaxDialog:reload');
}
});
});
var $questionsList = $('#reviewing-questions-list');
setupSortableList($questionsList);
$questionsList.on('sortupdate', function(evt, ui) {
var ids = $questionsList.find('li').map(function(index, item) {
return $(item).data('item-id');
});
ids = $.makeArray(ids);
$.ajax({
url: {{ url_for('.sort_reviewing_questions', event, review_type=review_type)|tojson }},
method: 'POST',
data: {
field_ids: ids
},
error: handleAjaxError,
success: function() {
$container.trigger('ajaxDialog:reload');
}
});
});
})();
</script>