From: Coleman Watts Date: Tue, 16 Sep 2014 01:30:44 +0000 (-0400) Subject: CRM-15295 - Show 'new item' after creating a container X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6f2311483b933b7547f5d24b2fdb2df1090b07a2;p=civicrm-core.git CRM-15295 - Show 'new item' after creating a container --- diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 5dba257bf9..940268bad2 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -501,7 +501,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; - $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse')); + $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&new=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", array(1 => $group->title) ), ts('Saved'), 'success'); diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 84507d6808..2428bc80fd 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -127,6 +127,11 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { * @access public */ function browse() { + $resourceManager = CRM_Core_Resources::singleton(); + if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + } + $customField = array(); $customFieldBAO = new CRM_Core_BAO_CustomField(); diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 7c4fc52542..e0f8e431b2 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -289,7 +289,7 @@ class CRM_Price_Form_Set extends CRM_Core_Form { else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? 'browse' : 'add'; - $url = CRM_Utils_System::url('civicrm/admin/price/field', array('reset' => 1, 'action' => $action, 'sid' => $set->id)); + $url = CRM_Utils_System::url('civicrm/admin/price/field', array('reset' => 1, 'action' => $action, 'sid' => $set->id, 'new' => 1)); CRM_Core_Session::setStatus(ts("Your Set '%1' has been added. You can add fields to this set now.", array(1 => $set->title) ), ts('Saved'), 'success'); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 4069279303..756fdce079 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -121,6 +121,11 @@ class CRM_Price_Page_Field extends CRM_Core_Page { * @access public */ function browse() { + $resourceManager = CRM_Core_Resources::singleton(); + if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + } + $priceField = array(); $priceFieldBAO = new CRM_Price_BAO_PriceField(); diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index d30758b344..112c1d0a49 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -370,7 +370,7 @@ class CRM_UF_Form_Group extends CRM_Core_Form { else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; - $url = CRM_Utils_System::url("civicrm/admin/uf/group/field$action", 'reset=1&gid=' . $ufGroup->id . '&action=' . ($action ? 'add' : 'browse')); + $url = CRM_Utils_System::url("civicrm/admin/uf/group/field$action", 'reset=1&new=1&gid=' . $ufGroup->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts('Your CiviCRM Profile \'%1\' has been added. You can add fields to this profile now.', array(1 => $ufGroup->title) ), ts('Profile Added'), 'success'); diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index f1803eebb8..ae3bdf8e95 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -110,6 +110,11 @@ class CRM_UF_Page_Field extends CRM_Core_Page { * @static */ function browse() { + $resourceManager = CRM_Core_Resources::singleton(); + if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + } + $ufField = array(); $ufFieldBAO = new CRM_Core_BAO_UFField(); diff --git a/js/crm.addNew.js b/js/crm.addNew.js new file mode 100644 index 0000000000..2fe2e02cee --- /dev/null +++ b/js/crm.addNew.js @@ -0,0 +1,8 @@ +// http://civicrm.org/licensing +// Opens the "new item" dialog after creating a container/set +CRM.$(function($) { + var emptyMsg = $('.crm-empty-table'); + if (emptyMsg.length) { + $('.action-link a.button', '#crm-container').click(); + } +}); diff --git a/templates/CRM/Custom/Page/Field.tpl b/templates/CRM/Custom/Page/Field.tpl index ceb0eb39c7..16fb0e61ce 100644 --- a/templates/CRM/Custom/Page/Field.tpl +++ b/templates/CRM/Custom/Page/Field.tpl @@ -70,9 +70,9 @@ {else} {if $action eq 16} -
+
{ts}status{/ts} - {ts 1=$groupTitle}There are no fields for custom group '%1'.{/ts} + {ts}None found.{/ts}
{/if} {/if} diff --git a/templates/CRM/Price/Page/Field.tpl b/templates/CRM/Price/Page/Field.tpl index c8d0262bf0..9ec0fea8e7 100644 --- a/templates/CRM/Price/Page/Field.tpl +++ b/templates/CRM/Price/Page/Field.tpl @@ -96,9 +96,9 @@ {else} {if $action eq 16} -
+
- {ts 1=$groupTitle 2=$crmURL}There are no fields for price set '%1'.{/ts} + {ts}None found.{/ts}