rich-id/terms-module

View on GitHub
src/Infrastructure/Resources/views/sign/_partial/_body.html.twig

Summary

Maintainability
Test Coverage
<div class="terms-module-sign-content">
    {% if hasSignedTerms(terms, subject) == constant('RichId\\TermsModuleBundle\\Domain\\UseCase\\HasSignedTerms::HAS_SIGNED_OLD_VERSION') %}
        <div class="terms-module-ribon">{{ 'terms_module.sign.new_version'|trans({}, 'terms_module') }}</div>
    {% endif %}

    <div class="terms-module-sign-content-title">{{ lastTermsVersion.title }}</div>
    <div>{{ lastTermsVersion.content|raw }}</div>

    <form id="terms-module-sign-form"
          class="terms-module-center terms-module-sign-actions"
          method="post"
          action="{{ generateSigningRoute(terms, subject) }}"
    >
        <input type="hidden" name="accepted" id="terms-module-sign-accepted">

        <button type="button" class="terms-module-button-secondary terms-module-action terms-module-action-space terms-module-open-loader" onclick="refuseTerms()">{{ 'terms_module.sign.refuse'|trans({}, 'terms_module') }}</button>
        <button type="button" class="terms-module-button-primary terms-module-action terms-module-action-space terms-module-open-loader"  onclick="acceptTerms()">{{ 'terms_module.sign.accept'|trans({}, 'terms_module') }}</button>

        {% block answerLaterBlock%}
            <a class="terms-module-link terms-module-action-space terms-module-open-loader" onclick="ignoreTerms()">{{ 'terms_module.sign.prefer_answer_later'|trans({}, 'terms_module') }}</a>
        {% endblock %}
    </form>
</div>

<script>
    document.addEventListener("DOMContentLoaded", function () {
        window.refuseTerms = function () {
            document.getElementById('terms-module-sign-accepted').value = 0;
            document.getElementById('terms-module-sign-form').submit();
        }

        window.acceptTerms = function () {
            document.getElementById('terms-module-sign-accepted').value = 1;
            document.getElementById('terms-module-sign-form').submit();
        }

        window.ignoreTerms = function () {
            document.getElementById('terms-module-sign-accepted').value = '';
            document.getElementById('terms-module-sign-form').submit();
        }
    });
</script>