Closed
Bug 388830
Opened 18 years ago
Closed 16 years ago
Use JS to make sure there's a Description value when submitting an attachment
Categories
(Bugzilla :: Attachments & Requests, enhancement, P2)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.6
People
(Reporter: timeless, Assigned: mkanat)
References
()
Details
(Keywords: ue)
Attachments
(1 file, 3 obsolete files)
2.40 KB,
patch
|
dkl
:
review+
|
Details | Diff | Splinter Review |
I just tried to file a bug with an attachment, unfortunately, I got this:
The bug was created successfully, but attachment creation failed. Please add your attachment by clicking the "Create a New Attachment" link below.
oddly, for once in my life, JavaScript was enabled. Bugzilla should onsubmit check the upload field and if it has a value it should complain if there's no description of the attachment.
steps:
try to file a bug with an attachment and request review, but don't include a description.
--
no, i'm not planning to fix this.
![]() |
||
Comment 1•18 years ago
|
||
(In reply to comment #0)
> no, i'm not planning to fix this.
heh
OS: Windows XP → All
Hardware: PC → All
Assignee | ||
Comment 2•18 years ago
|
||
Wow, could that summary have been any more complex?
Priority: -- → P3
Summary: javascript should preflight attachment creation for description at bug submission → Use JS to make sure there's a Description value when submitting an attachment
Assignee: attach-and-request → timeless
Status: NEW → ASSIGNED
Attachment #275503 -
Flags: review?(LpSolit)
![]() |
||
Comment 4•18 years ago
|
||
Comment on attachment 275503 [details] [diff] [review]
plans change
>+function submitVerifier() {
>+ if (attachment_true &&
>+ attachment_true').style.display == 'block' &&
No idea what you mean. You clearly have a syntax problem.
Attachment #275503 -
Flags: review?(LpSolit) → review-
![]() |
||
Comment 7•17 years ago
|
||
timeless, are you still working on it? Otherwise pyrzak could fix this bug himself. If the patch is not invasive, we could take it for 3.2 too.
Target Milestone: --- → Bugzilla 3.4
To fix this issue, you only need to change line 186 of post_bug.cgi from
my $attach_id = Bugzilla::Attachment->insert_attachment_for_bug(!THROW_ERROR,
to
my $attach_id = Bugzilla::Attachment->insert_attachment_for_bug(THROW_ERROR,
to have the error thrown if a description is not entered.
That is how it is coded in Attachment.pm
![]() |
||
Comment 10•17 years ago
|
||
Comment on attachment 342307 [details] [diff] [review]
Throw error if there is no attachment description
No, this change is completely wrong. You don't want to throw an error once the attachment is uploaded.
Attachment #342307 -
Flags: review-
Comment 11•17 years ago
|
||
The error is thrown before the attachment is uploaded.
Unless I am mistaken, the file is not uploaded until after the description is
validated in Bugzilla::Attachment::insert_attachment_for_bug() when
_validate_data() is called.
Using this patch has validate_description return 0 if there is no description.
Assignee | ||
Comment 13•16 years ago
|
||
This was one of the issues that pyrzak's students' research pointed out. It's particularly annoying when you've uploaded a large attachment only to get this error that easily could have been caught with JS before submitting the attachment.
Assignee | ||
Comment 14•16 years ago
|
||
I know that this doesn't handle enter_bug--we have a whole other bug to handle JS form validation on enter_bug.
I also know that this doesn't handle the "File" field, which would have been more complicated to handle and is less of an issue because if there's no file it takes no time to upload it. :-) (However, if you really do want me to validate the File field also, I'll do it.)
Assignee: attach-and-request → mkanat
Attachment #275503 -
Attachment is obsolete: true
Attachment #342307 -
Attachment is obsolete: true
Attachment #375153 -
Flags: review?(guy.pyrzak)
Comment 15•16 years ago
|
||
which other bugs handle enter_bug (i'd like to have it documented on this bug).
Updated•16 years ago
|
Attachment #375153 -
Flags: review?(guy.pyrzak) → review-
Comment 16•16 years ago
|
||
Comment on attachment 375153 [details] [diff] [review]
v1
move the javascript into attachment.js please. I'd prefer for you to validate the file field. But I agree. I doubt users run into that problem often if at all. So if you don't want to bother with that still that's fine.
Comment 17•16 years ago
|
||
Comment on attachment 375153 [details] [diff] [review]
v1
also. You should trim the value before checking it for "" because it also doesn't check for spaces which it will also fail on the server side. YAHOO.lang.trim should be used first.
Assignee | ||
Comment 18•16 years ago
|
||
The enter_bug bug is bug 490767.
Assignee | ||
Comment 19•16 years ago
|
||
This also introduces a very simple method of localizing strings in external files.
Attachment #375153 -
Attachment is obsolete: true
Attachment #395133 -
Flags: review?(guy.pyrzak)
Assignee | ||
Updated•16 years ago
|
Attachment #395133 -
Flags: review?(guy.pyrzak) → review?(dkl)
Comment 20•16 years ago
|
||
Comment on attachment 395133 [details] [diff] [review]
v2
>Index: js/attachment.js
>+function validateAttachmentForm(theform) {
>+ var desc_value = YAHOO.lang.trim(theform.description.value);
>+ if (desc_value == '') {
>+ alert(BUGZILLA.string.attach_desc_required);
>+ return false;
>+ }
>+ return true;
>+}
You could shorten this as:
>+function validateAttachmentForm(theform) {
>+ if (YAHOO.lang.trim(theform.description.value == '') {
>+ alert(BUGZILLA.string.attach_desc_required);
>+ return false;
>+ }
>+ return true;
>+}
but just a nit-pick. I have tested this and works as expected. I like the idea of the BUGZILLA JS object in the header.html.tmpl although I could imagine that getting big over time. But I cannot not think of a better way to embed template toolkit variables into javascript values other than putting them there. You could maybe create a new template template/en/default/global/js-variables.none.tmpl and keep them all in there. But that can come later.
r=dkl
Attachment #395133 -
Flags: review?(dkl) → review+
Comment 21•16 years ago
|
||
(In reply to comment #20)
> >+function validateAttachmentForm(theform) {
> >+ if (YAHOO.lang.trim(theform.description.value == '') {
> >+ alert(BUGZILLA.string.attach_desc_required);
> >+ return false;
> >+ }
> >+ return true;
> >+}
Should have been:
+function validateAttachmentForm(theform) {
+ if (YAHOO.lang.trim(theform.description.value) == '') {
+ alert(BUGZILLA.string.attach_desc_required);
+ return false;
+ }
+ return true;
+}
![]() |
||
Updated•16 years ago
|
Flags: approval+
Target Milestone: Bugzilla 4.0 → Bugzilla 3.6
Updated•16 years ago
|
Flags: blocking3.2.6?
Flags: blocking3.0.10?
![]() |
||
Comment 23•16 years ago
|
||
This is a new feature, not a bug.
Flags: blocking3.2.6?
Flags: blocking3.2.6-
Flags: blocking3.0.10?
Flags: blocking3.0.10-
Updated•16 years ago
|
Flags: blocking3.2.6?
Flags: blocking3.2.6-
Flags: blocking3.0.10?
Flags: blocking3.0.10-
Flags: approval3.4?
![]() |
||
Comment 24•16 years ago
|
||
Don't override blocking flags. We won't take this patch on branches.
Flags: blocking3.2.6?
Flags: blocking3.2.6-
Flags: blocking3.0.10?
Flags: blocking3.0.10-
Flags: approval3.4?
Flags: approval3.4-
Assignee | ||
Comment 25•16 years ago
|
||
Checking in js/attachment.js;
/cvsroot/mozilla/webtools/bugzilla/js/attachment.js,v <-- attachment.js
new revision: 1.7; previous revision: 1.6
done
Checking in template/en/default/attachment/create.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/attachment/create.html.tmpl,v <-- create.html.tmpl
new revision: 1.42; previous revision: 1.41
done
Checking in template/en/default/global/header.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/global/header.html.tmpl,v <-- header.html.tmpl
new revision: 1.64; previous revision: 1.63
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•