From ea0f7233e206e940e3b763c6e735afeb9d964b42 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 21 Mar 2018 17:17:59 +1300 Subject: [PATCH] Sync address custom field file with main file. There is no reason for there being 2 files almost the same for custom data I plan to use this file more broadly (ie. permit custom data on other entities such as email, phone) and towards that have aligned the 2 files first. There are minor differences in display - read only fields show up as frozen for non-address & now for address too (instead of suppressed) - post help text shows as full text for address currently but after this it shows as a help-icon which can be clicked on - display improvements for file custom fields. Note that I think making address like the main file makes sense as that will be where deliberate changes have happened. --- .../Contact/Form/Edit/Address/CustomData.tpl | 3 +- .../Contact/Form/Edit/Address/CustomField.tpl | 106 ------------------ templates/CRM/Custom/Form/CustomData.tpl | 9 +- templates/CRM/Custom/Form/CustomField.tpl | 73 +----------- .../CRM/Custom/Form/Edit/CustomField.tpl | 99 ++++++++++++++++ 5 files changed, 111 insertions(+), 179 deletions(-) delete mode 100644 templates/CRM/Contact/Form/Edit/Address/CustomField.tpl create mode 100644 templates/CRM/Custom/Form/Edit/CustomField.tpl diff --git a/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl b/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl index 5f2b6a2f3d..1115cfa486 100644 --- a/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl +++ b/templates/CRM/Contact/Form/Edit/Address/CustomData.tpl @@ -36,7 +36,8 @@ {/if} {foreach from=$cd_edit.fields item=element key=field_id} - {include file="CRM/Contact/Form/Edit/Address/CustomField.tpl"} + {assign var="element_name" value=$element.element_custom_name} + {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.address.$blockId.$element_name} {/foreach}
diff --git a/templates/CRM/Contact/Form/Edit/Address/CustomField.tpl b/templates/CRM/Contact/Form/Edit/Address/CustomField.tpl deleted file mode 100644 index 6963a97027..0000000000 --- a/templates/CRM/Contact/Form/Edit/Address/CustomField.tpl +++ /dev/null @@ -1,106 +0,0 @@ -{* - +--------------------------------------------------------------------+ - | CiviCRM version 4.7 | - +--------------------------------------------------------------------+ - | 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 | - +--------------------------------------------------------------------+ -*} -{assign var="element_name" value=$element.element_custom_name} - - {if $element.help_pre} - -   - {$element.help_pre} - - {/if} - {if $element.options_per_line != 0 } - - {$form.address.$blockId.$element_name.label} - - {assign var="count" value="1"} - - - {* sort by fails for option per line. Added a variable to iterate through the element array*} - {assign var="index" value="1"} - {foreach name=outer key=key item=item from=$form.address.$blockId.$element_name} - {if $index < 10} - {assign var="index" value=`$index+1`} - {else} - - {if $count == $element.options_per_line} - - - {assign var="count" value="1"} - {else} - {assign var="count" value=`$count+1`} - {/if} - {/if} - {/foreach} - -
{$form.address.$blockId.$element_name.$key.html}
- - - - {if $element.help_post} - -   - {$element.help_post}
  - - {/if} - {else} - - {$form.address.$blockId.$element_name.label} - - {$form.address.$blockId.$element_name.html}  - - {if $element.data_type eq 'File'} - {if $element.element_value.data} -
-  {ts}Attached File{/ts}:   - {if $element.element_value.displayURL } - - - - {else} - {$element.element_value.fileName} - {/if} - {if $element.element_value.deleteURL } -
- {$element.element_value.deleteURL} - {/if} -
- {/if} - {elseif $element.html_type eq 'Autocomplete-Select'} - {assign var="element_name" value="address[$blockId][$element_name]" } - {if $element.data_type eq 'ContactReference'} - {include file="CRM/Custom/Form/ContactReference.tpl"} - {/if} - {/if} - - - - {if $element.help_post} - -  -{$element.help_post}
  - - {/if} -{/if} diff --git a/templates/CRM/Custom/Form/CustomData.tpl b/templates/CRM/Custom/Form/CustomData.tpl index d06e35c438..4403208135 100644 --- a/templates/CRM/Custom/Form/CustomData.tpl +++ b/templates/CRM/Custom/Form/CustomData.tpl @@ -30,7 +30,8 @@ {/if} {foreach from=$cd_edit.fields item=element key=field_id} - {include file="CRM/Custom/Form/CustomField.tpl"} + {assign var="element_name" value=$element.element_name} + {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} {/foreach}
@@ -54,7 +55,8 @@ {/if} {foreach from=$cd_edit.fields item=element key=field_id} - {include file="CRM/Custom/Form/CustomField.tpl"} + {assign var="element_name" value=$element.element_name} + {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} {/foreach}
@@ -82,7 +84,8 @@ {/if} {foreach from=$cd_edit.fields item=element key=field_id} - {include file="CRM/Custom/Form/CustomField.tpl"} + {assign var="element_name" value=$element.element_name} + {include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} {/foreach}
diff --git a/templates/CRM/Custom/Form/CustomField.tpl b/templates/CRM/Custom/Form/CustomField.tpl index 7dc3cd2938..0ef7da5dd7 100644 --- a/templates/CRM/Custom/Form/CustomField.tpl +++ b/templates/CRM/Custom/Form/CustomField.tpl @@ -23,73 +23,8 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{assign var="element_name" value=$element.element_name} - - {if $element.help_pre} - -   - {$element.help_pre} - - {/if} - {if $element.options_per_line != 0 } - - {$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} - - {assign var="count" value="1"} - - - {* sort by fails for option per line. Added a variable to iterate through the element array*} - {assign var="index" value="1"} - {foreach name=outer key=key item=item from=$form.$element_name} - {if $index < 10} - {assign var="index" value=`$index+1`} - {else} - - {if $count == $element.options_per_line} - - - {assign var="count" value="1"} - {else} - {assign var="count" value=`$count+1`} - {/if} - {/if} - {/foreach} - -
{$form.$element_name.$key.html}
- - +{* this file is deprecated & it's recommended to define formElement in the calling function. As of 5.1 + it is no longer used by core & is only retained in case it is used by extensions *} - {else} - - {$form.$element_name.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} - - {$form.$element_name.html}  - {if $element.data_type eq 'File'} - {if $element.element_value.data} -
-
-  {ts}Attached File{/ts}:   - {if $element.element_value.displayURL} - - - - {else} - {$element.element_value.fileName} - {/if} - {if $element.element_value.deleteURL} - - {/if} -
-
- {/if} - {elseif $element.html_type eq 'Autocomplete-Select'} - {if $element.data_type eq 'ContactReference'} - {include file="CRM/Custom/Form/ContactReference.tpl"} - {/if} - {/if} - - - - {/if} +{assign var="element_name" value=$element.element_name} +{include file="CRM/Custom/Form/Edit/CustomField.tpl" formElement=$form.$element_name} diff --git a/templates/CRM/Custom/Form/Edit/CustomField.tpl b/templates/CRM/Custom/Form/Edit/CustomField.tpl new file mode 100644 index 0000000000..9b345a10a4 --- /dev/null +++ b/templates/CRM/Custom/Form/Edit/CustomField.tpl @@ -0,0 +1,99 @@ +{* ++--------------------------------------------------------------------+ +| CiviCRM version 4.7 | ++--------------------------------------------------------------------+ +| 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 | ++--------------------------------------------------------------------+ +*} + +{if $element.help_pre} + +   + {$element.help_pre} + +{/if} +{if $element.options_per_line != 0 } + + {$formElement.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} + + {assign var="count" value="1"} + + + {* sort by fails for option per line. Added a variable to iterate through the element array*} + {assign var="index" value="1"} + {foreach name=outer key=key item=item from=$formElement} + {if $index < 10} + {assign var="index" value=`$index+1`} + {else} + + {if $count == $element.options_per_line} + + + {assign var="count" value="1"} + {else} + {assign var="count" value=`$count+1`} + {/if} + {/if} + {/foreach} + +
{$formElement.$key.html}
+ + +{else} + + {$formElement.label} + {if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if} + + + {$formElement.html}  + {if $element.data_type eq 'File'} + {if $element.element_value.data} +
+
 {ts}Attached File{/ts}:   + {if $element.element_value.displayURL} + + + + {else} + {$element.element_value.fileName} + {/if} + {if $element.element_value.deleteURL} + + + + {/if} +
+
+ {/if} + {elseif $element.html_type eq 'Autocomplete-Select'} + {if $element.data_type eq 'ContactReference'} + {assign var="element_name" value=$element.element_name} + {include file="CRM/Custom/Form/ContactReference.tpl"} + {/if} + {/if} + + +{/if} -- 2.25.1