From 2c8776f08e644029dcc5da338c58b9e0fc9c39fa Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 1 Feb 2016 16:57:31 -0700 Subject: [PATCH] Improve navigation menu item edit form --- CRM/Admin/Form/Navigation.php | 37 ++++++++++--------------- templates/CRM/Admin/Form/Navigation.tpl | 36 +++++++++++++++++------- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index 846ab46360..5f631f62e1 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -47,6 +47,8 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { public function buildQuickForm() { parent::buildQuickForm(); + $this->setPageTitle(ts('Menu Item')); + if ($this->_action & CRM_Core_Action::DELETE) { return; } @@ -65,27 +67,22 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { ); $this->add('text', 'url', ts('Url'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'url')); - $permissions = CRM_Core_Permission::basicPermissions(TRUE); - $include = &$this->addElement('advmultiselect', 'permission', - ts('Permission') . ' ', $permissions, - array( - 'size' => 5, - 'style' => 'width:auto', - 'class' => 'advmultiselect', - ) + $permissions = array(); + foreach (CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $id => $vals) { + $permissions[] = array('id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals)); + } + $this->add('text', 'permission', ts('Permission'), + array('placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(array('data' => $permissions))) ); - $include->setButtonAttributes('add', array('value' => ts('Add >>'))); - $include->setButtonAttributes('remove', array('value' => ts('<< Remove'))); - - $operators = array('AND' => 'AND', 'OR' => 'OR'); - $this->add('select', 'permission_operator', ts('Operator'), $operators); + $operators = array('AND' => ts('AND'), 'OR' => ts('OR')); + $this->add('select', 'permission_operator', NULL, $operators); //make separator location configurable - $separator = array(0 => 'None', 1 => 'After Menu Element', 2 => 'Before Menu Element'); - $this->add('select', 'has_separator', ts('Separator?'), $separator); + $separator = array(ts('None'), ts('After menu element'), ts('Before menu element')); + $this->add('select', 'has_separator', ts('Separator'), $separator); - $active = $this->add('advcheckbox', 'is_active', ts('Enabled?')); + $active = $this->add('advcheckbox', 'is_active', ts('Enabled')); if (CRM_Utils_Array::value('name', $this->_defaults) == 'Home') { $active->freeze(); @@ -101,7 +98,7 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { $homeMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Home', 'id', 'name'); unset($parentMenu[$homeMenuId]); - $parent = $this->add('select', 'parent_id', ts('Parent'), array('' => ts('- select -')) + $parentMenu); + $this->add('select', 'parent_id', ts('Parent'), array('' => ts('Top level')) + $parentMenu, FALSE, array('class' => 'crm-select2')); } } @@ -111,12 +108,6 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { public function setDefaultValues() { $defaults = $this->_defaults; if (isset($this->_id)) { - if (!empty($this->_defaults['permission'])) { - foreach (explode(',', $this->_defaults['permission']) as $value) { - $components[$value] = $value; - } - $defaults['permission'] = $components; - } //Take parent id in object variable to calculate the menu //weight if menu parent id changed $this->_currentParentID = CRM_Utils_Array::value('parent_id', $this->_defaults); diff --git a/templates/CRM/Admin/Form/Navigation.tpl b/templates/CRM/Admin/Form/Navigation.tpl index 95770d3ee4..f3cb505ef6 100644 --- a/templates/CRM/Admin/Form/Navigation.tpl +++ b/templates/CRM/Admin/Form/Navigation.tpl @@ -26,32 +26,48 @@ {* this template is used for adding/editing CiviCRM Menu *}
{include file="CRM/common/formButtons.tpl" location="top"}
-
{if $action eq 1}{ts}New Menu{/ts}{elseif $action eq 2}{ts}Edit Menu{/ts}{else}{ts}Delete Menu{/ts}{/if} - + + - { if $form.parent_id.html } + {if $form.parent_id.html} - + + {/if} - + + - - - - + +
{$form.label.label}{$form.label.html}
{$form.url.label}{$form.url.html} {help id="id-menu_url" file="CRM/Admin/Form/Navigation.hlp"}{$form.url.label} {help id="id-menu_url" file="CRM/Admin/Form/Navigation.hlp"}{$form.url.html}
{$form.parent_id.label}{$form.parent_id.html} {help id="id-parent" file="CRM/Admin/Form/Navigation.hlp"}{$form.parent_id.label} {help id="id-parent" file="CRM/Admin/Form/Navigation.hlp"}{$form.parent_id.html}
{$form.has_separator.label}{$form.has_separator.html} {help id="id-has_separator" file="CRM/Admin/Form/Navigation.hlp"}{$form.has_separator.label} {help id="id-has_separator" file="CRM/Admin/Form/Navigation.hlp"}{$form.has_separator.html}
{$form.permission.label}{help id="id-menu_permission" file="CRM/Admin/Form/Navigation.hlp"}{$form.permission.html}
 {$form.permission_operator.html} {$form.permission_operator.label} {help id="id-permission_operator" file="CRM/Admin/Form/Navigation.hlp"}{$form.permission.label}{help id="id-menu_permission" file="CRM/Admin/Form/Navigation.hlp"}{$form.permission.html} {$form.permission_operator.html} {help id="id-permission_operator" file="CRM/Admin/Form/Navigation.hlp"}
{$form.is_active.label}{$form.is_active.html}
-
{include file="CRM/common/formButtons.tpl" location="bottom"}
+{literal} + +{/literal} -- 2.25.1