Modify

Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#12856 closed defect (fixed)

The hierarchy is not shown in the new ticket's component dropdown list

Reported by: GaLaKtIkUs Owned by: falkb
Priority: normal Component: ComponentHierarchyPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description (last modified by Jun Omae)

The component hierarchy is not displayed in the "new ticket" component field as shown in the following screenshot:

A screenshot of the bug

The VirtualMachines component should be a subcomponent of the Software component as set in the Components admin panel:

The components admin panel

My trac configuration is provided below:

My trac config

Attachments (3)

newticket.png (49.9 KB) - added by GaLaKtIkUs 8 years ago.
A screenshot of the bug
components.png (50.7 KB) - added by GaLaKtIkUs 8 years ago.
The components admin panel
aboutrac.png (42.7 KB) - added by GaLaKtIkUs 8 years ago.
My trac config

Download all attachments as: .zip

Change History (29)

Changed 8 years ago by GaLaKtIkUs

Attachment: newticket.png added

A screenshot of the bug

Changed 8 years ago by GaLaKtIkUs

Attachment: components.png added

The components admin panel

Changed 8 years ago by GaLaKtIkUs

Attachment: aboutrac.png added

My trac config

comment:1 Changed 8 years ago by GaLaKtIkUs

Trac Release: 1.0

comment:2 Changed 8 years ago by GaLaKtIkUs

Please correct the Image macro name in the description!

comment:3 Changed 8 years ago by Jun Omae

Description: modified (diff)
Severity: blockernormal

comment:4 in reply to:  description ; Changed 8 years ago by Ryan J Ollos

Replying to mehdiru:

The component hierarchy is not displayed in the "new ticket" component field as shown in the following screenshot:

Does it display correctly after the ticket is created, on the "ticket" page?

comment:5 Changed 8 years ago by falkb

  1. Does it work for you with a very simple example test system, just containing a component "software" with its only child "VirtualMachines"?
  2. Can you debug if browser:componenthierarchyplugin/trunk/componenthierarchy/ticket.py#L31 returns useful data in _ChModel.get_direct_children()?

comment:6 in reply to:  5 ; Changed 8 years ago by GaLaKtIkUs

Replying to falkb: Sorry for the delay. I created a dedicated test environment for the plugin with the following components:

  • comp1
    • comp1.1
  • comp2
  1. Does it work for you with a very simple example test system, just containing a component "software" with its only child "VirtualMachines"?

Doesn't work ((

  1. Can you debug if browser:componenthierarchyplugin/trunk/componenthierarchy/ticket.py#L31 returns useful data in _ChModel.get_direct_children()?

Added the following line just after browser:componenthierarchyplugin/trunk/componenthierarchy/ticket.py#L31 with the following content

self.log.debug('%s has %s', comp.name, comp_children)

Got the following entries in the log file:

2016-08-29 18:55:26,396 Trac[ticket] DEBUG: comp1 has [u'comp1.1']
2016-08-29 18:55:26,398 Trac[ticket] DEBUG: comp1.1 has []
2016-08-29 18:55:26,400 Trac[ticket] DEBUG: comp2 has []

comment:7 in reply to:  4 Changed 8 years ago by GaLaKtIkUs

Replying to rjollos:

Replying to mehdiru:

The component hierarchy is not displayed in the "new ticket" component field as shown in the following screenshot:

Does it display correctly after the ticket is created, on the "ticket" page?

Can you please tell what is the expected result? The created ticket has the same look as ordinary tickets.

Last edited 8 years ago by GaLaKtIkUs (previous) (diff)

comment:8 in reply to:  6 ; Changed 8 years ago by falkb

Replying to mehdiru:

I created a dedicated test environment for the plugin with the following components:

  • comp1
    • comp1.1
  • comp2

Firefox renders this for me:

</th><td class="col1">
                        <select id="field-component" name="field_component"><option class="indention_level_1" value="comp1">comp1</option><option level="2" class="indention_level_2" value="comp1.1">comp1.1</option></select>

What does Firefox render for your combobox? Which browser do you use?

comment:9 in reply to:  8 Changed 8 years ago by GaLaKtIkUs

Replying to falkb:

Replying to mehdiru:

I created a dedicated test environment for the plugin with the following components:

  • comp1
    • comp1.1
  • comp2

Firefox renders this for me:

</th><td class="col1">
                        <select id="field-component" name="field_component"><option class="indention_level_1" value="comp1">comp1</option><option level="2" class="indention_level_2" value="comp1.1">comp1.1</option></select>

What does Firefox render for your combobox? Which browser do you use?

I have the same rendering problem in Chrome and in Firefox. Just forgot to mention it. I got the following rendered (in both firefox and chrome):

<select id="field-component" name="field_component"> <option value="comp1">comp1</option><option value="comp1.1">comp1.1</option><option value="comp2">comp2</option> </select>

comment:10 Changed 8 years ago by anonymous

Somehow JS-function ch_updateComponentOptions() is not working for you, but I think, JavaScript is allwed in your browser, right?

Can you see the tracing in your browsers developer console when you insert console.log("hallo"); to browser:componenthierarchyplugin/trunk/componenthierarchy/htdocs/create_component_hierarchy.js#L45 ?

comment:11 in reply to:  10 Changed 8 years ago by GaLaKtIkUs

Replying to anonymous:

Somehow JS-function ch_updateComponentOptions() is not working for you, but I think, JavaScript is allwed in your browser, right?

Can you see the tracing in your browsers developer console when you insert console.log("hallo"); to browser:componenthierarchyplugin/trunk/componenthierarchy/htdocs/create_component_hierarchy.js#L45 ?

JS is normally working as I know. I use other plugins that use JS. I'll try to follow your instructions. But I'm pretty weak in web debugging. Hope to do it in a few hours.

comment:12 Changed 8 years ago by anonymous

I thought about the call of add_script() in componenthierarchy/ticket.py also, but I cannot imagine why that could fail there... somehow strange. Hoping we can see in your browser console at least the call of jQuery(document).ready(function($) after inserting that console logging... Thanks already for staying tuned!

comment:13 in reply to:  10 Changed 8 years ago by GaLaKtIkUs

Replying to anonymous:

Somehow JS-function ch_updateComponentOptions() is not working for you, but I think, JavaScript is allwed in your browser, right?

Can you see the tracing in your browsers developer console when you insert console.log("hallo"); to browser:componenthierarchyplugin/trunk/componenthierarchy/htdocs/create_component_hierarchy.js#L45 ?

Got only that "hallo" in the console ...

jQuery(document).ready(function($) {
    console.log("hallo");
    $('#field-component').bind("onUpdate", function() {
        ch_updateComponentOptions();
    });
});

comment:14 Changed 8 years ago by falkb

That's good news, means the .js file has loaded. Now try to spread those console.log messages in ch_updateComponentsOptions(), please. I wonder where it fails to get to the adding of the "indention_level" stuff, you know.

comment:15 Changed 8 years ago by GaLaKtIkUs

Hi again. Added some logging:

function ch_updateComponentOptions()
{
    var options = $('#field-component option');
    var handled = [];
    var alle = [];

    options.each(function() {
        var jThis = $(this);
        var opt_text = jThis.text();
        var opt_val  = jThis.val();
        console.log("hallo-10");
        alle.push(opt_val);

        var thisLevel = jThis.attr('level');
        if (!thisLevel) {
            thisLevel = 1;
            jThis.attr('class', 'indention_level_1');
            console.log("hallo-11");
        }
        console.log("hallo-12");
        if ($.inArray(opt_val, handled) == -1 && component_children[opt_val]) {
            thisLevel++;
            console.log("hallo-13");
            var nbsp = "";
            if ($.browser.msie) {
                // The IE does not support css styling for option tags                                                                                     
                for (var i = 1; i < thisLevel; i++) {
                    nbsp = nbsp + "    ";
                }
            }
            console.log("hallo-14");
            $.each(component_children[opt_val].reverse(), function(idx, value) {
                var jChildOpt = $('#field-component option[value="' + value + '"]');
                jChildOpt.attr('level', thisLevel);
                jChildOpt.attr('class', 'indention_level_' + thisLevel);
                if ($.browser.msie) {
                    jChildOpt.text(nbsp + value);
                    console.log("hallo-15");
                }
                jChildOpt.insertAfter(jThis);
                console.log("hallo-16");
            });

            handled.push(opt_val);
            console.log("hallo-17");
        }
    });
}

jQuery(document).ready(function($) {
    console.log("hallo-00");
    $('#field-component').bind("onUpdate", function() {
        ch_updateComponentOptions();
        console.log("hallo-01");
    });
    console.log("hallo-02");
});

In the console I got:

hallo-00
hallo-02

That indicated that the ch_updateComponentOptions() is never being called.

comment:16 Changed 8 years ago by falkb

Hahaha, now it's clear to me. :-) I thought "onUpdate" is a common jQuery function but it's just a custom event we trigger from within the SimpleMultiProjectPlugin (see here and look for $(field_id).trigger("onUpdate");). This means the plugin currently only works for user of the SimpleMultiProjectPlugin. :)

Well, to get it working for all, I think, we could try to call ch_updateComponentOptions() also immediately in this ready-function. Does this work for you?:

--8<---snip---
...
jQuery(document).ready(function($) {
    console.log("hallo-00");
    $('#field-component').bind("onUpdate", function() {
        ch_updateComponentOptions();
        console.log("hallo-01");
    });
+   ch_updateComponentOptions();
    console.log("hallo-02");
});

comment:17 in reply to:  16 ; Changed 8 years ago by GaLaKtIkUs

Replying to falkb:

Hahaha, now it's clear to me. :-) I thought "onUpdate" is a common jQuery function but it's just a custom event we trigger from within the SimpleMultiProjectPlugin (see here and look for $(field_id).trigger("onUpdate");). This means the plugin currently only works for user of the SimpleMultiProjectPlugin. :)

Well, to get it working for all, I think, we could try to call ch_updateComponentOptions() also immediately in this ready-function. Does this work for you?:

--8<---snip---
...
jQuery(document).ready(function($) {
    console.log("hallo-00");
    $('#field-component').bind("onUpdate", function() {
        ch_updateComponentOptions();
        console.log("hallo-01");
    });
+   ch_updateComponentOptions();
    console.log("hallo-02");
});

The patch works. Will later make some additional test to ensure that there are no other problems such as compatibility issues with other plugins I use. I'll let you informed in the next few hours.

comment:18 Changed 8 years ago by falkb

Cool! Yeah, I don't exactly know, if the ready-function is late enough to update the component combobox, though it seems it works this way.

Maybe someone else can help out, and suggest which standard jQuery event can be used to bind to, I mean to be sure that Trac and its plugins are all ready with their things they do in all those other .js scripts on page load...

comment:19 Changed 8 years ago by GaLaKtIkUs

Also it would be cool if the component's hierarchy is shown in the component's name in the ticket and in the report windows after the ticket is created ...

comment:20 in reply to:  19 ; Changed 8 years ago by falkb

Replying to mehdiru:

Also it would be cool if the component's hierarchy is shown in the component's name in the ticket and in the report windows after the ticket is created ...

The question is how it should be displayed and what should happen if its path is very long because of a deep hierarchy...

comment:21 in reply to:  20 ; Changed 8 years ago by GaLaKtIkUs

Replying to falkb:

Replying to mehdiru:

Also it would be cool if the component's hierarchy is shown in the component's name in the ticket and in the report windows after the ticket is created ...

The question is how it should be displayed and what should happen if its path is very long because of a deep hierarchy...

It would be nice if it is displayed as a unix path (comp1/comp1.1). Some option in the trac.ini file would configure how many levels to show up from the component, for example: for the parameter set to 2, the comp0/comp0.0/comp0.0.0/comp0.0.0.0 component's name should display as .../comp0.0.0/comp0.0.0.0 with ... indicating that there are more hierarchy levels up.

comment:22 in reply to:  21 Changed 8 years ago by falkb

Replying to mehdiru:

It would be nice if it is displayed as a unix path (comp1/comp1.1). Some option in the trac.ini file would configure how many levels to show up from the component, for example: for the parameter set to 2, the comp0/comp0.0/comp0.0.0/comp0.0.0.0 component's name should display as .../comp0.0.0/comp0.0.0.0 with ... indicating that there are more hierarchy levels up.

Sounds good, although I can imagine the plugin has to keep it configurable, because some people want backslashes or some people don't want to see the path... Furthermore, the abbreviation and also the appropriate resizing of the combobox is more complex than it seems... But please, create a new ticket for this feature wish, although I don't have time for coding new stuff at present, but who knows, things are changing fast.

comment:23 in reply to:  17 ; Changed 8 years ago by falkb

Replying to mehdiru:

Will later make some additional test to ensure that there are no other problems such as compatibility issues with other plugins I use. I'll let you informed in the next few hours.

Still works? I can't suppose other plugins tweaking the components...

comment:24 in reply to:  23 Changed 8 years ago by GaLaKtIkUs

Replying to falkb:

Replying to mehdiru:

Will later make some additional test to ensure that there are no other problems such as compatibility issues with other plugins I use. I'll let you informed in the next few hours.

Still works? I can't suppose other plugins tweaking the components...

Tomorrow evening I'll report the results. I'm in GMT+3 timezone.

comment:25 Changed 8 years ago by GaLaKtIkUs

Seems to work. Can you please patch the source code?

comment:26 Changed 8 years ago by falkb

Resolution: fixed
Status: newclosed

In 15746:

fixes #12856:

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.