summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/BugModal/web/new_bug.css9
-rw-r--r--extensions/BugModal/web/new_bug.js16
-rw-r--r--new_bug.cgi30
-rw-r--r--template/en/default/bug/new_bug.html.tmpl12
4 files changed, 63 insertions, 4 deletions
diff --git a/extensions/BugModal/web/new_bug.css b/extensions/BugModal/web/new_bug.css
index a96083d81..8a161bb9a 100644
--- a/extensions/BugModal/web/new_bug.css
+++ b/extensions/BugModal/web/new_bug.css
@@ -10,6 +10,10 @@
padding: 8px;
}
+#reset {
+ padding: 1.5px 8px;
+}
+
.new-bug-container {
display: flex;
display: -webkit-flex;
@@ -41,6 +45,7 @@
flex: 6 1 30px;
margin:5px;
}
-input, label {
- display: block; !important
+
+.file-container {
+ padding: 8px;
}
diff --git a/extensions/BugModal/web/new_bug.js b/extensions/BugModal/web/new_bug.js
index 9da5abce9..32dbe4783 100644
--- a/extensions/BugModal/web/new_bug.js
+++ b/extensions/BugModal/web/new_bug.js
@@ -105,5 +105,21 @@ $(document).ready(function() {
this.form.submit()
}
});
+
+ $('#data').on("change", function () {
+ if (!$('#data').val()) {
+ return
+ } else {
+ document.getElementById('reset').style.display = "inline-block";
+ $("#description").prop('required',true);
+ }
+ });
+ $('#reset')
+ .click(function(event) {
+ event.preventDefault();
+ document.getElementById('data').value = "";
+ document.getElementById('reset').style.display = "none";
+ $("#description").prop('required',false);
+ });
});
diff --git a/new_bug.cgi b/new_bug.cgi
index 7f35f9ebc..6a62d0dcb 100644
--- a/new_bug.cgi
+++ b/new_bug.cgi
@@ -45,6 +45,8 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
+my $dbh = Bugzilla->dbh;
+
unless ($user->in_group('new-bug-testers')) {
print $cgi->redirect(correct_urlbase());
@@ -70,6 +72,34 @@ if (lc($cgi->request_method) eq 'post') {
});
delete_token($token);
+ my $data_fh = $cgi->upload('data');
+
+ if ($data_fh) {
+ my $content_type = Bugzilla::Attachment::get_content_type();
+ my $attachment;
+
+ my $error_mode_cache = Bugzilla->error_mode;
+ Bugzilla->error_mode(ERROR_MODE_DIE);
+ my $timestamp = $dbh->selectrow_array(
+ 'SELECT creation_ts FROM bugs WHERE bug_id = ?', undef, $new_bug->bug_id);
+ eval {
+ $attachment = Bugzilla::Attachment->create(
+ {bug => $new_bug,
+ creation_ts => $timestamp,
+ data => $data_fh,
+ description => scalar $cgi->param('description'),
+ filename => $data_fh,
+ ispatch => 0,
+ isprivate => 0,
+ mimetype => $content_type,
+ });
+ };
+ Bugzilla->error_mode($error_mode_cache);
+ unless ($attachment) {
+ $vars->{'message'} = 'attachment_creation_failed';
+ }
+ }
+
my $recipients = { changer => $user };
my $bug_sent = Bugzilla::BugMail::Send($new_bug->bug_id, $recipients);
$bug_sent->{type} = 'created';
diff --git a/template/en/default/bug/new_bug.html.tmpl b/template/en/default/bug/new_bug.html.tmpl
index b1367788d..a8d514142 100644
--- a/template/en/default/bug/new_bug.html.tmpl
+++ b/template/en/default/bug/new_bug.html.tmpl
@@ -18,7 +18,7 @@
[% IF user.id %]
<div style="display: none" id="xhr-error"></div>
- <form name="newbugform" id="newbugform" method="post" action="new_bug.cgi">
+ <form name="newbugform" id="newbugform" method="post" action="new_bug.cgi" enctype="multipart/form-data">
<input type="hidden" value="[% issue_hash_token(['new_bug']) FILTER html %]" name="token">
<div class="new-bug-container">
<div class="new-bug">
@@ -56,7 +56,15 @@
[% INCLUDE bug_modal/common_new_comment.html.tmpl disable_cols=1 %]
[% END %]
[% WRAPPER bug_modal/module.html.tmpl title = "Attach a File" collapsed = 1 %]
- <p>Coming Soon.</p>
+ <div class="file-container">
+ <input type="file" style="display: inline-block;" id="data" name="data" size="50" >
+ <button id="reset" style="display: none;">Reset</button>
+ </div>
+ <label for="description" style="display: inline-block;">Description:</label>
+ <input type="text" id="description" name="description" class="required"
+ size="60" maxlength="200" style="display: inline-block;">
+ <input type="radio" id="autodetect"
+ name="contenttypemethod" value="autodetect" checked="checked" style="display:none">
[% END %]
<button type="submit" id="create-btn" class="create-btn major">Submit</button>
</div>