Modify

Opened 10 years ago

Closed 10 years ago

#12113 closed defect (fixed)

PATCH: javascript not added to ticket page when using custom theme

Reported by: Cinc Owned by: falkb
Priority: normal Component: SimpleMultiProjectPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

Hi,

we are using a Trac installation with a custom theme which doesn't have a banner at the top. Because of that the javascript file for filtering the milestones can't be added to the ticket pages with the current code.

I created a patch which uses add_script() instead of filtering to add the necessary script:

  • Trac/Plugins/SimpleMultiProject-0.0.4dev-py2.7.egg/simplemultiproject/ticket.py

     
    8888
    8989    def filter_stream(self, req, method, filename, stream, data):
    9090        if filename == "ticket.html":
     91            add_script(req, "simplemultiproject/filter_milestones.js")
    9192            # replace "project" text input (lineedit) for ticket editing with a selection field
    9293            filter = Transformer('//input[@id="field-project"]')
    9394            ticket_data = data['ticket']
    9495
    95             script_filter = Transformer('//div[@id="banner"]')
    96 
    9796            stream = stream | filter.replace(self._projects_field_ticket_input(req, ticket_data))
    98             stream = stream | script_filter.before(self._update_milestones_script(req))
    9997
    10098        return stream
    10199
    102     def _update_milestones_script(self, req):
    103         script = tag.script(type="text/javascript", src=req.href.chrome("simplemultiproject", "filter_milestones.js"))
    104         return script
    105100
    106101    def _add_milestones_maps(self, req, ticket_data):
    107102

Works like a charm over here.

Regards Cinc

Attachments (1)

SimpleMultiProject_ticket.diff (1.4 KB) - added by Cinc 10 years ago.
Patch for using add_script() when adding javascript to ticket page

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by Cinc

Patch for using add_script() when adding javascript to ticket page

comment:1 Changed 10 years ago by falkb

Thank you! I've applied the patch to the local system here without seeing any problems. Gonna test it on another system soon... stay tuned!

comment:2 Changed 10 years ago by falkb

Status: newaccepted

comment:3 Changed 10 years ago by falkb

Resolution: fixed
Status: acceptedclosed

In 14335:

, fixes #11573:
Thanks and kudos to Cinc for 2 nice patches!:

  • better support of custom themes (fixes #12113)
  • with [ticket-custom] option project = select , custom queries show project list as drop-down now
  • additionally: show version drop-down in ticket-change form as ordered list now

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain falkb.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.