Menu

#2025 iBackofficeDictEntriesExtension + ajax.render.php

3.0.1
closed
None
User Interface
Critical
3.0.0
defect
2022-05-03
2022-02-07
No

I'm trying to adjust my geometry extension so it works with iTop 3.0.

While doing so, I implemented dictionary entries using the iBackofficeDictEntriesExtension.

Now, when for instance I edit a dashboard page and drag and drop any dashlet, I got a whole bunch of JavaScript being displayed instead. I tracked it down: ajax.render.php did not simply return the name of the ID of the dashlet. The response also contained a whole bunch of JavaScript for said dictionary entries extension.

I believe other AjaxPage elements will be affected as well. Since they're ajax, is it expected to have them return the back office dictionary entries? And if so: how to properly add dictionary entries to the frontend without having it happen in these kind of pages?

Discussion

  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-07

    Sorry, version is of course 3.0.0

    This might be desired behavior if AjaxPage is indeed returning HTML; but not in case of JSON data or in this case where just a simple string is expected.

     

    Last edit: Jeffrey Bostoen 2022-02-07
  • Guillaume Lajarige

    Hello Jeffrey,

    It depends, AjaxPage can return either pure data (some endpoints) or HTML + JS (modals, dashboard editor, ...), this is for compatibility reasons.
    JsonPage on the other hand only returns JSON data, this page should be prefered when using data endpoints.
    Are you using your own endpoint or one of iTop's?

    That being said we had an issue with some endpoint using the wrong kind of page, in that case dictionary files where added. It has been fixed in 3.0.1 by Anne-Catherine

    Cheers,
    Guillaume

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-07

    Thanks for the quick feedback!

    The endpoint is currently the native ajax.render.php ; where a request is made to get the new dashlet ID (operation=new_dashlet_id) (which kind of feels like it should return JSON instead of simply a dashlet name in plain text form).

     

    Last edit: Jeffrey Bostoen 2022-02-07
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-09

    I just checked the GitHub repo, I don't believe it's fixed in this case.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-10

    Hello,

    Indeed this endpoint returns HTML (Content-Type: text/html;charset=UTF-8). But in the code it is an AjaxPage that is intanciated ?!?? (see https://github.com/Combodo/iTop/blob/17e8c53236cf1d2171734da524c99312403ba4b1/pages/ajax.render.php#L1056)

    Jeffrey you're saying that when adding some dict entries with a iBackofficeDictEntriesExtension impl, you're getting this endpoint to return also all the dict entries ? Can you share a snippet so we can reproduce ?

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-10
    • status: new --> more-info-needed
    • Version: 2.6.0 --> 3.0.0
     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-10

    Correct. When I use that interface, it results in the endpoint returning not just an ID for the dashlet that I want to add to the overview; but it also returns (in HTML so definitely check the raw output and not just the visible stuff) an entire script.

    But I'd already expect the call to return JSON instead of HTML, which is a strange implementation choice for this entire new_dashlet_id operation)

        /**
        * Class DictEntriesGeometry. Adds common translations to all pages.
        */
        class DictEntriesGeometry implements iBackofficeDictEntriesExtension {
    
            /**
             * @inheritDoc
             */
            public function GetDictEntries(): array {
    
                return [
    
                    // UI (object menu)
                    'UI:CopyAsGeoJSON:NoFeature',
                    'UI:CopyAsGeoJSON:InvalidMapType',
    
                    // Common panels
                    'UI:MapControl:FeaturePanel:Title'
    
                ];
    
            }
    
        }
    
     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-02-16

    Did you manage to replicate this?

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-21

    Hello,
    Sorry for the late answer :/
    I was able to reproduce the behavior really easily ! Many thanks for all the elements

    I filled a new bug : N°4836

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-21
    • status: more-info-needed --> accepted
    • assigned_to: Pierre Goiffon
     
  • Pierre Goiffon

    Pierre Goiffon - 2022-02-21

    Should be fixed in 33ceab86

     
    🎉
    1
  • Anne-Catherine Cognet

    • status: accepted --> closed
     

Log in to post a comment.