From 704f21c02f7d64accdfec4020fd5b0078ecf5cf4 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 18 Aug 2014 13:14:00 +0100 Subject: [PATCH] CRM-13863 - Improve workflow with container sets (custom fields/prices/profiles) --- CRM/Custom/Form/Group.php | 4 +++- CRM/Custom/Page/Field.php | 1 + CRM/Price/Form/Field.php | 16 +++++++++++++--- CRM/Price/Form/Set.php | 4 +++- CRM/Price/Page/Field.php | 3 --- CRM/UF/Form/Field.php | 12 +++++++++++- CRM/UF/Form/Group.php | 4 +++- templates/CRM/Custom/Page/Field.tpl | 11 +++++------ templates/CRM/Price/Form/Field.tpl | 1 - templates/CRM/Price/Page/Field.tpl | 6 ++++-- templates/CRM/UF/Form/Field.tpl | 1 - templates/CRM/UF/Page/Field.tpl | 7 +++++-- tests/phpunit/WebTest/Event/AddPricesetTest.php | 6 ------ 13 files changed, 48 insertions(+), 28 deletions(-) diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 912ad98c87..5dba257bf9 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -499,7 +499,9 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)), ts('Saved'), 'success'); } else { - $url = CRM_Utils_System::url('civicrm/admin/custom/group/field/add', 'reset=1&action=add&gid=' . $group->id); + // Jump directly to adding a field if popups are disabled + $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; + $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", array(1 => $group->title) ), ts('Saved'), 'success'); diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 6d77dec760..0085da3368 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -103,6 +103,7 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { CRM_Core_Action::EXPORT => array( 'name' => ts('Move'), 'url' => 'civicrm/admin/custom/group/field/move', + 'class' => 'small-popup', 'qs' => 'reset=1&fid=%%id%%', 'title' => ts('Move Custom Field'), ), diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 54be353b08..3870e0dbc5 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -86,9 +86,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $this->_fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}"); - $breadCrumb = array(array('title' => ts('Price Set Fields'), - 'url' => $url, - )); + $breadCrumb = array(array('title' => ts('Price Set Fields'), 'url' => $url)); $this->_extendComponentId = array(); $extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id'); @@ -97,6 +95,18 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } CRM_Utils_System::appendBreadCrumb($breadCrumb); + + switch ($this->_action) { + case CRM_Core_Action::ADD: + CRM_Utils_System::setTitle(ts('Add Price Field')); + break; + case CRM_Core_Action::UPDATE: + CRM_Utils_System::setTitle(ts('Edit Price Field')); + break; + case CRM_Core_Action::DELETE: + CRM_Utils_System::setTitle(ts('Delete Price Field')); + break; + } } /** diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 084a02d270..7c4fc52542 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -287,7 +287,9 @@ class CRM_Price_Form_Set extends CRM_Core_Form { CRM_Core_Session::setStatus(ts('The Set \'%1\' has been saved.', array(1 => $set->title)), ts('Saved'), 'success'); } else { - $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=add&sid=' . $set->id); + // Jump directly to adding a field if popups are disabled + $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? 'browse' : 'add'; + $url = CRM_Utils_System::url('civicrm/admin/price/field', array('reset' => 1, 'action' => $action, 'sid' => $set->id)); CRM_Core_Session::setStatus(ts("Your Set '%1' has been added. You can add fields to this set now.", array(1 => $set->title) ), ts('Saved'), 'success'); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index fb5453e592..ec19d9238b 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -78,8 +78,6 @@ class CRM_Price_Page_Field extends CRM_Core_Page { * @access public */ function &actionLinks() { if (!isset(self::$_actionLinks)) { - // helper variable for nicer formatting - $deleteExtra = ts('Are you sure you want to delete this price field?'); self::$_actionLinks = array( CRM_Core_Action::UPDATE => array( 'name' => ts('Edit Price Field'), @@ -108,7 +106,6 @@ class CRM_Price_Page_Field extends CRM_Core_Page { 'url' => 'civicrm/admin/price/field', 'qs' => 'action=delete&reset=1&sid=%%sid%%&fid=%%fid%%', 'title' => ts('Delete Price'), - 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', ), ); } diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 61a2360faa..87c276cb35 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -106,7 +106,17 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if ($this->_gid) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'title'); - CRM_Utils_System::setTitle($this->_title . ' - ' . ts('CiviCRM Profile Fields')); + switch ($this->_action) { + case CRM_Core_Action::ADD: + CRM_Utils_System::setTitle(ts('Add Profile Field')); + break; + case CRM_Core_Action::UPDATE: + CRM_Utils_System::setTitle(ts('Edit Profile Field')); + break; + case CRM_Core_Action::DELETE: + CRM_Utils_System::setTitle(ts('Delete Profile Field')); + break; + } $url = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}" diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index ed56a0c26a..d30758b344 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -368,7 +368,9 @@ class CRM_UF_Form_Group extends CRM_Core_Form { CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been saved.", array(1 => $ufGroup->title)), ts('Profile Saved'), 'success'); } else { - $url = CRM_Utils_System::url('civicrm/admin/uf/group/field/add', 'reset=1&action=add&gid=' . $ufGroup->id); + // Jump directly to adding a field if popups are disabled + $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; + $url = CRM_Utils_System::url("civicrm/admin/uf/group/field$action", 'reset=1&gid=' . $ufGroup->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts('Your CiviCRM Profile \'%1\' has been added. You can add fields to this profile now.', array(1 => $ufGroup->title) ), ts('Profile Added'), 'success'); diff --git a/templates/CRM/Custom/Page/Field.tpl b/templates/CRM/Custom/Page/Field.tpl index 24e2378a59..ceb0eb39c7 100644 --- a/templates/CRM/Custom/Page/Field.tpl +++ b/templates/CRM/Custom/Page/Field.tpl @@ -66,20 +66,19 @@ {/strip} - {else} {if $action eq 16}
- {ts}status{/ts} - {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group/field/add' q="action=add&reset=1&gid=$gid"}{/capture} - {ts 1=$groupTitle 2=$crmURL}There are no custom fields for custom group '%1', add one.{/ts} + {ts}status{/ts} + {ts 1=$groupTitle}There are no fields for custom group '%1'.{/ts}
{/if} {/if} + {/if} {include file="CRM/common/crmeditable.tpl"} diff --git a/templates/CRM/Price/Form/Field.tpl b/templates/CRM/Price/Form/Field.tpl index 5c9eb2d427..4c678b322c 100644 --- a/templates/CRM/Price/Form/Field.tpl +++ b/templates/CRM/Price/Form/Field.tpl @@ -67,7 +67,6 @@ } {/literal} -

{if $action eq 1}{ts}Add Field{/ts}{elseif $action eq 2}{ts}Edit Field{/ts}{/if}

{include file="CRM/common/formButtons.tpl" location="top"}
diff --git a/templates/CRM/Price/Page/Field.tpl b/templates/CRM/Price/Page/Field.tpl index 424be8aa98..470e131067 100644 --- a/templates/CRM/Price/Page/Field.tpl +++ b/templates/CRM/Price/Page/Field.tpl @@ -98,8 +98,10 @@ {if $action eq 16}
- {capture assign=crmURL}{crmURL p='civicrm/admin/price/field q="action=add&reset=1&sid=$sid"}{/capture} - {ts 1=$groupTitle 2=$crmURL}There are no fields for price set '%1', add one.{/ts} + {ts 1=$groupTitle 2=$crmURL}There are no fields for price set '%1'.{/ts} +
+ {/if} {/if} diff --git a/templates/CRM/UF/Form/Field.tpl b/templates/CRM/UF/Form/Field.tpl index 067cf5ddee..2b0f5dc0c4 100644 --- a/templates/CRM/UF/Form/Field.tpl +++ b/templates/CRM/UF/Form/Field.tpl @@ -23,7 +23,6 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -

{if $action eq 8}{ts}Delete Field{/ts} - {$fieldTitle}{elseif $action eq 1}{ts}Add Field{/ts}{elseif $action eq 2}{ts}Edit Field{/ts} - {$fieldTitle}{/if}

{if $action eq 8}
diff --git a/templates/CRM/UF/Page/Field.tpl b/templates/CRM/UF/Page/Field.tpl index c14f9d797a..265e19d812 100644 --- a/templates/CRM/UF/Page/Field.tpl +++ b/templates/CRM/UF/Page/Field.tpl @@ -90,8 +90,11 @@ {if $action eq 16} {capture assign=crmURL}{crmURL p="civicrm/admin/uf/group/field/add" q="reset=1&action=add&gid=$gid"}{/capture}
-
- {ts 1=$groupTitle 2=$crmURL}There are no CiviCRM Profile Fields for '%1', you can add one now.{/ts} +
+ {ts 1=$groupTitle 2=$crmURL}There are no CiviCRM Profile Fields for '%1'.{/ts} +
+ {/if} {/if} diff --git a/tests/phpunit/WebTest/Event/AddPricesetTest.php b/tests/phpunit/WebTest/Event/AddPricesetTest.php index 376aea867b..c06f2486e6 100644 --- a/tests/phpunit/WebTest/Event/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Event/AddPricesetTest.php @@ -722,12 +722,6 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { //check the delete for price field $this->openCiviPage("admin/price/field", "reset=1&action=browse&sid={$sid}"); $this->click("xpath=//table[@id='option11']/tbody/tr/td[9]/span[2]/ul/li[2]/a"); - // Check confirmation alert. - $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this price field?/", - $this->getConfirmation() - )); - $this->chooseOkOnNextConfirmation(); - $this->waitForPageToLoad($this->getTimeoutMsec()); //assert the message $this->waitForText('price_set_used_by', "it is currently in use by one or more active events or contribution pages or contributions or event templates."); -- 2.25.1