From 62fbdfc0a466d0418466aaf0fc89c59b244127fb Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 14 Jul 2018 16:52:48 +0100 Subject: [PATCH] Improve optiongroups admin UI workflow --- CRM/Admin/Form/OptionGroup.php | 19 ++++++++++++------- templates/CRM/Admin/Form/OptionGroup.tpl | 4 ++++ templates/CRM/Admin/Page/OptionGroup.tpl | 5 ++++- templates/CRM/Admin/Page/Options.tpl | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CRM/Admin/Form/OptionGroup.php b/CRM/Admin/Form/OptionGroup.php index c1216fcd83..0b76228f1c 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -78,7 +78,7 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description') ); - $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE); + $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), empty($this->_values['is_reserved'])); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { @@ -96,8 +96,12 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { $element->freeze(); } } + + $this->add('checkbox', 'is_reserved', ts('Reserved?')); + $this->freeze('is_reserved'); + if (!empty($this->_values['is_reserved'])) { - $this->freeze(array('name', 'is_active')); + $this->freeze(array('name', 'is_active', 'data_type')); } } @@ -118,12 +122,13 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { // store the submitted values in an array $params = $this->exportValues(); - // If we are adding option group via UI it should not be marked reserved. - if (!isset($params['is_reserved'])) { - $params['is_reserved'] = 0; + if ($this->_action & CRM_Core_Action::ADD) { + // If we are adding option group via UI it should not be marked reserved. + if (!isset($params['is_reserved'])) { + $params['is_reserved'] = 0; + } } - - if ($this->_action & CRM_Core_Action::UPDATE) { + elseif ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } diff --git a/templates/CRM/Admin/Form/OptionGroup.tpl b/templates/CRM/Admin/Form/OptionGroup.tpl index a5f60ea67d..0712447471 100644 --- a/templates/CRM/Admin/Form/OptionGroup.tpl +++ b/templates/CRM/Admin/Form/OptionGroup.tpl @@ -52,6 +52,10 @@ {$form.is_active.label} {$form.is_active.html} + + {$form.is_reserved.label} + {$form.is_reserved.html} + {/if}
{include file="CRM/common/formButtons.tpl" location="bottom"}
diff --git a/templates/CRM/Admin/Page/OptionGroup.tpl b/templates/CRM/Admin/Page/OptionGroup.tpl index e8c60e31d8..9b57c75c24 100644 --- a/templates/CRM/Admin/Page/OptionGroup.tpl +++ b/templates/CRM/Admin/Page/OptionGroup.tpl @@ -60,7 +60,10 @@ {$row.name} {if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if} - {ts}Options{/ts} + + {ts}Settings{/ts} + {ts}Edit Options{/ts} + {/foreach} diff --git a/templates/CRM/Admin/Page/Options.tpl b/templates/CRM/Admin/Page/Options.tpl index 8a5936b631..bea754d8f4 100644 --- a/templates/CRM/Admin/Page/Options.tpl +++ b/templates/CRM/Admin/Page/Options.tpl @@ -175,7 +175,7 @@ {if $isLocked ne 1} {crmButton p="civicrm/admin/options/$gName" q='action=add&reset=1' class="new-option" icon="plus-circle"}{ts 1=$gLabel}Add %1{/ts}{/crmButton} {/if} - {crmButton p="civicrm/admin" q="reset=1" class="cancel" icon="times"}{ts}Done{/ts}{/crmButton} + {crmButton p="civicrm/admin/options" q="action=browse&reset=1" class="next no-popup" icon="check"}{ts}Done{/ts}{/crmButton} {/if} -- 2.25.1