summaryrefslogtreecommitdiff
path: root/pgcommitfest/commitfest/templates/base_form.html
blob: 91f2e91e6bb22af2359df9b143420ddf783464a5 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{%extends "base.html"%}
{%load commitfest%}

{%block contents%}
<form class="form-horizontal {{extraformclass}}" method="POST" action=".">{%csrf_token%}
{%if form.errors%}
 <div class="alert">Please correct the errors below, and re-submit the form.</div>
{%endif%}
{%if form.non_field_errors%}
 <div class="alert alert-danger">{{form.non_field_errors}}</div>
{%endif%}
{%if note%}
<div class="alert alert-info">{{note|safe}}</div>
{%endif%}
 {%for field in form%}
 {%if not field.is_hidden%}
 <div class="form-group">
   {{field|label_class:"control-label col-lg-1"}}
   <div class="col-lg-11 controls">
  {%if field.errors %}
   {%for e in field.errors%}
 <div class="alert alert-danger">{{e}}</div>
   {%endfor%}
  {%endif%}
{%if not field.name in form.selectize_multiple_fields%}{{field|field_class:"form-control"}}{%else%}{{field}}{%endif%}
{%if field.help_text%}<br/>{{field.help_text|safe}}{%endif%}</div>
 </div>
 {%else%}
{{field}}
 {%endif%}
{%endfor%}
 <div class="form-group">
  <div class="col-lg-12">
   <div class="control"><input type="submit" class="btn btn-default" value="{{savebutton|default:"Save"}}"></div>
  </div>
 </div>
</form>

{%if threadbrowse %}
{%include "thread_attach.inc" %}
{%endif%}

{%if user.is_staff%}
<div class="modal fade" id="searchUserModal" role="dialog">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	<h3>Search user</h3>
      </div>
      <div class="modal-body">
	<form class="form-inline" style="margin-bottom: 5px;">
	  <div class="input-append">
	    <input id="searchUserSearchField" type="text" class="span2 search-query" autocomplete="off">
	    <button id="searchUserSearchButton" onclick="return findUsers()" class="btn btn-default">Search</button>
	  </div>
	</form>
	<div>Search for users above and then pick one in the list below:</div>
	<div id="searchUserListWrap">
	  <select id="searchUserList" size="6" style="width:100%;" onchange="searchUserListChanged()"></select>
	</div>
      </div>
      <div class="modal-footer">
	<a href="#" class="btn btn-default" data-dismiss="modal">Close</a>
	<a href="#" id="doSelectUserButton" class="btn btn-default btn-primary disabled">Add user to system</a>
      </div>
    </div>
  </div>
</div>
{%endif%}
{%endblock%}

{%block extrahead%}
<link rel="stylesheet" href="/https/git.postgresql.org/media/commitfest/css/selectize.css" />
<link rel="stylesheet" href="/https/git.postgresql.org/media/commitfest/css/selectize.default.css" />
{%endblock%}
{%block morescript%}
<script src="/https/git.postgresql.org/media/commitfest/js/selectize.min.js"></script>
<script>
/* Set up selectize fields */
{% for f, url in selectize_multiple_fields %}
   $('#id_{{f}}').selectize({
      plugins: ['remove_button'],
      valueField: 'id',
      labelField: 'value',
      searchField: 'value',
      load: function(query, callback) {
         if (!query.length) return callback();
         $.ajax({
            'url': '{{url}}',
            'type': 'GET',
            'dataType': 'json',
            'data': {
               'query': query,
            },
            'error': function() { callback();},
            'success': function(res) { callback(res.values);},
         });
      }
   });
{%endfor%}
{%if user.is_staff%}
   $('.selectize-control').after(
      $('<a href="#" class="btn btn-default btn-sm">Import user not listed</a>').click(function () {
          search_and_store_user();
      })
   );

$('#searchUserModal').on('shown.bs.modal', function() {
	  $('#searchUserSearchField').focus();
});
{%endif%}

/* Build our button callbacks */
$(document).ready(function() {
   $('button.attachThreadButton').each(function (i,o) {
      var b = $(o);
      b.click(function() {
	 $('#attachThreadAttachOnly').val('1');
         browseThreads(function(msgid) {
            b.prev().val(msgid);
            return true;
         });
         return false;
      });
   });
});
</script>
{%endblock%}