Page 1 of 2

Overlapping Elements in Iframe Edit Form

Posted: Tue Jan 21, 2025 9:24 pm
by yvesf
Hi,

I have a browse and edit form within an iframe filtered by date. When I try to create a new record, the interface behaves unexpectedly.
Video_2025-01-21_211457.gif
Many thanks for your recommandation to solve this issue.

Yves

Re: Overlapping Elements in Iframe Edit Form

Posted: Tue Jan 21, 2025 9:32 pm
by steven
Hi yvesf,

Can you upload a copy, so we can take a look?


Steven

Re: Overlapping Elements in Iframe Edit Form

Posted: Tue Jan 21, 2025 10:28 pm
by yvesf
Here it is -->
01-21-2025_202611_679010f36a5dc_nuBuilder_backup.sql.gzip

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 5:58 am
by kev1n
Hi Yves,

It seems that the issue is caused by nuFilterRun(). When I remove or exclude it, the functionality works as expected.
As a workaround, you could add the following WHERE clause to the iframe SQL to display today’s data by default:

Code: Select all

WHERE CAST(rdv_date AS DATE) = CURDATE()
For filtering, you can set a hash cookie containing a different date and then refresh the iframe accordingly. If you’re unsure how to implement this, I’d be happy to provide an example.

Additionally, it’s important not to declare variables using let or const directly in the Custom Code of the form. If the form is reloaded, these variables will still exist and can cause errors. To avoid this, you can refactor the code into separate functions where let and const can be safely used, or you can use var directly in the form’s Custom Code.

Also, It’s important to note that `nuuserhome` is a core form in nuBuilder, and no custom code should be added to it, as it will be overwritten when nuBuilder is updated. However, perhaps you only used it for your upload sample.

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 7:07 am
by yvesf
Hi Kev1n,

Thank you for your valuable feedback—it’s much appreciated!

I’ve been working on building an agenda in nuBuilder and initially considered using the nufilterrun function with the following approach:

- I have a browse list, which displays the full list of tasks, regardless of the date, sorted by date.
My idea was to create an iframe that filters tasks dynamically based on a date field at the top of the page. I have seen a lot of videos pushing this approach.
However, I now understand that using nufilterrun may not be the best approach, as it can cause UI rendering issues.
I understand that a better solution would be to use hash cookies. If possible, could you provide an example or further explanation of how to implement this method?

On another point, I appreciate your remark about customizing nuUserHome. I’ve applied this customization to each of my apps. However, before proceeding with any upgrades, I understand it’s better to create a dedicated launch form instead.

Thanks again for your continued help and support!

Yves

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 8:05 am
by kev1n
iframe WHERE:

Code: Select all

WHERE
    (
        '#filter_date#' = '' OR '#filter_date#' = '#' OR CAST('#filter_date#' AS DATE) IS NULL
    )
    AND CAST(rdv_date AS DATE) = CURDATE()
    OR (
        LENGTH('#filter_date#') = 10 
        AND CAST('#filter_date#' AS DATE) IS NOT NULL 
        AND CAST(rdv_date AS DATE) = CAST('#filter_date#' AS DATE)
    );
(if no filter is set, use the current date as default)

And for "Date Accueil", I added an onchange event that calls a function refreshRDViFrame(); that is declared in the main form's Custom Code:

Code: Select all

function refreshRDViFrame() {

    let $accDate = $('#acc_date');
    let filterDate = nuFORM.removeFormatting($accDate.val(), $accDate.attr('data-nu-format'));

    const iframeRDV = $("#RDV_iframe")[0].contentWindow;
    iframeRDV.nuSetProperty('filter_date', filterDate);
    iframeRDV.nuGetBreadcrumb();

}
Similarly, a filter condition can be applied to the "acc_praticien" field.

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 9:55 am
by yvesf
Hi Kevin,

I have the following error "Uncaught TypeError: Cannot read properties of undefined (reading 'contentWindow')".
It seems that the iframe's contentWindow is not accessible.
Thx for your help,

Yves

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 10:00 am
by kev1n
Replace "RDV_iframe" with the obj ID of your iframe if it is different.

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 10:15 am
by yvesf
solved but not filtering the view

Yves

Re: Overlapping Elements in Iframe Edit Form

Posted: Wed Jan 22, 2025 10:19 am
by kev1n
Please upload the db again.