Skip to content

Commit

Permalink
Merge pull request #18410 from agh1/buttonrama
Browse files Browse the repository at this point in the history
Buttonrama
  • Loading branch information
colemanw authored Sep 9, 2020
2 parents e5ea8ae + 14120ba commit 6f47e02
Show file tree
Hide file tree
Showing 63 changed files with 248 additions and 303 deletions.
12 changes: 11 additions & 1 deletion CRM/Admin/Form/Preferences/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ public function buildQuickForm() {
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());

$this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
$this->addElement(
'xbutton',
'ckeditor_config',
CRM_Core_Page::crmIcon('fa-wrench') . ' ' . ts('Configure CKEditor'),
[
'type' => 'submit',
'class' => 'crm-button',
'style' => 'display:inline-block;vertical-align:middle;float:none!important;',
'value' => 1,
]
);

$editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
$this->assign('editOptions', $editOptions);
Expand Down
7 changes: 6 additions & 1 deletion CRM/Admin/Form/Setting/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public function buildQuickForm() {
$this->addFormRule(['CRM_Admin_Form_Setting_Smtp', 'formRule']);
parent::buildQuickForm();
$buttons = $this->getElement('buttons')->getElements();
$buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), ['crm-icon' => 'fa-envelope-o']);
$buttons[] = $this->createElement(
'xbutton',
$this->_testButtonName,
CRM_Core_Page::crmIcon('fa-envelope-o') . ' ' . ts('Save & Send Test Email'),
['type' => 'submit']
);
$this->getElement('buttons')->setElements($buttons);

if (!empty($setStatus)) {
Expand Down
9 changes: 7 additions & 2 deletions CRM/Batch/Form/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,14 @@ public function buildQuickForm() {
// add the force save button
$forceSave = $this->getButtonName('upload', 'force');

$this->addElement('submit',
$this->addElement('xbutton',
$forceSave,
ts('Ignore Mismatch & Process the Batch?')
ts('Ignore Mismatch & Process the Batch?'),
[
'type' => 'submit',
'value' => 1,
'class' => 'crm-button crm-button_qf_Entry_upload_force-save',
]
);

$this->addButtons([
Expand Down
8 changes: 6 additions & 2 deletions CRM/Case/Form/CaseView.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ public function buildQuickForm() {
// This button is hidden but gets clicked by javascript at
// https://github.com/civicrm/civicrm-core/blob/bd28ecf8121a85bc069cad3ab912a0c3dff8fdc5/templates/CRM/Case/Form/CaseView.js#L194
// by the onChange handler for the above timeline_id select.
$this->addElement('submit', $this->getButtonName('next'), ' ', ['class' => 'hiddenElement']);
$this->addElement('xbutton', $this->getButtonName('next'), ' ', [
'class' => 'hiddenElement',
'type' => 'submit',
]);

$this->buildMergeCaseForm();

Expand Down Expand Up @@ -523,11 +526,12 @@ public function buildMergeCaseForm() {
// This button is hidden but gets clicked by javascript at
// https://github.com/civicrm/civicrm-core/blob/bd28ecf8121a85bc069cad3ab912a0c3dff8fdc5/templates/CRM/Case/Form/CaseView.js#L55
// when the mergeCasesDialog is saved.
$this->addElement('submit',
$this->addElement('xbutton',
$this->getButtonName('next', 'merge_case'),
ts('Merge'),
[
'class' => 'hiddenElement',
'type' => 'submit',
]
);
}
Expand Down
26 changes: 20 additions & 6 deletions CRM/Contact/Form/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,17 +808,31 @@ public function buildQuickForm() {
$this->addField('image_URL', ['maxlength' => '255', 'label' => ts('Browse/Upload Image')]);

// add the dedupe button
$this->addElement('submit',
$this->addElement('xbutton',
$this->_dedupeButtonName,
ts('Check for Matching Contact(s)')
ts('Check for Matching Contact(s)'),
[
'type' => 'submit',
'value' => 1,
'class' => "crm-button crm-button{$this->_dedupeButtonName}",
]
);
$this->addElement('submit',
$this->addElement('xbutton',
$this->_duplicateButtonName,
ts('Save Matching Contact')
ts('Save Matching Contact'),
[
'type' => 'submit',
'value' => 1,
'class' => "crm-button crm-button{$this->_duplicateButtonName}",
]
);
$this->addElement('submit',
$this->addElement('xbutton',
$this->getButtonName('next', 'sharedHouseholdDuplicate'),
ts('Save With Duplicate Household')
ts('Save With Duplicate Household'),
[
'type' => 'submit',
'value' => 1,
]
);

$buttons = [
Expand Down
3 changes: 2 additions & 1 deletion CRM/Contact/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,9 @@ public function buildQuickForm() {
// also set the group title and freeze the action task with Add Members to Group
$groupValues = ['id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]];
$this->assign_by_ref('group', $groupValues);
$this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', [1 => $this->_group[$this->_amtgID]]),
$this->add('xbutton', $this->_actionButtonName, ts('Add Contacts to %1', [1 => $this->_group[$this->_amtgID]]),
[
'type' => 'submit',
'class' => 'crm-form-submit',
]
);
Expand Down
9 changes: 7 additions & 2 deletions CRM/Contact/Form/Task/AddToParentClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ public function buildQuickForm() {
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', $contactType);
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), ['class' => 'crm-form-submit']);
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), ['class' => 'crm-form-submit']);
$buttonAttrs = [
'type' => 'submit',
'class' => 'crm-form-submit',
'value' => 1,
];
$this->addElement('xbutton', $this->getButtonName('refresh'), ts('Search'), $buttonAttrs);
$this->addElement('xbutton', $this->getButtonName('cancel'), ts('Cancel'), $buttonAttrs);
$this->addButtons([
[
'type' => 'next',
Expand Down
5 changes: 4 additions & 1 deletion CRM/Contribute/Form/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ public function buildQuickForm() {
// views are implemented as frozen form
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]);
$this->addElement('xbutton', 'done', ts('Done'), [
'type' => 'button',
'onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'",
]);
}

// don't show option for contribution amounts section if membership price set
Expand Down
5 changes: 3 additions & 2 deletions CRM/Contribute/Form/ContributionPage/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ public function buildQuickForm() {
$this->assign_by_ref('colorFields', $this->_colorFields);

$this->_refreshButtonName = $this->getButtonName('refresh');
$this->addElement('submit',
$this->addElement('xbutton',
$this->_refreshButtonName,
ts('Save and Preview')
ts('Save and Preview'),
['type' => 'submit']
);
parent::buildQuickForm();
$this->addFormRule(['CRM_Contribute_Form_ContributionPage_Widget', 'formRule'], $this);
Expand Down
5 changes: 4 additions & 1 deletion CRM/Contribute/Import/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public function buildQuickForm() {

$this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);

$this->addElement('submit', 'loadMapping', ts('Load Mapping'), NULL, ['onclick' => 'checkSelect()']);
$this->addElement('xbutton', 'loadMapping', ts('Load Mapping'), [
'type' => 'submit',
'onclick' => 'checkSelect()',
]);

$this->addContactTypeSelector();
}
Expand Down
14 changes: 11 additions & 3 deletions CRM/Core/BAO/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,12 @@ public static function buildMappingForm(&$form, $mappingId, $columnNo, $blockCou
$hasRelationTypes = [];

$columnCount = $columnNo;
$form->addElement('submit', 'addBlock', ts('Also include contacts where'),
['class' => 'submit-link']
$form->addElement('xbutton', 'addBlock', ts('Also include contacts where'),
[
'type' => 'submit',
'class' => 'submit-link',
'value' => 1,
]
);

$contactTypes = CRM_Contact_BAO_ContactType::basicTypes();
Expand Down Expand Up @@ -553,7 +557,11 @@ public static function buildMappingForm(&$form, $mappingId, $columnNo, $blockCou
$form->add('text', "value[$x][$i]", '');
}

$form->addElement('submit', "addMore[$x]", ts('Another search field'), ['class' => 'submit-link']);
$form->addElement('xbutton', "addMore[$x]", ts('Another search field'), [
'type' => 'submit',
'class' => 'submit-link',
'value' => 1,
]);
}
//end of block for

Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,8 @@ public function wizardHeader($currentPageName) {
public function addWizardStyle(&$wizard) {
$wizard['style'] = [
'barClass' => '',
'stepPrefixCurrent' => '<i class="crm-i fa-chevron-right" aria-hidden="true"></i>&nbsp;',
'stepPrefixPast' => '<i class="crm-i fa-check" aria-hidden="true"></i>&nbsp;',
'stepPrefixCurrent' => '<i class="crm-i fa-chevron-right" aria-hidden="true"></i> ',
'stepPrefixPast' => '<i class="crm-i fa-check" aria-hidden="true"></i> ',
'stepPrefixFuture' => ' ',
'subStepPrefixCurrent' => '&nbsp;&nbsp;',
'subStepPrefixPast' => '&nbsp;&nbsp;',
Expand Down
24 changes: 17 additions & 7 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@ public function addButtons($params) {

$attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button);

// A lot of forms use the hacky method of looking at
// `$params['button name']` (dating back to them being inputs with a
// "value" of the button label) rather than looking at
// `$this->controller->getButtonName()`. It makes sense to give buttons a
// value by default as a precaution.
$attrs['value'] = 1;

if (!empty($button['class'])) {
$attrs['class'] .= ' ' . $button['class'];
}
Expand All @@ -686,7 +693,8 @@ public function addButtons($params) {
}

if ($button['type'] === 'reset') {
$prevnext[] = $this->createElement($button['type'], 'reset', $button['name'], $attrs);
$attrs['type'] = 'reset';
$prevnext[] = $this->createElement('xbutton', 'reset', $button['name'], $attrs);
}
else {
if (!empty($button['subName'])) {
Expand All @@ -704,12 +712,11 @@ public function addButtons($params) {
if (in_array($button['type'], ['next', 'upload', 'done']) && $button['name'] === ts('Save')) {
$attrs['accesskey'] = 'S';
}
$icon = CRM_Utils_Array::value('icon', $button, $defaultIcon);
if ($icon) {
$attrs['crm-icon'] = $icon;
}
$buttonContents = CRM_Core_Page::crmIcon($button['icon'] ?? $defaultIcon) . ' ' . $button['name'];
$buttonName = $this->getButtonName($button['type'], CRM_Utils_Array::value('subName', $button));
$prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs);
$attrs['class'] .= " crm-button crm-button-type-{$button['type']} crm-button{$buttonName}";
$attrs['type'] = 'submit';
$prevnext[] = $this->createElement('xbutton', $buttonName, $buttonContents, $attrs);
}
if (!empty($button['isDefault'])) {
$this->setDefaultAction($button['type']);
Expand Down Expand Up @@ -2448,7 +2455,10 @@ public function addTaskMenu($tasks) {
$this->_actionButtonName = $this->getButtonName('next', 'action');
}
$this->assign('actionButtonName', $this->_actionButtonName);
$this->add('submit', $this->_actionButtonName, ts('Go'), ['class' => 'hiddenElement crm-search-go-button']);
$this->add('xbutton', $this->_actionButtonName, ts('Go'), [
'type' => 'submit',
'class' => 'hiddenElement crm-search-go-button',
]);

// Radio to choose "All items" or "Selected items only"
$selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', ['checked' => 'checked']);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Smarty/plugins/block.crmButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function smarty_block_crmButton($params, $text, &$smarty) {
if (strpos($icon, 'fa-') !== 0) {
$icon = "fa-$icon";
}
$iconMarkup = "<i class='crm-i $icon' aria-hidden=\"true\"></i>&nbsp; ";
$iconMarkup = "<i class='crm-i $icon' aria-hidden=\"true\"></i> ";
}
// All other params are treated as html attributes
CRM_Utils_Array::remove($params, 'icon', 'p', 'q', 'a', 'f', 'h', 'fb', 'fe');
Expand Down
7 changes: 5 additions & 2 deletions CRM/Custom/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,13 @@ public function buildQuickForm() {
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid);
$this->addElement('button',
$this->addElement('xbutton',
'done',
ts('Done'),
['onclick' => "location.href='$url'"]
[
'type' => 'button',
'onclick' => "location.href='$url'",
]
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion CRM/Custom/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ public function buildQuickForm() {
// TODO: Is this condition ever true? Can this code be removed?
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]);
$this->addElement('xbutton', 'done', ts('Done'), [
'type' => 'button',
'onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'",
]);
}
}

Expand Down
10 changes: 7 additions & 3 deletions CRM/Custom/Form/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ public function buildQuickForm() {
'reset=1&action=browse&fid=' . $this->_fid . '&gid=' . $this->_gid,
TRUE, NULL, FALSE
);
$this->addElement('button',
$this->addElement('xbutton',
'done',
ts('Done'),
['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times']
CRM_Core_Page::crmIcon('fa-times') . ' ' . ts('Done'),
[
'type' => 'button',
'onclick' => "location.href='$url'",
'class' => 'crm-form-submit cancel',
]
);
}
}
Expand Down
8 changes: 6 additions & 2 deletions CRM/Event/Form/ManageEvent/Fee.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ public function buildQuickForm() {
$this->add('datepicker', 'discount_end_date[' . $i . ']', ts('Discount End Date'), [], FALSE, ['time' => FALSE]);
}
$_showHide->addToTemplate();
$this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'),
['class' => 'crm-form-submit cancel']
$this->addElement('xbutton', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'),
[
'type' => 'submit',
'class' => 'crm-form-submit cancel',
'value' => 1,
]
);
if (Civi::settings()->get('deferred_revenue_enabled')) {
$deferredFinancialType = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
Expand Down
12 changes: 7 additions & 5 deletions CRM/Financial/Form/BatchTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function preProcess() {
*/
public function buildQuickForm() {
if ($this->_batchStatus == 'Closed') {
$this->add('submit', 'export_batch', ts('Export Batch'));
$this->add('xbutton', 'export_batch', ts('Export Batch'), ['type' => 'submit']);
}

// do not build rest of form unless it is open/reopened batch
Expand All @@ -85,9 +85,9 @@ public function buildQuickForm() {

parent::buildQuickForm();
if (CRM_Batch_BAO_Batch::checkBatchPermission('close', $this->_values['created_id'])) {
$this->add('submit', 'close_batch', ts('Close Batch'));
$this->add('xbutton', 'close_batch', ts('Close Batch'), ['type' => 'submit']);
if (CRM_Batch_BAO_Batch::checkBatchPermission('export', $this->_values['created_id'])) {
$this->add('submit', 'export_batch', ts('Close & Export Batch'));
$this->add('xbutton', 'export_batch', ts('Close & Export Batch'), ['type' => 'submit']);
}
}

Expand All @@ -99,8 +99,9 @@ public function buildQuickForm() {
ts('Task'),
['' => ts('- actions -')] + ['Remove' => ts('Remove from Batch')]);

$this->add('submit', 'rSubmit', ts('Go'),
$this->add('xbutton', 'rSubmit', ts('Go'),
[
'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'GoRemove',
]);
Expand All @@ -123,8 +124,9 @@ public function buildQuickForm() {
ts('Task'),
['' => ts('- actions -')] + ['Assign' => ts('Assign to Batch')]);

$this->add('submit', 'submit', ts('Go'),
$this->add('xbutton', 'submit', ts('Go'),
[
'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'Go',
]);
Expand Down
3 changes: 2 additions & 1 deletion CRM/Financial/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public function buildQuickForm() {
ts('Task'),
['' => ts('- actions -')] + $batchAction);

$this->add('submit', 'submit', ts('Go'),
$this->add('xbutton', 'submit', ts('Go'),
[
'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'Go',
]);
Expand Down
Loading

0 comments on commit 6f47e02

Please sign in to comment.