CRM-14353 - remove UF_Form_Field and UF_Form_Group formNavigate includes
[civicrm-core.git] / templates / CRM / UF / Form / Field.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 <h3>{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}</h3>
27 <div class="crm-block crm-form-block crm-uf-field-form-block">
28 {if $action eq 8}
29 <div class="messages status no-popup">
30 <div class="icon inform-icon"></div>
31 {ts}WARNING: Deleting this profile field will remove it from Profile forms and listings. If this field is used in any 'stand-alone' Profile forms, you will need to update those forms to remove this field.{/ts} {ts}Do you want to continue?{/ts}
32 </div>
33 {else}
34 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
35 <table class="form-layout-compressed">
36 <tr class="crm-uf-field-form-block-field_name">
37 <td class="label">{$form.field_name.label}</td>
38 <td>{$form.field_name.html}<br />
39 <span class="description">&nbsp;{ts}Select the type of CiviCRM record and the field you want to include in this Profile.{/ts}</span></td>
40 </tr>
41 <tr class="crm-uf-field-form-block-label">
42 <td class="label">{$form.label.label} {help id='label'}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='label' id=$fieldId}{/if}</td>
43 <td>{$form.label.html}</td>
44 </tr>
45 <tr class="crm-uf-field-form-block-is_multi">
46 <td class="label">{$form.is_multi_summary.label}{help id='is_multi_summary'}</td>
47 <td>{$form.is_multi_summary.html}<br />
48 </tr>
49 <tr class="crm-uf-field-form-block-is_required">
50 <td class="label">{$form.is_required.label} {help id='is_required'}</td>
51 <td>{$form.is_required.html}</td>
52 </tr>
53 <tr class="crm-uf-field-form-block-is_view">
54 <td class="label">{$form.is_view.label} {help id='is_view'}</td>
55 <td>{$form.is_view.html}</td>
56 </tr>
57 <tr id="profile_visibility" class="crm-uf-field-form-block-visibility">
58 <td class="label">{$form.visibility.label} {help id='visibility'}</td>
59 <td>{$form.visibility.html}</td>
60 </tr>
61 <tr class="crm-uf-field-form-block-is_searchable">
62 <td class="label"><div id="is_search_label">{$form.is_searchable.label} {help id='is_searchable'}</div></td>
63 <td><div id="is_search_html">{$form.is_searchable.html}</td>
64 </tr>
65 <tr class="crm-uf-field-form-block-in_selector">
66 <td class="label"><div id="in_selector_label">{$form.in_selector.label}{help id='in_selector'}</div></td>
67 <td><div id="in_selector_html">{$form.in_selector.html}</div></td>
68 </tr>
69 <tr class="crm-uf-field-form-block-help_pre">
70 <td class="label">{$form.help_pre.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='help_pre' id=$fieldId}{/if} {help id='help'}</td>
71 <td>{$form.help_pre.html}</td>
72 </tr>
73 <tr class="crm-uf-field-form-block-help_post">
74 <td class="label">{$form.help_post.label}{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_field' field='help_post' id=$fieldId}{/if} {help id='help'}</td>
75 <td>{$form.help_post.html}</td>
76 </tr>
77 <tr class="crm-uf-field-form-block-weight">
78 <td class="label">{$form.weight.label} {help id='weight'}</td>
79 <td>&nbsp;{$form.weight.html}</td>
80 </tr>
81 <tr class="crm-uf-field-form-block-is_active">
82 <td class="label">{$form.is_active.label} {help id='is_active'}</td>
83 <td>{$form.is_active.html}</td>
84 </tr>
85 </table>
86 {/if}
87 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
88 </div>
89
90 {$initHideBoxes}
91
92 {literal}
93 <script type="text/javascript">
94 var otherModule = new Array( );
95 {/literal}{foreach from=$otherModules item="mval" key="mkey"}{literal}
96 otherModule[{/literal}{$mkey}{literal}] = '{/literal}{$mval}{literal}';
97 {/literal}{/foreach}{literal}
98
99 CRM.$(function($) {
100 if ( $.inArray( "Profile", otherModule ) > -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
101 $('#profile_visibility').show();
102 }
103 else if( $.inArray( "Search Profile", otherModule ) > -1 ){
104 $('#profile_visibility').show();
105 $("#in_selector").prop('checked',true);
106 }
107 else if( $.inArray( "Profile", otherModule ) == -1 && $.inArray( "Search Profile", otherModule ) == -1 ){
108 $('#profile_visibility').hide();
109 }
110 $('[id^=field_name]').change(function() {
111 showLabel();
112 mixProfile();
113 });
114 });
115
116 var preHelpLabel = "";
117 function showLabel( ) {
118 if (preHelpLabel) {
119 cj(".crm-uf-field-form-block-help_pre .label").html(preHelpLabel);
120 }
121 var $elements = cj(".crm-uf-field-form-block-is_view, .crm-uf-field-form-block-is_required, .crm-uf-field-form-block-visibility, .crm-uf-field-form-block-is_searchable, .crm-uf-field-form-block-in_selector, .crm-uf-field-form-block-help_post");
122
123 $elements.show();
124
125 if (cj('[name="field_name[0]"]').val() == "Formatting") {
126 if (!preHelpLabel) {
127 preHelpLabel = cj(".crm-uf-field-form-block-help_post .label").html();
128 }
129 cj(".crm-uf-field-form-block-help_pre .label").html('<label for="help_pre">HTML Code</label>');
130 $elements.hide();
131 }
132
133 // Set the Field Label
134 var labelValue = '';
135 if (cj('[name="field_name[0]"]').val()) {
136 var fieldId = cj('[name="field_name[1]"]').val();
137 if (fieldId) {
138 labelValue = cj('[name="field_name[1]"] :selected').text().split(' :: ', 2)[0];
139 if (cj('[name="field_name[3]"]').val()) {
140 labelValue += '-' + cj('[name="field_name[3]"] :selected').text();
141 }
142 if (cj('[name="field_name[2]"]').val()) {
143 labelValue += ' (' + cj('[name="field_name[2]"] :selected').text() + ')';
144 }
145 }
146 }
147
148 cj('#label').val(labelValue);
149
150 /* Code to hide searchable attribute for no searchable fields */
151 if (document.getElementsByName("field_name[1]")[0].selectedIndex == -1) {
152 return;
153 }
154 var field2 = document.getElementsByName("field_name[1]")[0][document.getElementsByName("field_name[1]")[0].selectedIndex].text;
155 {/literal}
156 {foreach from=$noSearchable key=dnc item=val}
157 {literal}
158 if (field2 == "{/literal}{$val}{literal}") {
159 cj('#is_search_label, #is_search_html').hide();
160 }
161 {/literal}
162 {/foreach}
163 {literal}
164
165 // Code to set Profile Field help, from custom data field help
166 if (fieldId.substring(0, 7) == 'custom_') {
167 fieldId = fieldId.substring( fieldId.length, 7);
168 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/custom' h=0 }"{literal};
169 cj.post( dataUrl, { id: fieldId }, function(data) {
170 cj('#help_post').val(data.help_post);
171 cj('#help_pre').val(data.help_pre);
172 }, 'json');
173 }
174 }
175
176 {/literal}{if $action neq 8}{literal}
177 showHideSeletorSearch();
178
179 function showHideSeletorSearch() {
180 var is_search = cj('#is_search_label, #is_search_html');
181 var in_selector = cj('#in_selector_label, #in_selector_html');
182 if (cj("#visibility").val() == "User and User Admin Only") {
183 is_search.hide();
184 in_selector.hide();
185 cj("#is_searchable").prop('checked',false);
186 }
187 else {
188 if (!cj("#is_view").prop('checked')) {
189 is_search.show();
190 }
191 var fldName = cj("#field_name_1").val();
192 if (fldName == 'group' || fldName == 'tag') {
193 in_selector.hide();
194 }
195 else {
196 in_selector.show();
197 }
198 }
199 }
200
201 cj("#field_name_1").bind( 'change blur', function( ) {
202 showHideSeletorSearch( );
203 });
204
205 CRM.$(function($) {
206 cj("#field_name_1").addClass( 'huge' );
207 viewOnlyShowHide( );
208 cj("#is_view").click( function(){
209 viewOnlyShowHide();
210 });
211 });
212 {/literal}{/if}{literal}
213
214 cj("#field_name_1").change(
215 function() {
216 multiSummaryToggle(cj(this).val());
217 });
218
219 CRM.$(function($) {
220 var fieldId = cj("#field_name_1").val();
221 multiSummaryToggle(fieldId);
222 });
223
224 function multiSummaryToggle(customId) {
225 if (customId && customId.match(/custom_[\d]/)) {
226
227 var dataUrl = "{/literal}{crmURL p='civicrm/ajax/rest' q='className=CRM_UF_Page_AJAX&fnName=checkIsMultiRecord&json=1' h=0 }"{literal};
228 dataUrl = dataUrl + '&customId=' + customId;
229 cj.ajax({ url: dataUrl,
230 async: false,
231 global: false,
232 dataType : 'json',
233 success : function(response) {
234 if (response.is_multi != 0 ) {
235 cj('.crm-uf-field-form-block-is_multi').show();
236 }
237 else {
238 if (cj('#is_multi_summary').is(':checked')) {
239 cj('#is_multi_summary').prop('checked', false);
240 }
241 cj('.crm-uf-field-form-block-is_multi').hide();
242 }
243 }
244 });
245 }
246 else {
247 if (cj('#is_multi_summary').is(':checked')) {
248 cj('#is_multi_summary').prop('checked', false);
249 }
250 cj('.crm-uf-field-form-block-is_multi').hide();
251 }
252 }
253
254 function viewOnlyShowHide() {
255 var is_search = cj('#is_search_label, #is_search_html');
256 if (cj("#is_view").prop('checked')) {
257 is_search.hide();
258 cj("#is_searchable").prop('checked', false);
259 }
260 else if (cj("#visibility").val() != "User and User Admin Only") {
261 is_search.show();
262 }
263 }
264
265 //CRM-4363
266 function mixProfile( ) {
267 var allMixTypes = ["Participant", "Membership", "Contribution"];
268 var type = document.forms.Field['field_name[0]'].value;
269 var alreadyMixProfile = {/literal}{if $alreadyMixProfile}true{else}false{/if}{literal};
270 if (allMixTypes.indexOf( type ) != -1 || alreadyMixProfile) {
271 if (document.getElementById("is_searchable").checked) {
272 document.getElementById("is_searchable").checked = false;
273 if ( alreadyMixProfile ) {
274 var message = {/literal}'{ts escape="js"}You can not mark fields as Searchable in a profile that contains fields for multiple record types.{/ts}'{literal};
275 }
276 else {
277 var message = type + {/literal}'{ts escape="js"} fields can not be marked as Searchable in a profile.{/ts}'{literal};
278 }
279 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
280 }
281 if ( document.getElementById("in_selector").checked ) {
282 document.getElementById("in_selector").checked = false;
283 if ( alreadyMixProfile ) {
284 var message = {/literal}'{ts escape="js"}You can not mark a field as a Result Column in a profile that contains fields from multiple record types.{/ts}'{literal};
285 }
286 else {
287 var message = type + {/literal}'{ts escape="js"} can not be used as a Result Column for profile searches.{/ts}'{literal};
288 }
289 cj().crmError(message, {/literal}'{ts escape="js"}Error{/ts}'{literal});
290 }
291 }
292 }
293
294 function verify( ) {
295 var allMixTypes = ["Participant", "Membership", "Contribution"];
296 var type = document.forms.Field['field_name[0]'].value;
297 if ( allMixTypes.indexOf( type ) != -1 ) {
298 var message = {/literal}'{ts escape='js'}Oops. One or more fields in this profile are configured to be Searchable and / or shown in a Results Column, AND you are trying to add a {/ts}'
299 + type + '{ts} field. Profiles with a mixture of field types can not include Searchable or Results Column fields. If you save this field now, the Seachable and Results Column settings will be removed for all fields in this profile. Do you want to continue?{/ts}'{literal};
300 var ok = confirm( message );
301 if ( !ok ) {
302 return false;
303 }
304 }
305 }
306
307 </script>
308 {/literal}