[almost] AUTOMATIC FORM BUTTONS

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

[almost] AUTOMATIC FORM BUTTONS

Post by grimblefritz » 2016-07-17 19:43

I've put together a module that handles detail view form buttons, in much the same way mktabbed_html() does for tabs. (Note I say mktabbed_html() and not mktabbed(), meaning this module uses an array and only an array.)

I've added the module to my mktabbed demo site. Once you click into the detail view, there you will see the additional buttons.

Source is linked on the main page.

Instructions for use are in the source comments.

For the click-averse, a sample:

Code: Select all

      require('hooks/_mkbuttons.php');

      $buttons['print']['invoice']['name'] = 'Print Invoice';
      $buttons['print']['invoice']['insert'] = false;
      $buttons['print']['invoice']['update'] = true;
      $buttons['print']['invoice']['style'] = 'default';
      $buttons['print']['invoice']['icon'] = 'print';

      $buttons['print']['voucher']['name'] = 'Print Voucher';
      $buttons['print']['voucher']['insert'] = false;
      $buttons['print']['voucher']['update'] = true;
      $buttons['print']['voucher']['style'] = 'default';
      $buttons['print']['voucher']['icon'] = 'print';

      $buttons['email']['invoice']['name'] = 'Email Invoice';
      $buttons['email']['invoice']['insert'] = false;
      $buttons['email']['invoice']['update'] = true;
      $buttons['email']['invoice']['style'] = 'success';
      $buttons['email']['invoice']['icon'] = 'envelope';

      $html .= mkbuttons('orders', $selecteID, $buttons)

sgrzy01
Posts: 16
Joined: 2016-07-25 20:04

Re: [almost] AUTOMATIC FORM BUTTONS

Post by sgrzy01 » 2016-07-25 20:34

Thank you for this... and sorry if I'm being thick.. but where does this code get inserted?

in the code (for ex:) it says, "In the orders.php file, orders() function, add this code", orders() function? I suspect it would go into orders_dv() but not having luck.

Can you clarify for me?

Thanks...

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: [almost] AUTOMATIC FORM BUTTONS

Post by grimblefritz » 2016-07-26 16:20

UPDATED:

* Improved click event handling
* Added optional confirmation dialog

Demo, source and example contacts.php available on my form tools demo site.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: [almost] AUTOMATIC FORM BUTTONS

Post by DevGiu » 2016-07-28 10:47

Could be interesting to attach in one param a JS function to tell directly to the button wich JS execute.
Sample:

Code: Select all

$buttons['email']['invoice']['action'] = 'function(){ alert "hello"; }';
/Giuseppe
Professional Outsourcing Services

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: [almost] AUTOMATIC FORM BUTTONS

Post by grimblefritz » 2016-07-28 11:47

I was thinking about that yesterday, but along the lines of checking for a user-defined function of a predefined name.

For example, if you need a custom js action, you would define (using your example):

function mkb_email_invoice_click(....

If that exists, it would be used instead of the current window.location method.

Would that work? I think there are already too many parameters, I'm reluctant to add another.

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: [almost] AUTOMATIC FORM BUTTONS

Post by DevGiu » 2016-07-28 12:16

I think the way you describe could be interesting
/Giuseppe
Professional Outsourcing Services

Post Reply