jan-vince / smallgdpr

OctoberCMS plugin to cope with GDPR
MIT License
9 stars 9 forks source link

Managing cookies, choices not saved or updated? #14

Closed egerstudio closed 2 years ago

egerstudio commented 3 years ago

I'm having an issue over several different installations where the manage cookies form, and the modal for that matter, does not update the checkbox choices properly.

Enter the modal or page with manage cookie component and changing what cookies to allow, then when saving, if one of the optional cookie checkboxes are unchecked, it reverts back to checked when saved.

I have an example of it (albeit in Norwegian, but I think you can get the drift anyway) at this link. It's not possible to deselect the optional cookie on this page and save it, it always reverts back.

What am I doing wrong?

jan-vince commented 3 years ago

Can you please check your layout, page and maybe partials used to render /gdpr page if there are not two same components for cookiesManage?

I can see two identical <script> blocks in the end of the /gdpr page.

egerstudio commented 3 years ago

Thanks for responding so quickly :)

This is my layout file

description = "KvammeUrnes statisk smal"

[staticBreadcrumbs]

[staticMenu]

[staticPage]
useContent = 1
default = 0

[cookiesBar]
==
<!doctype html>
<html lang="en">

    {% partial 'header/head' %}

    <body>

        {% partial 'nav/navigation' %}

        <!-- Innhold -->
        <div class="container">
            <div class="row py-5 mt-5">
                <div class="col-10 offset-1 col-lg-8 offset-lg-2 ">
                    {% component 'staticPage' %}
                </div>
            </div>
        </div>

        {% partial 'footer/footer' %}

        {% component 'cookiesBar' %}

        {% partial 'scripts/scripts' %}

    </body>
</html>

The component cookiesBar is called, but cookiesManage is called from a snippet inside the staticPage component.

This is the static page code

[viewBag]
title = "Informasjonskapsler"
url = "/gdpr"
layout = "page-static-narrow"
is_hidden = 0
navigation_hidden = 1
==
<figure data-component="\JanVince\SmallGDPR\Components\CookiesManage" data-snippet="cookiesManage">&nbsp;</figure>

The funny thing is that when I remove this from components/cookiesmanage/default.htm, the source code still somehow inserts the script on the page. And it still does not work when saving. I just don't get what I'm doing wrong, though it's probably something blatantly obvious ;)

{% put scripts %}

    <script>

        $('#cookies-manage-save').click(function() {

            {% partial '@set-cookies' setOnlyManageCookies = true %}

            {% if cookiesSettingsGet('cookies_manage_disable_page_reload', 0) == 0 %}

                location.reload(true);

            {% endif %}

        });

    </script>

{% endput %}
jan-vince commented 3 years ago

Try to add cookiesManage component in your layout and see if it will work.

I can have a bug in snippet code.

And I usually render static page with {% page %} not with {% component 'staticPage' %} so this can also be a cause of a problem.

The double script is my bug - I will have to fix this. But on my sites it works even with double Githubissues.

  • Githubissues is a development platform for aggregating issues.