From 8f57842f7f6b3fc979a0d00d8ea3c78afdd08768 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 2 Nov 2019 11:20:38 +1100 Subject: [PATCH] Add in template file for laying out datepicker in custom fields and extract js into own template for sharing --- templates/CRM/Core/DatePickerRange.tpl | 16 +----- .../CRM/Core/DatePickerRangeCustomField.tpl | 51 +++++++++++++++++++ templates/CRM/Core/DatePickerRangejs.tpl | 40 +++++++++++++++ templates/CRM/Custom/Form/Search.tpl | 2 +- 4 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 templates/CRM/Core/DatePickerRangeCustomField.tpl create mode 100644 templates/CRM/Core/DatePickerRangejs.tpl diff --git a/templates/CRM/Core/DatePickerRange.tpl b/templates/CRM/Core/DatePickerRange.tpl index b23bf1e591..3e9f668cc7 100644 --- a/templates/CRM/Core/DatePickerRange.tpl +++ b/templates/CRM/Core/DatePickerRange.tpl @@ -44,19 +44,5 @@ {$form.$toName.html} - {literal} - - {/literal} + {include file="CRM/Core/DatePickerRangejs.tpl" relativeName=$relativeName} diff --git a/templates/CRM/Core/DatePickerRangeCustomField.tpl b/templates/CRM/Core/DatePickerRangeCustomField.tpl new file mode 100644 index 0000000000..4448fb51a0 --- /dev/null +++ b/templates/CRM/Core/DatePickerRangeCustomField.tpl @@ -0,0 +1,51 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 5 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2018 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{*this is included inside a table row*} +{assign var=relativeName value=$fieldName|cat:"_relative"} +{assign var='from' value=$from|default:'_low'} +{assign var='to' value=$to|default:'_high'} + + {if !$hideRelativeLabel} + + {$form.$relativeName.label} + + {/if} + + {$form.$relativeName.html}
+ + + {assign var=fromName value=$fieldName|cat:$from} + {$form.$fromName.label} + {$form.$fromName.html} + + + {assign var=toName value=$fieldName|cat:$to} + {$form.$toName.label} + {$form.$toName.html} + + + + {include file="CRM/Core/DatePickerRangejs.tpl" relativeName=$relativeName} diff --git a/templates/CRM/Core/DatePickerRangejs.tpl b/templates/CRM/Core/DatePickerRangejs.tpl new file mode 100644 index 0000000000..d12d899404 --- /dev/null +++ b/templates/CRM/Core/DatePickerRangejs.tpl @@ -0,0 +1,40 @@ +{* + +--------------------------------------------------------------------+ + | CiviCRM version 5 | + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC (c) 2004-2018 | + +--------------------------------------------------------------------+ + | This file is a part of CiviCRM. | + | | + | CiviCRM is free software; you can copy, modify, and distribute it | + | under the terms of the GNU Affero General Public License | + | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | + | | + | CiviCRM is distributed in the hope that it will be useful, but | + | WITHOUT ANY WARRANTY; without even the implied warranty of | + | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | See the GNU Affero General Public License for more details. | + | | + | You should have received a copy of the GNU Affero General Public | + | License and the CiviCRM Licensing Exception along | + | with this program; if not, contact CiviCRM LLC | + | at info[AT]civicrm[DOT]org. If you have questions about the | + | GNU Affero General Public License or the licensing of CiviCRM, | + | see the CiviCRM license FAQ at http://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{literal} + +{/literal} diff --git a/templates/CRM/Custom/Form/Search.tpl b/templates/CRM/Custom/Form/Search.tpl index f8b9870803..cb55931c1a 100644 --- a/templates/CRM/Custom/Form/Search.tpl +++ b/templates/CRM/Custom/Form/Search.tpl @@ -45,7 +45,7 @@ {$form.$element_name_from.html|crmAddClass:six}   {$form.$element_name_to.label}  {$form.$element_name_to.html|crmAddClass:six} {elseif $element.skip_calendar NEQ true } - {include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName=$element_name} + {include file="CRM/Core/DatePickerRangeCustomField.tpl" fieldName=$element_name hideRelativeLabel=0} {/if} {else} {$form.$element_name.label} -- 2.25.1