Clarification on callbacks

Hello list,
I’m considering trying out a callback. Ken suggested it as a way to add a
link to pages that will let users toggle between self-service and standard
interfaces, and I’m very much hoping I can use it to customize the way
history displays on ticket summary pages.

From what I’ve read so far, it seems like a callback is analogous to a
subclass. If I have a ‘renderer’ class that can make pretty text from raw
HTML, I might then subclass it and override the function that parses text
to make it work on XML. Yes, it’s a very terrible example, but hopefully
the idea is correct.

Anyway, a callback in RT seems a lot like that. I want the ticket page to
display how it already does, but I don’t like the history part. Thus, I
copy the file to the proper callback directory, then modify it. RT will,
when it knows it has to use Display.html, look in callbacks first and use
my version. Only if I don’t provide one will it use the default one in
share/html/Tickets.

Do I have this right–copy the existing file to callbacks and modify it? Or
do I make a blank file, override only the bits I want to in there, and not
copy the whole thing? Am I thinking about callbacks all wrong?

Alex Hall
Automatic Distributors, IT department
ahall@autodist.com

Hey Alex,On Tue, Oct 11, 2016 at 3:27 PM, Alex Hall ahall@autodist.com wrote:

Hello list,
I’m considering trying out a callback. Ken suggested it as a way to add a
link to pages that will let users toggle between self-service and standard
interfaces, and I’m very much hoping I can use it to customize the way
history displays on ticket summary pages.

From what I’ve read so far, it seems like a callback is analogous to a
subclass. If I have a ‘renderer’ class that can make pretty text from raw
HTML, I might then subclass it and override the function that parses text to
make it work on XML. Yes, it’s a very terrible example, but hopefully the
idea is correct.

Anyway, a callback in RT seems a lot like that. I want the ticket page to
display how it already does, but I don’t like the history part. Thus, I copy
the file to the proper callback directory, then modify it. RT will, when it
knows it has to use Display.html, look in callbacks first and use my
version. Only if I don’t provide one will it use the default one in
share/html/Tickets.

Do I have this right–copy the existing file to callbacks and modify it? Or
do I make a blank file, override only the bits I want to in there, and not
copy the whole thing? Am I thinking about callbacks all wrong?

You are thinking about Callbacks wrong. :slight_smile:

They are hook points in the HTML (Mason) of RT.

Many (most?) RT extension will have some callbacks in them. Here is a
nice easy one to get your feet wet:

Take a look at the source for this extension and note the
html/Callbacks directory. Then look in your RT share/html directory
for where those callbacks would appear.

In this particular instance, rt-extension-commentoncreate adds a
“comment” box just below the “create” content box on the
Ticket/Create.html page.

So you can see from the source of the extension, it will add something
to the AfterMessageBox callback in the Create.html Mason component.

I’ll let you dig a little bit more with this extension or another one
to get more familiar with callbacks.

Also, read the documentation:

https://docs.bestpractical.com/rt/4.4.1/writing_extensions.html#Callbacks

-m

Callbacks I get now, at least I’m pretty sure I do. I’ve been reading the
docs for RT objects, and if I can use any of the properties and methods
I’ve found, I can see how plugins are so powerful.

My sticking point now is modifying what’s already there. I can remove items
from a menu with deleteKey, but I haven’t found a way to remove items from
other areas of RT and replace them with my own. My ultimate goal, as I’ve
said, is to redo the ticket history section on ticket summary and history
pages, to make it easier to read and follow. I have an idea of how I’d make
the display I want to see, but how do I also get rid of the default one?
Callbacks let you insert your own functionality at certain points,
but–understandably–they don’t seem as willing to let you get at the
existing structure. If I wanted to get rid of history and put in my own, or
hide the time worked/estimated section entirely, could I do so? If I can,
where is a good place to start reading about how? Thanks!On Tue, Oct 11, 2016 at 4:38 PM, Matt Zagrabelny mzagrabe@d.umn.edu wrote:

Hey Alex,

On Tue, Oct 11, 2016 at 3:27 PM, Alex Hall ahall@autodist.com wrote:

Hello list,
I’m considering trying out a callback. Ken suggested it as a way to add a
link to pages that will let users toggle between self-service and
standard
interfaces, and I’m very much hoping I can use it to customize the way
history displays on ticket summary pages.

From what I’ve read so far, it seems like a callback is analogous to a
subclass. If I have a ‘renderer’ class that can make pretty text from raw
HTML, I might then subclass it and override the function that parses
text to
make it work on XML. Yes, it’s a very terrible example, but hopefully the
idea is correct.

Anyway, a callback in RT seems a lot like that. I want the ticket page to
display how it already does, but I don’t like the history part. Thus, I
copy
the file to the proper callback directory, then modify it. RT will, when
it
knows it has to use Display.html, look in callbacks first and use my
version. Only if I don’t provide one will it use the default one in
share/html/Tickets.

Do I have this right–copy the existing file to callbacks and modify it?
Or
do I make a blank file, override only the bits I want to in there, and
not
copy the whole thing? Am I thinking about callbacks all wrong?

You are thinking about Callbacks wrong. :slight_smile:

They are hook points in the HTML (Mason) of RT.

Many (most?) RT extension will have some callbacks in them. Here is a
nice easy one to get your feet wet:

GitHub - bestpractical/rt-extension-commentoncreate

Take a look at the source for this extension and note the
html/Callbacks directory. Then look in your RT share/html directory
for where those callbacks would appear.

In this particular instance, rt-extension-commentoncreate adds a
“comment” box just below the “create” content box on the
Ticket/Create.html page.

So you can see from the source of the extension, it will add something
to the AfterMessageBox callback in the Create.html Mason component.

I’ll let you dig a little bit more with this extension or another one
to get more familiar with callbacks.

Also, read the documentation:

Writing extensions - RT 4.4.1 Documentation - Best Practical

-m

Alex Hall
Automatic Distributors, IT department
ahall@autodist.com

Callbacks I get now, at least I’m pretty sure I do. I’ve been reading the
docs for RT objects, and if I can use any of the properties and methods I’ve
found, I can see how plugins are so powerful.

My sticking point now is modifying what’s already there. I can remove items
from a menu with deleteKey, but I haven’t found a way to remove items from
other areas of RT and replace them with my own.

You would use local versions of the Mason components. RT doesn’t (at
this point) have that modular or dynamic of an architecture.

It’d be great to have flexibility for users to see what they want in
the layout - it’d probably be a big-ish undertaking to implement it.

My ultimate goal, as I’ve

said, is to redo the ticket history section on ticket summary and history
pages, to make it easier to read and follow. I have an idea of how I’d make
the display I want to see, but how do I also get rid of the default one?

From:

https://docs.bestpractical.com/rt/4.4.1/writing_portlets.html

“Copy /opt/rt4/html/share/SelfService/index.html to
/opt/rt4/local/html/SelfService/index.html”

So if you wanted un-callback-able modifications made to your RT, then
you’d copy, for instance:

/opt/rt4/html/share/Ticket/Display.html

to

/opt/rt4/html/local/Ticket/Display.html

and then hack on the latter.

-m

Callbacks I get now, at least I’m pretty sure I do. I’ve been reading the
docs for RT objects, and if I can use any of the properties and methods I’ve
found, I can see how plugins are so powerful.

My sticking point now is modifying what’s already there. I can remove items
from a menu with deleteKey, but I haven’t found a way to remove items from
other areas of RT and replace them with my own.

You would use local versions of the Mason components. RT doesn’t (at
this point) have that modular or dynamic of an architecture.

I hoped you weren’t going to say that. :slight_smile: I was looking earlier, to find where exactly the download/with headers links and other extras get assembled and inserted. I couldn’t find any of it anywhere. I found ShowHistory and ShowTransaction, but I couldn’t find where the text of replies and other transactions gets turned into what you see on the web UI. I must have missed something obvious, but I can’t see what.

You would use local versions of the Mason components. RT doesn’t (at
this point) have that modular or dynamic of an architecture.

I hoped you weren’t going to say that. :slight_smile: I was looking earlier, to find where exactly the download/with headers links and other extras get assembled and inserted. I couldn’t find any of it anywhere. I found ShowHistory and ShowTransaction, but I couldn’t find where the text of replies and other transactions gets turned into what you see on the web UI. I must have missed something obvious, but I can’t see what.

You could always get (by paying) BPS to make the modifications to
upstream - then you’d get something that is supported for the future
and the community would benefit by getting new functionality.

-m