From a2a3cc46057d813a696e270460dd4cf087c65a94 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 25 Sep 2017 12:37:34 -0400 Subject: [PATCH] IconPicker fixes - add crm-i class and display icon in jstree --- CRM/Admin/Form/Navigation.php | 4 ++++ js/jquery/jquery.crmIconPicker.js | 6 ++++-- templates/CRM/Admin/Page/Navigation.tpl | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index 4075ffd55b..12cd080471 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -137,6 +137,10 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { $params['current_parent_id'] = $this->_currentParentID; } + if (!empty($params['icon'])) { + $params['icon'] = 'crm-i ' . $params['icon']; + } + $navigation = CRM_Core_BAO_Navigation::add($params); // also reset navigation diff --git a/js/jquery/jquery.crmIconPicker.js b/js/jquery/jquery.crmIconPicker.js index 8fce94267f..6e84df5c02 100644 --- a/js/jquery/jquery.crmIconPicker.js +++ b/js/jquery/jquery.crmIconPicker.js @@ -38,10 +38,12 @@ ]; function formatButton() { - var split = $input.val().split(' '); + var val = $input.val().replace('fa ', ''); + val = val.replace('crm-i ', ''); + var split = val.split(' '); $button.button('option', { label: split[0] || ts('None'), - icons: {primary: $input.val()} + icons: {primary: val ? val : 'fa-'} }); $style.toggle(!!split[0]).val(split[1] || ''); } diff --git a/templates/CRM/Admin/Page/Navigation.tpl b/templates/CRM/Admin/Page/Navigation.tpl index e37969e883..53df3b70d2 100644 --- a/templates/CRM/Admin/Page/Navigation.tpl +++ b/templates/CRM/Admin/Page/Navigation.tpl @@ -60,7 +60,7 @@ CRM.api3('Navigation', 'get', { domain_id: {/literal}{$config->domainID()}{literal}, options: {limit: 0, sort: 'weight'}, - return: ['label', 'parent_id'], + return: ['label', 'parent_id', 'icon'], name: {'!=': 'Home'}, sequential: 1 }).done(function(data) { @@ -69,7 +69,7 @@ items.push({ id: value.id, text: value.label, - icon: false, + icon: value.icon || false, parent: value.parent_id || '#' }); }); -- 2.25.1