post by heruprambadi on Nov 25, 2023

Hello @johnny , so i try to input data using GCE from slow internet. I fill the form, and click save 10 x. And it inserts data 10 x. It should be just inserted one times.

So my question is, how to prevent multiple times insert with gce ?

post by johnny on Nov 25, 2023

Hello @heruprambadi ,

I never thought about that to be honest. I think I should just disable the button “Insert” when you press the button. I will revisit it for the next version release and let you know.

Regards
Johnny

post by heruprambadi on Nov 26, 2023

Yeah, i never thought about that too. But some of my clients still use very slow internet connection, and i just found the same data inserted by my client with just 1 sec time difference. From my experience, it caused by slow internet connection. So when they click save button, insert process is so slow and thats make they think they should click save button again to make it fast. And after that, multiple same data inserted.

Another reason is, they just accidentaly click save button twice. But it’s almost imposibble to click it twice from fast internet @johnny

post by nasrul on Nov 29, 2023

hello @heruprambadi

i add this script in my default view to prevent that happen
in javascript tag

        window.addEventListener('gcrud.form.add-load', () => {
            setLoadingBtnGc();
        });
        window.addEventListener('gcrud.form.edit-load', ({
            detail
        }) => {
            setLoadingBtnGc();
        });

        function setLoadingBtnGc() {
            $('form[class^="gc-form-"]').submit(function() {
                var form = $(this);
                var button = form.find('button[type="submit"]');
                var labelBefore = button.html();
                button.prop('disabled', true);
                button.html('<span class="fa fa-spinner"></span> Loading...');
                enableButtonGcAgain(button,labelBefore);
                return true;
            });
        }
        function enableButtonGcAgain(button,labelBefore){
            setTimeout(function() {
                button.prop('disabled', false);
                button.html(labelBefore);
            }, 3000); // Adjust the timeout as needed (in milliseconds)
        }

post by heruprambadi on Nov 30, 2023

Thank’s @nasrul , but i haven’t tested it yet. To test it, i have to find slow internet connection, and it’s really hard to find slow internet from where i am now :smiley:
I think people in big city never experience this problem, that’s why @johnny never thought about it.

post by heruprambadi on Nov 30, 2023

post by johnny on Nov 30, 2023

Thanks @nasrul for this. In the meantime, I have fixed this issue for the next version which hopefully will be released soon :slight_smile:

post by nasrul on Dec 1, 2023

post by nasrul on Dec 1, 2023

post by johnny on Dec 2, 2023

I am glad to announce you that this is now fixed on the latest version of Grocery CRUD (3.0.16)

If you are using Composer then I have good news for you since now we have moved to our private composer server. In short that means that you no longer need to download any zip file for update :slight_smile:

For more you can check the blog post: Grocery CRUD Private Composer | Grocery CRUD Blog

Regards
Johnny

post by heruprambadi on Dec 3, 2023

1 / 11
Nov 2023