Closed Bug 566331 Opened 14 years ago Closed 10 years ago

Move JS code out of bug/edit.html.tmpl

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 5.0

People

(Reporter: LpSolit, Assigned: ishitva.goel)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

There is ~100 lines of JavaScript in bug/edit.html.tmpl. This code is pretty hard to read with all the english strings and TT code in it, and probably makes the life pretty difficult to localizers. This JS code should go somewhere into js/*.js, and relevant data passed to it (strings + bug data). Probably not an easy task.
Thanks to bug 653634, most of the JS functions defined in this template are gone. This leaves us with adjustRemainingTime() and updateRemainingTime() which could be moved into js/field.js, which is already loaded.
Depends on: 653634
Whiteboard: [Good Intro Bug]
Assignee: create-and-change → ishitva.goel
Status: NEW → ASSIGNED
Target Milestone: --- → Bugzilla 5.0
Attached patch patch13d.diff (obsolete) — Splinter Review
This patch removes the JS functions adjustRemainingTime() and updateRemainingTime() from bug/edit.html.tmpl and places them into js/field.js .
Also the variable name " fRemainingTime " is now changed to " bz_remaining_time " .
Attachment #8385139 - Flags: review?(dkl)
Comment on attachment 8385139 [details] [diff] [review]
patch13d.diff

>=== modified file 'js/field.js'

>+var bz_remaining_time;
>+function adjustRemainingTime(bz_remaining_time_arg) {
>+    bz_remaining_time = bz_remaining_time_arg;

This won't work. bz_remaining_time_arg is going to override bz_remaining_time. This function takes no argument.


>+    var new_time;
>+    // prevent negative values if work_time > remainingTime
>+    new_time =

You can merge these lines into one: var new_time = ...


>+}
>\ No newline at end of file

Please add a newline at the end of the file.



>=== modified file 'template/en/default/bug/edit.html.tmpl'

>+  adjustRemainingTime([% bug.remaining_time %]);
>+  updateRemainingTime();

That's not the right time to call these functions. They are called later, triggered by onchange. You must also define bz_remaining_time here.
Attachment #8385139 - Flags: review?(dkl) → review-
Attached patch patch13e.diffSplinter Review
The patch fixes the issues mentioned in the comment 3 .
Attachment #8385245 - Flags: review?(dkl)
Attachment #8385139 - Attachment is obsolete: true
Comment on attachment 8385245 [details] [diff] [review]
patch13e.diff

>=== modified file 'js/field.js'

>+    // prevent negative values if work_time > remainingTime

s/remainingTime/bz_remaining_time/


>+    document.changeform.remaining_time.value =
>+        Math.round(new_time * 100)/100;

Nit: this could be written on a single line.


Works fine. r=LpSolit with these fixes on checkin.
Attachment #8385245 - Flags: review?(dkl) → review+
Flags: approval?
Whiteboard: [Good Intro Bug]
Flags: approval? → approval+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified js/field.js
modified template/en/default/bug/edit.html.tmpl
Committed revision 8955.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: