Home Analyst Portal

Default save behaviour changed in latest baseline

Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

Hi (@Justin_Workman @Shane_White )

We have a custom add-on that gives the possibility to open a request in a new tab from gridview: Open workitem in new tab from gridview — Cireson Community

When saving or cancel the request on the new tab it used to close the tab but know it instead redirects to "My work"

Anyone who knows what is changed in latest baseline when closing a request - it seems that the default behaviour has changed?

Best Answer

  • Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
    edited December 2020 Answer ✓

    I checked our history, and the code was added between v9.4.2 and v9.6.0, so it doesn't seem to be related to the PR76704 Shane mentioned, as that was introduced in v9.0.13. For more specfic info, you'll probably need someone at Cireson to pick-axe their commits:

    git log -p -S'history.length == 1' -- Scripts/app/app.lib.js
    


Answers

  • Shane_WhiteShane_White Cireson Support Super IT Monkey ✭✭✭✭✭

    The only thing I can remember along those lines is:

    PR76704Portal redirects to the New Work Item page after creating a new work item

    This fixed an issue where when you were finished it would take you back to the workitem/new page, rather than the page you were on before you open the IR.

    What version did you upgrade from -> to?

    Thanks,

    Shane

  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭
    edited November 2020

    9.4 something -> 10.2.3 (edited 😁)

  • Shane_WhiteShane_White Cireson Support Super IT Monkey ✭✭✭✭✭

    Hmm thats a rather big jump, I will chat with the guys later and have a look at the code, but might be hard to find!

  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

    it's the same in our test system - but there it was only from 10.1 to 10.2.3 (i'm not totally sure if it was the same on 10.1 or first on 10.2.3)

  • Shane_WhiteShane_White Cireson Support Super IT Monkey ✭✭✭✭✭

    No worries, we will have a look either way :-)

  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

    It is in C:\inetpub\CiresonPortal\Scripts\app\app.lib.js - line 1051/1052

    When opening a new tab it always has a history length equal 1

    Can you ask the guys if it has changed recently or it's a browser update that has made the diffence?

    The function (look in the text for SHANE 😁 ):

        this.gotoFormReturnUrl = function () {
    
    
            var windowOpener;
            var homeURL = "/";
    
    
            try {
                //when IR opened from a diff domain it will fail on window.opener.location
                if (window.opener && window.opener.location.host) {
                    windowOpener = window.opener;
                }
            } catch (e) {
                windowOpener = false;
            }
    
    
    
    
            if (windowOpener && (window.opener.location.host === window.location.host) &&
                    history.length < 2 //if they browse away don't close the form, reloads don't add to history count
            ) {
                //we have a window that was opened from another portal window
                //let's first clear out the return URL in the session
                this.removeFormReturnUrl();
    
    
                if (history.length == 1) { // <<<<<<<<<<<<< THIS ONE SHANE!!!!!
                    location.href = homeURL; //handle new tab
                }
                else {
                    //now lets just close ourself
                    window.close();
                }
                
            } else {
                //when return url was empty then redirect to alternate homepage.
                if (history.length > 2) {
                    //do the normal thing
                    if (_.isNull(this.getFormReturnUrl())) {
                        //when previous page is not the login page, go back to document referrer if it isnt empty else to fallback url
                        if (document.referrer.indexOf("/Login") == -1 && document.referrer != "") {
                            location.href = document.referrer;
                        }
                        else {
                            location.href = homeURL;
                        }
                            
                    } else {
                        
                        //there were instances were domain/host name was omitted, so send down the absolute path instead
                        var origin = location.protocol + '//' + location.hostname + (location.port ? (':' + location.port) : '');
                        var absolutePath = origin + this.getFormReturnUrl();
                        if (location.href == absolutePath)
                            history.go(-1);
                        location.href = absolutePath;
                    }
                } else {
                    //alternate homepage redirect.
                    location.href = homeURL;
                }
                return;
            }
    
    
        }
    
    
    
  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

    Any news @Shane_White ? 🙂

  • Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭

    The easy (ie unsupported) way would be to just add a parameter ?newTabOpener to your linkValue and then check for that parameter in app.lib.js 😋

    if(history.length == 1 && !window.location.search.includes("newTabOpener")) { ... }
    


  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

    @Konstantin_Slavin-Bo yes, or just change the event to window.close() 😁

  • Mikkel_MadsenMikkel_Madsen Customer Advanced IT Monkey ✭✭✭

    Any news @Shane_White ?

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @Mikkel_Madsen - I'm not sure if/when this changed, but I have no doubt it was to address some other issue. As you and @Konstantin_Slavin-Bo have pointed out there are custom ways around the "new behavior."

  • Konstantin_Slavin-BoKonstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭
    edited December 2020 Answer ✓

    I checked our history, and the code was added between v9.4.2 and v9.6.0, so it doesn't seem to be related to the PR76704 Shane mentioned, as that was introduced in v9.0.13. For more specfic info, you'll probably need someone at Cireson to pick-axe their commits:

    git log -p -S'history.length == 1' -- Scripts/app/app.lib.js
    


Sign In or Register to comment.