From 7926b99958de7914a57fe7e8d9a17ad64034690c Mon Sep 17 00:00:00 2001 From: mark burdett Date: Wed, 30 Apr 2014 17:45:40 -0700 Subject: [PATCH] migrate "Create New" button to hierarchical jQuery UI menu --- CRM/Contact/BAO/ContactType.php | 11 ++++++-- CRM/Core/Block.php | 31 ++++++++++++++-------- css/civicrm.css | 5 ++-- templates/CRM/Block/CreateNew.tpl | 43 ++++++++++++++----------------- 4 files changed, 51 insertions(+), 39 deletions(-) diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 67524c32da..1cc4976bc1 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -509,16 +509,23 @@ WHERE subtype.name IN ('" . implode("','", $subType) . "' )"; foreach ($contactTypes as $key => $value) { if ($key) { $typeValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $key); - $typeUrl = 'ct=' . CRM_Utils_Array::value('0', $typeValue); + $cType = CRM_Utils_Array::value('0', $typeValue); + $typeUrl = 'ct=' . $cType; if ($csType = CRM_Utils_Array::value('1', $typeValue)) { $typeUrl .= "&cst=$csType"; } - $shortCuts[] = array( + $shortCut = array( 'path' => 'civicrm/contact/add', 'query' => "$typeUrl&reset=1", 'ref' => "new-$value", 'title' => $value, ); + if ($csType = CRM_Utils_Array::value('1', $typeValue)) { + $shortCuts[$cType]['shortCuts'][] = $shortCut; + } + else { + $shortCuts[$cType] = $shortCut; + } } } return $shortCuts; diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index dfd0aa9981..537ef02d09 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -401,17 +401,8 @@ class CRM_Core_Block { } $values = array(); - foreach ($shortCuts as $short) { - $value = array(); - if (isset($short['url'])) { - $value['url'] = $short['url']; - } - else { - $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE); - } - $value['title'] = $short['title']; - $value['ref'] = $short['ref']; - $values[] = $value; + foreach ($shortCuts as $key => $short) { + $values[$key] = self::setShortCutValues($short); } // call links hook to add user defined links @@ -432,6 +423,24 @@ class CRM_Core_Block { self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values)); } + private static function setShortcutValues($short) { + $value = array(); + if (isset($short['url'])) { + $value['url'] = $short['url']; + } + elseif (isset($short['path'])) { + $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE); + } + $value['title'] = $short['title']; + $value['ref'] = $short['ref']; + if (!empty($short['shortCuts'])) { + foreach ($short['shortCuts'] as $shortCut) { + $value['shortCuts'][] = self::setShortcutValues($shortCut); + } + } + return $value; + } + /** * create the list of dashboard links * diff --git a/css/civicrm.css b/css/civicrm.css index 71b93e97da..53ed9afec5 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2426,7 +2426,7 @@ div.grippie { } #crm-create-new-list { - width: 124px; + width: 180px; } #crm-contact-actions-list .icon { background-image: url("../i/icons/jquery-ui-FFFFFF.png"); @@ -3754,14 +3754,13 @@ div.m ul#civicrm-menu, .crm-participant-list-inner, .crm-event-links-list-inner, .crm-contribpage-links-list-inner, -.crm-create-new-list-inner, .crm-contact-actions-list-inner { background-color: #2f2f2e; padding: 4px; } .crm-create-new-list-inner { - width: 124px!important; + width: 180px!important; } .ac_even { diff --git a/templates/CRM/Block/CreateNew.tpl b/templates/CRM/Block/CreateNew.tpl index 85a8ddaf91..784e564268 100644 --- a/templates/CRM/Block/CreateNew.tpl +++ b/templates/CRM/Block/CreateNew.tpl @@ -25,12 +25,20 @@
{ts}Create New{/ts} -
+
    - {foreach from=$shortCuts item=short} -
  • {$short.title}
  • - {/foreach} + {foreach from=$shortCuts item=short} +
  • {$short.title} + {if $short.shortCuts} + + {/if} +
  • + {/foreach}
@@ -39,26 +47,15 @@
{literal} {/literal} -- 2.25.1