gigascience / gigadb-website

Source code for running GigaDB
http://gigadb.org
GNU General Public License v3.0
9 stars 15 forks source link

table settings not kept on mockup pages #1956

Open only1chunts opened 4 months ago

only1chunts commented 4 months ago

User story

As a user I want to have my prefered table settings maintained when I refresh a mockup page So that I can see the expected things in the table(s)

Acceptance criteria

Given I am on a mockup page (e.g. https://staging.gigadb.org/dataset/view/id/102544/token/vEKNF93Qi945PzNo ) And I'm looking at the Files table When I set the "table settings" to view just 10 rows per page and I click view "next" 10 items in the table Then the page doesn't revert back to showing me >10 rows (in my case it reverted back to all 21 rows, but that maybe dependant on the previous table settings)

Additional Info

It happens when change the table settings to also add additional columns (Format, release date) in addition to the nb of items per page

Product Backlog Item Ready Checklist

Product Backlog Item Done Checklist

luistoptal commented 3 months ago

@rija I see this error also in the dataset view (no mockup), I traced it back to the cookies not being updated, despite the correct arguments passed to the controller in the function protected/components/DatasetPageSettings.php

This is the function that takes care of this

    public function setFileSettings(array $columns, int $pageSize, CMap $cookies): array
    {
        if (isset($cookies['file_setting'])) {
            $cookies['file_setting']->value = json_encode([ "setting" => $columns, "page" => $pageSize]);
        } else {
                $cookie = new CHttpCookie('file_setting', json_encode(array('setting' => $columns, 'page' => $pageSize)));
                $cookie->expire = time() + (60 * 60 * 24 * 30);
                $cookies['file_setting'] = $cookie;
        }
        return [ "columns" => $columns, "pageSize" => $pageSize ];
    }

If I get rid of the conditional and the true branch, the cookie is updated, i.e.:

    public function setFileSettings(array $columns, int $pageSize, CMap $cookies): array
    {
        $cookie = new CHttpCookie('file_setting', json_encode(array('setting' => $columns, 'page' => $pageSize)));
        $cookie->expire = time() + (60 * 60 * 24 * 30);
        $cookies['file_setting'] = $cookie;
        return [ "columns" => $columns, "pageSize" => $pageSize ];
    }

Does this looks like an correct fix? I don't find in the Yii docs a method to update cookies like the one in the true branch

NOTE: I will assume the above is correct and create a PR

luistoptal commented 3 months ago

@only1chunts @rija I see another issue which in principle seems unrelated to this one (happens in develop branch):

Upon refreshing the dataset page, e.g. http://gigadb.gigasciencejournal.com/dataset/view/id/100245 I always see an alert popup "Confirm Form Resubmission":

image