Add reserved/enabled to option groups list and buttons to top of page.
authorMatthew Wire <devel@mrwire.co.uk>
Tue, 29 May 2018 18:45:27 +0000 (19:45 +0100)
committerMatthew Wire <devel@mrwire.co.uk>
Thu, 21 Jun 2018 21:55:22 +0000 (22:55 +0100)
CRM/Admin/Form/OptionGroup.php
templates/CRM/Admin/Page/OptionGroup.tpl

index 059a5bf878604fab3bc2c7cac65c7e145490efae..c1216fcd83c2294b8d88f289009b8114161ac15b 100644 (file)
@@ -110,22 +110,24 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form {
   public function postProcess() {
     CRM_Utils_System::flushCache();
 
-    $params = $this->exportValues();
     if ($this->_action & CRM_Core_Action::DELETE) {
       CRM_Core_BAO_OptionGroup::del($this->_id);
       CRM_Core_Session::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success');
     }
     else {
-
-      $params = $ids = array();
       // 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::UPDATE) {
-        $ids['optionGroup'] = $this->_id;
+        $params['id'] = $this->_id;
       }
 
-      $optionGroup = CRM_Core_BAO_OptionGroup::add($params, $ids);
+      $optionGroup = CRM_Core_BAO_OptionGroup::add($params);
       CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name)), ts('Saved'), 'success');
     }
   }
index f33ba6ed422870619a6c43cbf45bea8046d94729..e8c60e31d833edb9972bbee03a8686e5592b04a4 100644 (file)
 {if $rows}
 
 <div id="browseValues">
-    {strip}
+  {if $action ne 1 and $action ne 2}
+    <div class="action-link">
+      {crmButton q="action=add&reset=1" id="newOptionGroup"  icon="plus-circle"}{ts}Add Option Group{/ts}{/crmButton}
+      {crmButton p="civicrm/admin" q="reset=1" class="cancel" icon="times"}{ts}Done{/ts}{/crmButton}
+    </div>
+  {/if}
+
+  {strip}
   {* handle enable/disable actions*}
    {include file="CRM/common/enableDisableApi.tpl"}
     <table cellpadding="0" cellspacing="0" border="0">
         <tr class="columnheader">
-        <th>{ts}Title{/ts}</th>
-        <th>{ts}Name{/ts}</th>
-        <th></th>
+          <th>{ts}Title{/ts}</th>
+          <th>{ts}Name{/ts}</th>
+          <th>{ts}Reserved{/ts}</th>
+          <th>{ts}Enabled?{/ts}</th>
+          <th></th>
         </tr>
         {foreach from=$rows item=row}
-      <tr id="optionGroup-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
-            <td class="crm-admin-optionGroup-title">{if $row.title}{$row.title}{else}( {ts}none{/ts} ){/if}</td>
-            <td class="crm-admin-optionGroup-name">{$row.name}</td>
-            <td><a href="{crmURL p="civicrm/admin/options" q="gid=`$row.id`&reset=1"}" title="{ts}View and Edit Options{/ts}">{ts}Options{/ts}</a></td>
+        <tr id="optionGroup-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"} {$row.class}{if NOT $row.is_active} disabled{/if}">
+          <td class="crm-admin-optionGroup-title">{if $row.title}{$row.title}{else}( {ts}none{/ts} ){/if}</td>
+          <td class="crm-admin-optionGroup-name">{$row.name}</td>
+          <td class="crm-admin-optionGroup-is_reserved">{if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
+          <td class="crm-admin-optionGroup-is_active" id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
+          <td><a href="{crmURL p="civicrm/admin/options" q="gid=`$row.id`&reset=1"}" title="{ts}View and Edit Options{/ts}">{ts}Options{/ts}</a></td>
         </tr>
         {/foreach}
     </table>
       <div class="action-link">
           {crmButton q="action=add&reset=1" id="newOptionGroup"  icon="plus-circle"}{ts}Add Option Group{/ts}{/crmButton}
           {crmButton p="civicrm/admin" q="reset=1" class="cancel" icon="times"}{ts}Done{/ts}{/crmButton}
-        </div>
+      </div>
     {/if}
 </div>
-{elseif $action NEQ 1 && $action NEQ 2}
+{elseif $action ne 1 and $action ne 2}
     <div class="messages status no-popup">
         <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/>
         {capture assign=crmURL}{crmURL p='civicrm/admin/optionGroup' q="action=add&reset=1"}{/capture}