summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/template/en/default/pages/attachment_bounty_form.html.tmpl
blob: ffbb1acbcc216d639d6e503aa5be71ae23a168b5 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]
[% PROCESS global/variables.none.tmpl %]

[% inline_style = BLOCK %]
#bounty_form {
  padding: 10px;
}
#bounty_form .required:after {
  content: " *";
  color: red;
}
#bounty_form .field_label {
  font-weight: bold;
  display: block;
  text-align: left;
}
#bounty_form .field_desc {
  padding-bottom: 3px;
}
#bounty_form .field_desc,
#bounty_form .head_desc {
  width: 600px;
  word-wrap: normal;
}
#bounty_form .head_desc {
  padding-top: 5px;
  padding-bottom: 12px;
}
#bounty_form .form_section {
  margin-bottom: 10px;
}
#bounty_form textarea {
  font-family: inherit;
  font-size: inherit;
}
#bounty_form em {
  font-size: 1em;
}
.yui-calcontainer {
  z-index: 2;
}
[% END %]

[% inline_javascript = BLOCK %]
var validateDate = /^(\d{4}-\d{2}-\d{2}|)$/;
var validators = {
  reporter_email: /^[^,]+$/,
  amount_paid:    /^[0-9]*[-+?]?$/,
  reported_date:  validateDate,
  fixed_date:     validateDate,
  awarded_date:   validateDate,
  publish:        /^(0|1)$/,
  credit_1:       /^([^,]+|)$/,
  credit_2:       /^([^,]+|)$/,
  credit_3:       /^([^,]+|)$/
};

function validateAndSubmit() {
  'use strict';
  var alert_text = '';
  var requiredLabels = YAHOO.util.Selector.query('label.required');
  var skip = {};

  if (requiredLabels) {
    requiredLabels.forEach(function (label) {
      var name = label.getAttribute('for');
      var ids = YAHOO.util.Selector.query(
        '#bounty_form *[name="' + name + '"]'
      ).map(function (e) {
        return e.id
      });

      if (ids && ids[0]) {
        var id = ids[0];
        var desc = label.textContent || name;
        if (!isFilledOut(id)) {
          alert_text +=
            "Please enter a value for " +
            desc.replace(/[\r\n]+/, "").replace(/\s+/g, " ") +
            "\n";
          skip[id] = true;
        }
      }
    });
    for (var id in validators) {
      if (skip[id]) continue;
      var el = document.getElementById(id);
      if (validators[id] && !validators[id].test( el.value )) {
        var labels = YAHOO.util.Selector.query('label[for="' + id + '"]');
        var desc;
        if (labels && labels[0]) {
          desc = labels[0].textContent;
        }
        else {
          desc = id;
        }
        alert_text +=
          "Invalid value for " +
          desc.replace(/[\r\n]+/, "").replace(/\s+/g, " ") +
          "\n";
      }
    }

  }

  if (alert_text != '') {
    alert(alert_text);
    return false;
  }
  return true;
}
[% END %]

[% PROCESS global/header.html.tmpl
   title = "Bounty Attachment Form"
   generate_api_token = 1
   style = inline_style
   javascript = inline_javascript
   javascript_urls = [ 'extensions/BMO/web/js/form_validate.js',
                       'js/field.js', 'js/util.js' ]
%]

[% USE Bugzilla %]
[% cgi = Bugzilla.cgi %]

<form id="bounty_form" method="post" action="page.cgi"
  enctype="multipart/form-data" onSubmit="return validateAndSubmit();">

  <input type="hidden" name="bug_id" value="[% bug.id FILTER html %]">
  <input type="hidden" name="id" value="attachment_bounty_form.html">
  <input type="hidden" name="token" value="[% form.token FILTER html %]">
  <input type="hidden" name="submit" value="1">

  <div class="head_desc">
    Bounty Attachment for [% "$terms.Bug $bug.id" FILTER bug_link(bug.id) FILTER none %]
  </div>

  <div class="form_section">
    <label for="reporter_email" class="field_label required">Reporter's Email</label>
    <input type="text" name="reporter_email" id="reporter_email" size="80"
      value="[% form.reporter_email FILTER html %]">
  </div>

  <div class="form_section">
    <label for="amount_paid" class="field_label">Amount Paid</label>
    <input type="text" name="amount_paid" id="amount_paid" size="80" value="[% form.amount_paid FILTER html %]">
  </div>

  <div class="form_section">
    <label for="reported_date" class="field_label">Reported Date</label>
    <input name="reported_date" size="20" id="reported_date" value="[% form.reported_date FILTER html %]"
      onchange="updateCalendarFromField(this)">
    <button type="button" class="calendar_button"
      id="button_calendar_reported_date"
      onclick="showCalendar('reported_date')">
      <span>Calendar</span>
    </button>
    <div id="con_calendar_reported_date"></div>
    <script type="text/javascript">
      createCalendar('reported_date')
    </script>
  </div>

  <div class="form_section">
    <label for="fixed_date" class="field_label">Fixed Date</label>
    <input name="fixed_date" size="20" id="fixed_date" value="[% form.fixed_date FILTER html %]"
      onchange="updateCalendarFromField(this)">
    <button type="button" class="calendar_button"
      id="button_calendar_fixed_date"
      onclick="showCalendar('fixed_date')">
      <span>Calendar</span>
    </button>
    <div id="con_calendar_fixed_date"></div>
    <script type="text/javascript">
      createCalendar('fixed_date')
    </script>
  </div>

  <div class="form_section">
    <label for="awarded_date" class="field_label">Awarded Date</label>
    <input name="awarded_date" size="20" id="awarded_date" value="[% form.awarded_date FILTER html %]"
      onchange="updateCalendarFromField(this)">
    <button type="button" class="calendar_button"
      id="button_calendar_awarded_date"
      onclick="showCalendar('awarded_date')">
      <span>Calendar</span>
    </button>
    <div id="con_calendar_awarded_date"></div>
    <script type="text/javascript">
      createCalendar('awarded_date')
    </script>
  </div>

  <div class="form_section">
    <label for="publish" class="field_label">Publish</label>
    <select name="publish" id="publish">
        <option value="1"[% IF form.publish %]selected[% END %]>Yes</option>
        <option value="0"[% UNLESS form.publish %]selected[% END %]>No</option>
    </select>
  </div>

  <div class="form_section">
    <label for="credit_1" class="field_label">Credit</label>
    <input type="text" name="credit_1" id="credit_1" size="80" value="[% form.credit.0 FILTER html %]">
  </div>

  <div class="form_section">
    <label for="credit_2" class="field_label">Credit</label>
    <input type="text" name="credit_2" id="credit_2" size="80" value="[% form.credit.1 FILTER html %]">
  </div>

  <div class="form_section">
    <label for="credit_3" class="field_label">Credit</label>
    <input type="text" name="credit_3" id="credit_3" size="80" value="[% form.credit.2 FILTER html %]">
  </div>

  <input type="submit" id="commit" value="Submit">

  <p>
    [ <span class="required_star">*</span> <span class="required_explanation">
      Required Field</span> ]
  </p>
</form>

[% PROCESS global/footer.html.tmpl %]