Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CGU popin #16

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dockerfiles/grist/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ RUN apt-get update &&\
apt-get remove --purge -y wget

COPY ressources/* /grist/static/
RUN mv /grist/static/marianne-48x48.png /grist/static/ui-icons/Logo/
RUN mv /grist/static/GristGouvLogo.svg /grist/static/ui-icons/Logo/ &&\
mv /grist/static/favicon.png /grist/static/icons/favicon.png

# Variable to force grist to use custom.css and dinum-custom.js
ENV APP_STATIC_INCLUDE_CUSTOM_CSS true
Expand Down
133 changes: 133 additions & 0 deletions dockerfiles/grist/ressources/GristGouvLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dockerfiles/grist/ressources/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:root {
/* logo */
--icon-GristLogo: url("ui-icons/Logo/marianne-48x48.png") !important;
--icon-GristLogo: url("ui-icons/Logo/GristGouvLogo.svg") !important;
--grist-logo-bg: #ffffff !important;
--grist-logo-size: 22px 22px !important;

Expand Down
58 changes: 55 additions & 3 deletions dockerfiles/grist/ressources/dinum-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
selectedTz: 'CEST',

// Date du début de la maintenance
startDateWithoutTimezone: '2024-04-18T17:30:00',
startDateWithoutTimezone: '2024-04-10T13:00:00',

// Durée de la maitenance prévue (en minutes).
// ASTUCE: Si la maintenance dure moins longtemps que prévu, réduire a postériori la valeur de cette variable de sorte à ce qu'elle n'apparaisse plus.
Expand All @@ -27,7 +27,7 @@
})();


function showDialog() {
function showMaitainanceDialog() {
const dialog = document.createElement('dialog');
dialog.id = 'maintenancePopin';
const dateFormatter = new Intl.DateTimeFormat('fr-FR', {
Expand Down Expand Up @@ -66,7 +66,59 @@

if (Date.now() < maintainanceEndDate.getTime() &&
(!localStorage.maintainanceStartDateAgreement || localStorage.maintainanceStartDateAgreement !== maintainanceStartDate.toISOString())) {
window.addEventListener('load', showDialog);
window.addEventListener('load', showMaitainanceDialog);
}

/**
* Creates a link (anchor element) given the text and the href (link) passed.
* We use this method to prevent XSS injection.
*/
function makeLink(text, href) {
const a = document.createElement('a');
a.textContent = text;
a.href = href;
a.target = "_blank";
a.rel = 'nofollow';
return a;
}

function showAgreementDialog() {
const { termsOfServiceUrl } = window.gristConfig;
if (!termsOfServiceUrl) {
return;
}

const dialog = document.createElement('dialog');
dialog.id = 'agreementPopin';
const cguLinkHtml = makeLink("les conditions d'utilisation", termsOfServiceUrl).outerHTML;
dialog.innerHTML = `
<p>
Veuillez accepter ${cguLinkHtml} de Grist avant de continuer.
</p>
<p>
Vous pourrez les retrouvez à tout moment via le lien en bas<br>
à gauche de la page d'accueil de Grist.
</p>
<form method="dialog">
<p>
<input type="checkbox" id="jaccepte">
<label for="jaccepte">J'ai lu et j'accepte sans réserve ${cguLinkHtml}</label>
</p>
<button disabled id="fermerPopinAgreement">Poursuivre sur Grist</button>
</form>
`;
document.body.appendChild(dialog);
document.getElementById('fermerPopinAgreement').onclick = function onMessageUnderstood() {
localStorage.gcuAgreementDate = new Date().toISOString();
}
document.getElementById('jaccepte').onchange = function (ev) {
document.getElementById('fermerPopinAgreement').disabled = !ev.target.checked;
}
dialog.showModal();
}

if (!localStorage.gcuAgreementDate) {
window.addEventListener('load', showAgreementDialog);
}
})();

Expand Down
Binary file added dockerfiles/grist/ressources/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed dockerfiles/grist/ressources/marianne-48x48.png
Binary file not shown.
Loading