-
Notifications
You must be signed in to change notification settings - Fork 11
Ngstack 833 cookie consent cookie policy improvements new #210
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
base: master
Are you sure you want to change the base?
Changes from all commits
4732349
7d91ed5
dfa908f
7637ebc
8af15f1
7a2af09
4fed0bd
122a9f0
9bd336f
8ee8393
2d59474
2348b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* REQUIRED HTML STRUCTURE FOR IT TO WORK | ||
|
|
||
| FETCH PAGE AND RENDER WRAPPER | ||
| <div class="js-fetch-page" data-fetch-page-content-id="CONTENT_ID"> | ||
|
|
||
| FETCHED PAGE PLACEHOLDER | ||
| <div class="js-fetch-page-placeholder"></div> | ||
|
|
||
| WRAPPED FETCH TRIGGER LINK FOR EZRICHTEXT TEXTS | ||
| <div class="js-fetch-page-trigger-wrapper"><a href=""></a></div> | ||
| OR JUST FETCH TRIGGER LINK | ||
| <a class="js-fetch-page-trigger-wrapper"></a> | ||
|
|
||
| FETCHED PAGE REMOVAL LINK FROM PLACEHOLDER | ||
| <a class="js-fetch-page-remove"></a> | ||
|
|
||
| </div> | ||
|
|
||
| */ | ||
| export default class FetchPageAndRender { | ||
| constructor(element, options) { | ||
| this.element = element; | ||
| this.options = options; | ||
|
|
||
| this.triggerWrapper = document.querySelector(options.triggerWrapper); | ||
| this.pagePlaceholder = document.querySelector(options.pagePlaceholder); | ||
| this.pageRemove = document.querySelector(options.pageRemove); | ||
|
|
||
| this.init(); | ||
| } | ||
|
|
||
| init() { | ||
| if (this.triggerWrapper instanceof HTMLAnchorElement) { | ||
| this.triggerWrapper.addEventListener('click', this.handleFetchPage.bind(this)); | ||
| } else { | ||
| this.triggerWrapper | ||
| .querySelector('a') | ||
| .addEventListener('click', this.handleFetchPage.bind(this)); | ||
| } | ||
| } | ||
|
|
||
| handleFetchPage(event) { | ||
| event.preventDefault(); | ||
|
|
||
| const url = `/view-payload/${this.element.dataset.fetchPageContentId}`; | ||
|
|
||
| fetch(url) | ||
| .then((response) => { | ||
| console.log(url, response); | ||
| if (!response.ok) { | ||
| throw new Error(); | ||
| } | ||
| return response.text(); | ||
| }) | ||
| .then(this.handleRenderPage.bind(this)) | ||
| .catch((error) => { | ||
| console.error(`Failed to fetch page content: ${error}`); | ||
| }); | ||
| } | ||
|
|
||
| handleRenderPage(page) { | ||
| const template = document.createElement('template'); | ||
| template.innerHTML = page.trim(); | ||
|
|
||
| this.pagePlaceholder.appendChild(template.content); | ||
|
|
||
| this.pageRemove.addEventListener('click', (e) => { | ||
| e.preventDefault(); | ||
| this.pagePlaceholder.innerHTML = ''; | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ngsite_view_payload: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain a bit why this route is used for? In any case, this should not be located in media-site, but in netgen/site-bundle.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was used to activate payload I guess. Was not working without it. Please suggest me how to do it? The same file and line of code, just to do it inside netgen/site-bundle?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is used exclusively to display the cookie policy, then the controller and route should reflect this. You don't need to pass the content ID around when the controller can just load the cookie policy text by itself and output it. Besides, having this generic controller take ANY content ID and just display the content can be a security issue. |
||
| path: /view-payload/{contentId} | ||
| controller: App\Controller\ViewPayload | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Controller; | ||
|
|
||
| use Netgen\Bundle\SiteBundle\Controller\Controller; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| final class ViewPayload extends Controller | ||
| { | ||
| public function __invoke(int $contentId): Response | ||
| { | ||
| return new Response( | ||
| $this->getContentRenderer()->renderContent( | ||
| $this->getLoadService()->loadContent($contentId), | ||
| 'payload', | ||
| ), | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100000 was not enough? :D
please add a proper value based on the bootstrap z-index states:
https://getbootstrap.com/docs/5.2/layout/z-index/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was not enough, unfortunately toggle buttons are leaking on the front of page due to this fix

Not ideal of course. Please suggest any solution if you have one.