From 3e61a453a0f17e3d05d127e39cb071cba103bf58 Mon Sep 17 00:00:00 2001 From: Mathieu Lu Date: Tue, 8 Aug 2023 22:03:36 -0400 Subject: [PATCH] dev/user-interface#53 Reduce presence of Save and Done/New on forms --- CRM/Campaign/Form/Campaign.php | 8 -- CRM/Campaign/Form/Survey.php | 11 --- CRM/Contact/Form/Contact.php | 2 +- CRM/Contribute/Form/Contribution.php | 19 +++-- CRM/Contribute/Form/ContributionPage.php | 73 ++----------------- .../Form/ContributionPage/Settings.php | 9 --- CRM/Event/Form/ManageEvent.php | 6 -- CRM/Event/Form/ManageEvent/EventInfo.php | 15 +--- CRM/Event/Form/Participant.php | 2 +- CRM/Financial/Form/FinancialBatch.php | 5 -- CRM/Member/Form.php | 19 +++-- CRM/PCP/Form/Contribute.php | 3 - CRM/Pledge/Form/Pledge.php | 39 +++++----- templates/CRM/Core/Form/RecurringEntity.tpl | 5 -- .../CRM/Event/Form/ManageEvent/EventInfo.tpl | 3 - templates/CRM/Event/Form/ManageEvent/Fee.tpl | 4 - .../CRM/Event/Form/ManageEvent/Location.tpl | 8 +- .../Event/Form/ManageEvent/Registration.tpl | 3 - 18 files changed, 59 insertions(+), 175 deletions(-) diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php index 6a3931a1e9..7feef215f2 100644 --- a/CRM/Campaign/Form/Campaign.php +++ b/CRM/Campaign/Form/Campaign.php @@ -235,14 +235,6 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form { 'isDefault' => TRUE, ], ]; - // Skip this button when adding a new campaign from an entityRef - if (empty($_GET['snippet']) || empty($_GET['returnExtra'])) { - $buttons[] = [ - 'type' => 'upload', - 'name' => ts('Save and New'), - 'subName' => 'new', - ]; - } $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), diff --git a/CRM/Campaign/Form/Survey.php b/CRM/Campaign/Form/Survey.php index a15aa03dea..6c797e6026 100644 --- a/CRM/Campaign/Form/Survey.php +++ b/CRM/Campaign/Form/Survey.php @@ -101,17 +101,6 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { 'name' => ts('Save'), 'isDefault' => TRUE, ], - [ - 'type' => 'upload', - 'name' => ts('Save and Done'), - 'subName' => 'done', - ], - [ - 'type' => 'upload', - 'name' => ts('Save and Next'), - 'spacing' => '                 ', - 'subName' => 'next', - ], ]; } else { diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index b1395a93c8..a016b17d3d 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -892,7 +892,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 'isDefault' => TRUE, ], ]; - if (CRM_Core_Permission::check('add contacts')) { + if (!$this->_contactId && CRM_Core_Permission::check('add contacts')) { $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index b35e3d1f22..60ce147e90 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -884,24 +884,27 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $mailingInfo = Civi::settings()->get('mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); - $this->addButtons([ + $buttons = [ [ 'type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE, ], - [ + ]; + if (!$this->_id) { + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new', - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ]); + ]; + } + $buttons[] = [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ]; + $this->addButtons($buttons); // if contribution is related to membership or participant freeze Financial Type, Amount if ($this->_id) { diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index f09086dfd0..28a383d00f 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -34,13 +34,6 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { */ protected $_pledgeBlockID; - /** - * Are we in single form mode or wizard mode? - * - * @var bool - */ - protected $_single; - /** * Is this the first page? * @@ -48,13 +41,6 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { */ protected $_first = FALSE; - /** - * Is this the last page? - * - * @var bool - */ - protected $_last = FALSE; - /** * Store price set id. * @@ -97,10 +83,6 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { // setting title and 3rd level breadcrumb for html page if contrib page exists if ($this->_id) { $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title'); - - if ($this->_action == CRM_Core_Action::UPDATE) { - $this->_single = TRUE; - } } // CRM-16776 - show edit/copy/create buttons on Profiles Tab if user has required permission. @@ -166,57 +148,18 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { $this->addElement('hidden', 'cancelURL', $this->_cancelURL); } - if ($this->_single) { - $buttons = [ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ], - [ - 'type' => 'upload', - 'name' => ts('Save and Done'), - 'spacing' => '         ', - 'subName' => 'done', - ], - ]; - if (!$this->_last) { - $buttons[] = [ - 'type' => 'submit', - 'name' => ts('Save and Next'), - 'spacing' => '                 ', - 'subName' => 'savenext', - ]; - } - $buttons[] = [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ]; - $this->addButtons($buttons); - } - else { - $buttons = []; - if (!$this->_first) { - $buttons[] = [ - 'type' => 'back', - 'name' => ts('Previous'), - 'spacing' => '     ', - ]; - } - $buttons[] = [ + $buttons = [ + [ 'type' => 'next', - 'name' => ts('Continue'), - 'spacing' => '         ', + 'name' => ts('Save'), 'isDefault' => TRUE, - ]; - $buttons[] = [ + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ]; - - $this->addButtons($buttons); - } + ], + ]; + $this->addButtons($buttons); $session->replaceUserContext($this->_cancelURL); diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index ebf7b9cc78..c91b6e9ec6 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -389,15 +389,6 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ if ($this->_action & CRM_Core_Action::ADD) { $url = 'civicrm/admin/contribute/amount'; $urlParams = "action=update&reset=1&id={$dao->id}"; - // special case for 'Save and Done' consistency. - if ($this->controller->getButtonName('submit') == '_qf_Amount_upload_done') { - $url = 'civicrm/admin/contribute'; - $urlParams = 'reset=1'; - CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - [1 => $this->getTitle()] - ), ts('Saved'), 'success'); - } - CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams)); } parent::endPostProcess(); diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index f496bdc670..10d3018cae 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -269,12 +269,6 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { 'name' => ts('Save'), 'isDefault' => TRUE, ], - [ - 'type' => 'upload', - 'name' => ts('Save and Done'), - 'spacing' => '                 ', - 'subName' => 'done', - ], [ 'type' => 'cancel', 'name' => ts('Cancel'), diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index 9743f45c45..c2b896f001 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -244,22 +244,11 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { } $this->set('id', $event->id); - $this->postProcessHook(); if ($this->_action & CRM_Core_Action::ADD) { - $url = 'civicrm/event/manage/location'; - $urlParams = "action=update&reset=1&id={$event->id}"; - // special case for 'Save and Done' consistency. - if ('_qf_EventInfo_upload_done' === $this->controller->getButtonName('submit')) { - $url = 'civicrm/event/manage'; - $urlParams = 'reset=1'; - CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - [1 => $this->getTitle()] - ), ts('Saved'), 'success'); - } - - CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams)); + $url = CRM_Utils_System::url('civicrm/event/manage/location', "action=update&reset=1&id={$event->id}"); + CRM_Utils_System::redirect($url); } parent::endPostProcess(); diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index dbde26d55f..b828145330 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -765,7 +765,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 'civicrm/contact/search', 'civicrm/group/search', ]; - if (!in_array($path, $excludeForPaths)) { + if (!$this->getParticipantID() && !in_array($path, $excludeForPaths)) { $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), diff --git a/CRM/Financial/Form/FinancialBatch.php b/CRM/Financial/Form/FinancialBatch.php index 7ab2c65082..fbcf4bb3c7 100644 --- a/CRM/Financial/Form/FinancialBatch.php +++ b/CRM/Financial/Form/FinancialBatch.php @@ -77,11 +77,6 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { 'name' => ts('Save'), 'isDefault' => TRUE, ], - [ - 'type' => 'next', - 'name' => ts('Save and New'), - 'subName' => 'new', - ], [ 'type' => 'cancel', 'name' => ts('Cancel'), diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index f3835b5897..27906a68bc 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -346,22 +346,25 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { ]); } else { - $this->addButtons([ + $buttons = [ [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, ], - [ + ]; + if (!$this->_id) { + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ]); + ]; + }; + $buttons[] = [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ]; + $this->addButtons($buttons); } } diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index 19f4840996..890ffeb13e 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -72,11 +72,8 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { * @return void */ public function buildQuickForm() { - $this->_last = TRUE; CRM_PCP_BAO_PCP::buildPCPForm($this); - $this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this contribution page)'), NULL, ['onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);"]); - parent::buildQuickForm(); $this->addFormRule(['CRM_PCP_Form_Contribute', 'formRule'], $this); } diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index 1da913341f..c3146cd684 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -358,25 +358,28 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $uploadNames = $this->get( 'uploadNames' ); - $this->addButtons([ - [ - 'type' => 'upload', - 'name' => ts('Save'), - 'js' => ['onclick' => 'return verify( );'], - 'isDefault' => TRUE, - ], - [ - 'type' => 'upload', - 'name' => ts('Save and New'), - 'js' => ['onclick' => 'return verify( );'], - 'subName' => 'new', - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ]); + $buttons = [ + [ + 'type' => 'upload', + 'name' => ts('Save'), + 'js' => ['onclick' => 'return verify();'], + 'isDefault' => TRUE, + ], + ]; + if (!$this->_id) { + $buttons[] = [ + 'type' => 'upload', + 'name' => ts('Save and New'), + 'js' => ['onclick' => 'return verify();'], + 'subName' => 'new', + ]; + } + $buttons[] = [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ]; + $this->addButtons($buttons); $this->addFormRule(['CRM_Pledge_Form_Pledge', 'formRule'], $this); if ($this->_action & CRM_Core_Action::VIEW) { diff --git a/templates/CRM/Core/Form/RecurringEntity.tpl b/templates/CRM/Core/Form/RecurringEntity.tpl index 3567431ddf..3949653a14 100644 --- a/templates/CRM/Core/Form/RecurringEntity.tpl +++ b/templates/CRM/Core/Form/RecurringEntity.tpl @@ -13,11 +13,6 @@ {ts 1=$recurringEntityType}Repeat %1{/ts}
- {if !$recurringFormIsEmbedded} -
- {include file="CRM/common/formButtons.tpl" location="top"} -
- {/if} diff --git a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl index 3415737f7a..755d7149ec 100644 --- a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl +++ b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl @@ -10,9 +10,6 @@ {* Step 1 of New Event Wizard, and Edit Event Info form. *}
-
- {include file="CRM/common/formButtons.tpl" location="top"} -
{$form.repetition_frequency_unit.label} * {help id="id-repeats" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}
{if !empty($form.template_id)} diff --git a/templates/CRM/Event/Form/ManageEvent/Fee.tpl b/templates/CRM/Event/Form/ManageEvent/Fee.tpl index ab8e1dface..242a031eb9 100644 --- a/templates/CRM/Event/Form/ManageEvent/Fee.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Fee.tpl @@ -17,10 +17,6 @@ {/if}
-
- {include file="CRM/common/formButtons.tpl" location="top"} -
-
diff --git a/templates/CRM/Event/Form/ManageEvent/Location.tpl b/templates/CRM/Event/Form/ManageEvent/Location.tpl index 47a76afc27..019d5761e8 100644 --- a/templates/CRM/Event/Form/ManageEvent/Location.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Location.tpl @@ -13,9 +13,6 @@
-
- {include file="CRM/common/formButtons.tpl" location="top"} -
{if $locEvents}
{$form.title.label}
@@ -71,8 +68,11 @@
- {if $locEvents} +
+ {include file="CRM/common/formButtons.tpl" location="bottom"} +
+ {if $locEvents}