CRM-13863 - Custom - Ajaxify adding/editing custom fields
authorColeman Watts <coleman@civicrm.org>
Sat, 30 Nov 2013 21:56:51 +0000 (13:56 -0800)
committerColeman Watts <coleman@civicrm.org>
Sat, 30 Nov 2013 21:56:51 +0000 (13:56 -0800)
CRM/Custom/Page/Field.php
templates/CRM/Custom/Page/Field.js [new file with mode: 0644]
templates/CRM/Custom/Page/Field.tpl

index 8475b42d0181b05b7afe682bbbedac22a720a446..cadb99ddce8496bf4a06f31c330b408f5d7e58be 100644 (file)
@@ -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 (file)
index 0000000..6c870aa
--- /dev/null
@@ -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;
+    });
+});
index cc4e6e12b5fd0bdba24cb91a5a296dcf4dfa5fea..1cdfb37c6aae81be7cc1d500bdc0d6c3a9a16200 100644 (file)
@@ -70,7 +70,7 @@
         {/strip}
 
         <div class="action-link">
-            <a href="{crmURL p='civicrm/admin/custom/group/field/add' q="reset=1&action=add&gid=$gid"}" id="newCustomField" class="button"><span><div class="icon add-icon"></div>{ts}Add Custom Field{/ts}</span></a>
+            <a href="{crmURL p='civicrm/admin/custom/group/field/add' q="reset=1&action=add&gid=$gid"}" id="newCustomField" class="button action-item"><span><div class="icon add-icon"></div>{ts}Add Custom Field{/ts}</span></a>
         </div>
      </div>
 
@@ -79,7 +79,7 @@
         <div class="messages status no-popup">
         <img src="{$config->resourceBase}i/Inform.gif" alt="{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', <a href='%2'>add one</a>.{/ts}
+        {ts 1=$groupTitle 2=$crmURL}There are no custom fields for custom group '%1', <a class="action-item" href='%2'>add one</a>.{/ts}
         </div>
         {/if}
     {/if}