1.0.1 • Published 6 years ago

freeman.gdpr.informationconsentplugin v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Introduction

Freeman.GDPR.InformationConsent is a lightweight jQuery plugin, to display a simple checkbox which is use to get user consent from an appication, several condition is applied which you can see below on # Implementation Conditions area.

Getting Started

1.Installation process
    NPM:
        npm install freeman.gdpr.InformationConsent --save-dev
2.Software dependencies
    jQuery 3.x:
        Via NPM:   npm install jQuery@latest --save-dev

                    OR

        Via CDN -  Uncompressed: <script
                        src="https://code.jquery.com/jquery-3.3.1.js"
                        integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
                        crossorigin="anonymous"></script>
                    OR

        Via CDN -  Minified: <script
                    src="https://code.jquery.com/jquery-3.3.1.min.js"
                    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                    crossorigin="anonymous"></script>

3.Latest releases
    Current Release: 1.0.0

How to use this plugin:

Step 1: Go to https://freemanco.visualstudio.com/Freeman/_packaging?feed=Freeman.GDPR.Packages&_a=feed
Step 2: Click on Connect to feed. A pop-up is displayed.
Step 3: Choose npm from the list (on the left). Scroll down and click on Generate npm credentials.
Step 4: Copy and paste the token in .npmrc (Windows - C://Users//<username>) on your local machine. Generate 1 token per team
Step 5: Install the plugin and the necessary software dependencies in your application
Step 6: In the entry component,
    import '~/node_modules/freeman.gdpr.InformationConsent/js/jquery.InformationConsent.js';
    declare let $: any;  //If using TypeScript; else use 'var' instead of 'let'

    // To display the plugin in the modal.
    var aa = $( "selectorName" ).displayUserInitiatedPiiElement("elementId", "appName"); //Pass elementID (to which the plugin should be appended to) and appname 
    
    // Check if the checkbox is checked. If true then enable submit button; else disable submit button
    document.getElementById("gdpr-termsCheckboxId<elementId>").addEventListener("click", function () {
        if(aa.isChecked() == true) {
        $('<your button id>').removeClass("disabled").attr("rel", null);
        $('<your button id>').addClass("btn-primary").attr("rel", null);
        }
        if(aa.isChecked() == false) {
        $('<your button id>').removeClass("btn-primary").attr("rel", null);
        $('<your button id>').addClass("disabled").attr("rel", null);
        }
    });

    // To append the description
    aa.setDataInfo("This is the description given by Plantour");

Helper Methods

    a) isChecked() : you can directly get current value of checkbox with the help of this method.
    b) setDataInfo(<Information/Description>) : You can directly set Freeman Store Data Information in String with the help of this method.

Implementation Conditions:

1) Submit button should disabled if user initiat checkbox is "unchecked".
    a) You can directly get checkbox value via "isChecked()" method.
2) On Click Submit you must send an extra request call to GDPR server to save consent information in GDPR Database.
    Below is the api description that needs to send on click submit from application.

    Request Method: POST.
    Request URL:
            case 'dev':
                privacyAppEnv = 'https://privacyapi-dev.freeman.com/api/audit/adduserinfo';
                break;
            case 'test':
                privacyAppEnv = 'https://privacyapi-test.freeman.com/api/audit/adduserinfo';
                break;
            case 'uat':
                privacyAppEnv = 'https://privacyapi-uat.freeman.com/api/audit/adduserinfo';
                break;
            case 'prod':
                privacyAppEnv = 'https://privacyapi.freeman.com/api/audit/adduserinfo';
                break;

    Request Payload: 
        {
            "Message": "test", // you can mention form name or modal name with some description
            "Application":"ShowPlans",
            "Email":"bob1@foo.com",
            "FirstName": "Bobby",
            "LastName": "Johnson”
        }

Purpose of InformationConsent Plugin:

As a user, If I want to go to an application's website, voluntarily put in my personal info in order to get a demo, additional information about software, and see a notification and requirement to consent before selecting 'submit'.