Page 1 of 2
nuBuilder4-cloner
Posted: Sun Oct 25, 2020 8:39 am
by kev1n
Hi guys,
Here comes the "nuBuilder cloner".
It allows you to clone a nuBuilder Form with all its objects, events etc.
Features:
* Clone/Duplicate Forms with all PHP events, select, select clause, browse, tabs etc.
* Clone Objects with their events etc.
* Include only certain form tabs
* Copy objects to a new or existing form
* Dump the SQL INSERT statements to the browser window instead of executing them
Some Use cases:
* Clone a form to test changes before they are integrated into the productive system
* Export a form from one database and import it into another one
* You created a form and want to duplicate it because you need a similar form (Instead of recreating it from scratch)
* You want to copy a bunch of controls from one form to another
* You want other users than globeadmin (e.g. supervisors/managers) to manage the nuBuilder users. Clone nuBuilder's user form, customize it and give access to any users.
https://github.com/smalos/nuBuilder4-cloner
Re: nuBuilder4-cloner
Posted: Mon Oct 26, 2020 1:54 am
by nc07
Thanks, Ke1vin for your hard work and time, the nubuilder4 cloner would really save time now as we don't have to recreate the forms from the scratch. I have tested it and it works like charm.
Cheers
nc07
Re: nuBuilder4-cloner
Posted: Mon Oct 26, 2020 11:18 am
by Janusz
To confirm - I tested it as well - and works very well. It's really helpful tool. Thanks kev1n.
Re: nuBuilder4-cloner
Posted: Wed Oct 28, 2020 8:17 am
by kev1n
Thank you for your kind words, I truly appreciate it!
Any other comments/suggesions? (Especially from the nuBuilder specialists)
BTW, there has been an update:
* Fix cloner_tabs: Include only those specified with nuSetProperty()
* Added: cloneFormSelect(), cloneFormSelectClause() to clone a form's select and select clause.
* Added: If the Hash Cookie #cloner_open_new_form# is set to '0', the new form is not displayed
* Changed : If the Hash Cookie #cloner_without_objects# is set to '1', the objects on the form are not cloned
Re: nuBuilder4-cloner
Posted: Wed Oct 28, 2020 12:43 pm
by nac
Hello kev1n,
As others have said, this works really well and is a very welcome addition. Thanks for your efforts on this.
One suggestion - as it works by building a series of SQL INSERT statements, why not have an option that directs these to a .SQL text (dump) file rather than executing them in the current database? This would then allow the user to create a simple export file to copy a form and all its components to a different nuBuilder instance. I can see that you are using prepared statements with parameters in function insertRecord and so adding an option to create the equivalent insert statement with literals should be quite straightforward (I think!).
Even in the same database, it can sometimes be faster to dump some of the zzzz* records as a set of SQL statements, edit values and then re-import - if you know what you are doing.
Thanks again.
Neil
Re: nuBuilder4-cloner
Posted: Wed Oct 28, 2020 2:38 pm
by kev1n
Hi Neil,
Thanks for your feedback! Actually that's an excellent idea. I had actually started another project ("nuBuilder Exporter") that does just that.
However, I was not yet able to finish it completely. I'll see what can be done.
Re: nuBuilder4-cloner
Posted: Wed Oct 28, 2020 2:59 pm
by nac
You are very welcome, kev1n . I have been doing a bit more work with nuBuilder recently and have found a number of your code snippets to be very useful. Thanks once again.
It strikes me that you have already done the heavy lifting for a form exporter with the cloning code. It could easily be adapted for other objects as well.
Neil
PS I followed the Discord link in your signature but the invitation is not valid. I have never used Discord and so there may be something else going wrong.
Re: nuBuilder4-cloner
Posted: Wed Oct 28, 2020 4:05 pm
by kev1n
Neil,
I updated the discord link. I hope it works now.
And...
I also updated the cloner. It's now possible to dump the SQL statements instead of executing them.
Code: Select all
nuSetProperty('cloner_dump_statements','1');
nuSetProperty('cloner_without_objects', "0");
nuSetProperty('cloner_tabs','');
nuSetProperty('cloner_f1','');
nuSetProperty('cloner_f2','');
nuRunPHP('cloner', '',1);
Note: Instead of nuRunPHPHidden() use nuRunPHP(). This allows us to output the statements in a new browser tab.
sql_dump.png
Re: nuBuilder4-cloner
Posted: Thu Oct 29, 2020 9:57 am
by nac
Hi kev1n,
I have been doing a few tests using version 1.07 (
https://github.com/smalos/nuBuilder4-cl ... cloner.php) and it looks good. As you mentioned, the hash cookie flag is now the shorter '#cloner_dump#' (rather than the earlier '#cloner_dump_statements#') . The JS code ..
Code: Select all
nuSetProperty('cloner_dump','1');
nuSetProperty('cloner_without_objects', '0');
nuSetProperty('cloner_tabs','');
nuSetProperty('cloner_f1','');
nuSetProperty('cloner_f2','');
nuRunPHP('cloner', '',1);
.. generates all the SQL statements to create the complete form.
Great job.
Neil
Re: nuBuilder4-cloner
Posted: Thu Oct 29, 2020 10:31 am
by kev1n
Thanks Neil for testing (and your inputs) !