From b779852702743266fb048e28f85be6abc845795b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 30 Nov 2013 13:56:51 -0800 Subject: [PATCH] CRM-13863 - Custom - Ajaxify adding/editing custom fields --- CRM/Custom/Page/Field.php | 3 +-- templates/CRM/Custom/Page/Field.js | 14 ++++++++++++++ templates/CRM/Custom/Page/Field.tpl | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 templates/CRM/Custom/Page/Field.js diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 8475b42d01..cadb99ddce 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -69,7 +69,6 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { */ function &actionLinks() { if (!isset(self::$_actionLinks)) { - $deleteExtra = ts('Are you sure you want to delete this custom data field?'); self::$_actionLinks = array( CRM_Core_Action::UPDATE => array( 'name' => ts('Edit Field'), @@ -112,7 +111,6 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=delete&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Delete Custom Field'), - 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', ), ); } @@ -285,6 +283,7 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $this->preview($id); } else { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Custom/Page/Field.js'); $this->browse(); } diff --git a/templates/CRM/Custom/Page/Field.js b/templates/CRM/Custom/Page/Field.js new file mode 100644 index 0000000000..6c870aaab2 --- /dev/null +++ b/templates/CRM/Custom/Page/Field.js @@ -0,0 +1,14 @@ +// http://civicrm.org/licensing +cj(function($) { + $('#crm-main-content-wrapper') + // Widgetize the content area + .crmSnippet({block: false}) + // Open action links in a popup + .on('click', 'a.action-item:not(".enable-action, .disable-action")', function() { + CRM.loadForm(this.href).on('crmFormSuccess', function(e, data) { + // Refresh page when form completes + $('#crm-main-content-wrapper').crmSnippet('refresh'); + }); + return false; + }); +}); diff --git a/templates/CRM/Custom/Page/Field.tpl b/templates/CRM/Custom/Page/Field.tpl index cc4e6e12b5..1cdfb37c6a 100644 --- a/templates/CRM/Custom/Page/Field.tpl +++ b/templates/CRM/Custom/Page/Field.tpl @@ -70,7 +70,7 @@ {/strip} @@ -79,7 +79,7 @@
{ts}status{/ts} {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group/field/add' q="action=add&reset=1&gid=$gid"}{/capture} - {ts 1=$groupTitle 2=$crmURL}There are no custom fields for custom group '%1', add one.{/ts} + {ts 1=$groupTitle 2=$crmURL}There are no custom fields for custom group '%1', add one.{/ts}
{/if} {/if} -- 2.25.1