Zapisywanie via AJAX.
[redakcja.git] / platforma / templates / manager / pull_request.html
1 {% extends 'base.html' %}
2
3 {% block bodyid %}management{% endblock %}
4
5 {% block extrahead %}
6 <link rel="stylesheet" href="{{ STATIC_URL }}css/managment.css" type="text/css" />
7 <link rel="stylesheet" href="{{ STATIC_URL }}css/pygments.css" type="text/css" />
8 <script type="text/javascript">
9
10     
11     $(function() {
12
13         function refreshRow(id) {
14             var row = $('#request-' +id);
15
16             $.ajax({
17                 url: '{% url pullrequest_list %}/'+id,
18                 dataType: 'json',
19                 type: 'GET',
20                 success: function(data) {
21                     row.removeClass('status-N');
22                     row.removeClass('status-R');
23                     row.removeClass('status-A');
24                     row.addClass('status-'+ data.status);
25
26                     $('.column-doc', row).html(data.document);
27                     $('.column-status', row).html(data.status);
28
29                     alert('Merge accepted.');
30                 }
31             });            
32             
33         }
34         
35         $('.accept-button').click(function()
36         {
37             var id = parseInt($(this).attr('title'));
38
39             $.ajax({
40                 url: '{% url pullrequest_list %}/'+id,
41                 data: {action: 'accept'},
42                 dataType: 'json',
43                 type: 'PUT',
44                 success: function(data) {
45                     refreshRow(id);
46                 }
47             });
48             
49         });
50         
51         $('.show-diff').click(function() {
52             var button = $(this);
53             
54             if (button.attr('disabled') != 'disabled') {
55                 button.attr('disabled', 'disabled');
56                 var id = parseInt(button.attr('title'));
57                 var docid = $('h2', button.parents('.pull-request')).html();
58                 var diffUrl = button.parents('.pull-request').attr('data-diff-url');
59                 var revision = $('.pull-request-revision', button.parents('.pull-request')).html();
60                 
61                 $('.diff').slideUp(function() { $(this).remove() });
62                 $('<div class="diff"></div>')
63                     .hide()
64                     .appendTo($(this).parents('.pull-request'))
65                     .slideDown('slow')
66                     .load(diffUrl + '?revision=' + revision, null, function() {
67                         button.attr('disabled', null);
68                     });
69             }
70         });
71         
72     });
73 </script>
74 {% endblock %}
75
76 {% block maincontent %}
77 {% if objects %}
78     {% for pullreq in objects %}
79     <div class="status-{{ pullreq.status }} pull-request" id="request-{{ pullreq.id }}" data-diff-url="{% url diff_resource pullreq.document %}">
80         <h2>{{ pullreq.document }}</h2>
81         <ul class="request-info">
82             <li>commiter: {{ pullreq.comitter }}</li>
83             <li>revision: <span class="pull-request-revision">{{ pullreq.source_revision }}</span></li>
84             <li>status: {{ pullreq.status }}</li>
85             <li>data: {{ pullreq.timestamp }}</li>
86         </ul>
87         <p class="comment">{{ pullreq.comment }}</p>
88         {% ifnotequal pullreq.status 'A' %}
89         <p class="buttons">
90             <button type="button" class="awesome button green accept-button" title="{{pullreq.id}}">Akceptuj</button>
91             <button type="button" class="awesome button show-diff" title="{{pullreq.id}}">Zmiany</button>
92             <a class="awesome button" href="{% url editor_view pullreq.document %}?user=$prq-{{pullreq.id}}">Zobacz</a>
93         </p>
94         {% endifnotequal %}
95     </div>
96     {% endfor %}
97 {% else %}
98     {# <tr><td colspan="6">Brak żądań</td></tr> #}
99 {% endif %}
100 {# </table> #}
101
102 {% endblock %}