Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#155 Improve Option Groups form #12233

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions CRM/Admin/Form/OptionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,24 @@ public function buildQuickForm() {
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');
}
}
Expand Down
31 changes: 21 additions & 10 deletions templates/CRM/Admin/Page/OptionGroup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@
{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>
Expand All @@ -59,10 +70,10 @@
<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}
Expand Down