Merge pull request #18427 from mattwire/membershipbackendcached
[civicrm-core.git] / templates / CRM / Custom / Form / Group.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
1188c7a8 3 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 4 | |
1188c7a8
TO
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
6a488035
TO
8 +--------------------------------------------------------------------+
9*}
10{* add/update/view custom data group *}
c67e7149 11<div class="help">{ts}Use Custom Field Sets to add logically related fields for a specific type of CiviCRM record (e.g. contact records, contribution records, etc.).{/ts} {help id="id-group_intro"}</div>
6a488035 12<div class="crm-block crm-form-block">
6a488035
TO
13 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
14 <table class="form-layout">
15 <tr>
16 <td class="label">{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='title' id=$gid}{/if}</td>
17 <td class="html-adjust">{$form.title.html} {help id="id-title"}</td>
18 </tr>
19 <tr>
20 <td class="label">{$form.extends.label}</td>
21 <td>{$form.extends.html} {help id="id-extends"}</td>
22 </tr>
23 <tr>
24 <td class="label">{$form.weight.label}</td>
25 <td>{$form.weight.html} {help id="id-weight"}</td>
26 </tr>
1cc99faf 27 <tr id="is_multiple_row" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *}
6a488035
TO
28 <td></td>
29 <td class="html-adjust">{$form.is_multiple.html}&nbsp;{$form.is_multiple.label} {help id="id-is_multiple"}</td>
30 </tr>
1cc99faf 31 <tr id="multiple_row" class="hiddenElement">
6a488035
TO
32 <td class="label">{$form.max_multiple.label}</td>
33 <td>{$form.max_multiple.html} {help id="id-max_multiple"}</td>
34 </tr>
1cc99faf 35 <tr id="style_row" class="hiddenElement">
6a488035
TO
36 <td class="label">{$form.style.label}</td>
37 <td>{$form.style.html} {help id="id-display_style"}</td>
38 </tr>
2af06525
CW
39 <tr id="icon_row" class="hiddenElement">
40 <td class="label">{$form.icon.label}</td>
41 <td>{$form.icon.html}</td>
42 </tr>
6a488035
TO
43 <tr class="html-adjust">
44 <td>&nbsp;</td>
45 <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td>
46 </tr>
47 <tr>
48 <td>&nbsp;</td>
49 <td>{$form.collapse_adv_display.html} {$form.collapse_adv_display.label} {help id="id-collapse-adv"}</td>
50 </tr>
51 <tr>
52 <td>&nbsp;</td>
53 <td>{$form.is_active.html} {$form.is_active.label}</td>
54 </tr>
460931ca
JP
55 <tr>
56 <td>&nbsp;</td>
edf90a59 57 <td>{$form.is_public.html} {$form.is_public.label} {help id="id-is-public"}</td>
460931ca 58 </tr>
6a488035
TO
59 <tr class="html-adjust">
60 <td class="label">{$form.help_pre.label} <!--{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='help_pre' id=$gid}{/if}-->{help id="id-help_pre"}</td>
61 <td>{$form.help_pre.html}</td>
62 </tr>
63 <tr class="html-adjust">
64 <td class="label">{$form.help_post.label} <!--{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='help_post' id=$gid}{/if}-->{help id="id-help_post"}</td>
65 <td>{$form.help_post.html}</td>
66 </tr>
67 </table>
68 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
69</div>
70{if $action eq 2 or $action eq 4} {* Update or View*}
71 <p></p>
72 <div class="action-link">
80bc2820 73 {crmButton p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid" icon="th-list"}{ts}Custom Fields for this Set{/ts}{/crmButton}
6a488035
TO
74 </div>
75{/if}
76{$initHideBlocks}
77{literal}
78<script type="text/Javascript">
3cc60a06 79CRM.$(function($) {
1cc99faf 80 var tabWithTableOption;
6a488035 81
b01812e5 82 $('#extends_0').each(showHideStyle).change(showHideStyle);
6a488035 83
8838f818 84 var isGroupEmpty = {/literal}{$isGroupEmpty|@json_encode}{literal};
d9aa50a7
PJ
85 if (isGroupEmpty) {
86 showRange(true);
87 }
1cc99faf 88 $('input#is_multiple').change(showRange);
6a488035 89
20b066e0
CW
90 // "Collapse" is a bad default for "Tab" display
91 $("select#style").change(function() {
92 if ($(this).val() == 'Tab') {
93 $('#collapse_display').prop('checked', false);
94 }
2af06525 95 $('#icon_row').toggle($(this).val() !== 'Inline');
20b066e0 96 });
2af06525 97 $('#icon_row').toggle($("select#style").val() !== 'Inline');
20b066e0
CW
98
99 /**
100 * Check if this is a contact-related set and show/hide other options accordingly
101 */
d9aa50a7 102 function showHideStyle() {
b01812e5
CW
103 var
104 extend = $(this).val(),
105 contactTypes = {/literal}{$contactTypes}{literal},
106 showStyle = "{/literal}{$showStyle}{literal}",
107 showMultiple = "{/literal}{$showMultiple}{literal}",
108 showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}",
1cc99faf 109 isContact = ($.inArray(extend, contactTypes) >= 0);
6a488035 110
1cc99faf
CW
111 if (isContact) {
112 $("tr#style_row, tr#is_multiple_row").show();
ae8f569f 113 if ($('#is_multiple :checked').length) {
1cc99faf 114 $("tr#multiple_row").show();
d9aa50a7
PJ
115 }
116 }
117 else {
1cc99faf 118 $("tr#style_row, tr#is_multiple_row, tr#multiple_row").hide();
d9aa50a7 119 }
6a488035 120
d9aa50a7 121 if (showStyle) {
1cc99faf 122 $("tr#style_row").show();
d9aa50a7
PJ
123 }
124
125 if (showMultiple) {
1cc99faf 126 $("tr#style_row, tr#is_multiple_row").show();
d9aa50a7 127 }
6a488035 128
d9aa50a7 129 if (!showMaxMultiple) {
1cc99faf 130 $("tr#multiple_row").hide();
d9aa50a7 131 }
b01812e5 132 else if ($('#is_multiple').prop('checked')) {
1cc99faf 133 $("tr#multiple_row").show();
d9aa50a7 134 }
517184fa 135 }
6a488035 136
20b066e0
CW
137 /**
138 * Check if this set supports multiple records and adjust other options accordingly
139 *
140 * @param onFormLoad
141 */
d9aa50a7 142 function showRange(onFormLoad) {
1cc99faf
CW
143 if($("#is_multiple").is(':checked')) {
144 $("tr#multiple_row").show();
145 if (onFormLoad !== true) {
146 $('#collapse_display').prop('checked', false);
2af06525 147 $("select#style").append(tabWithTableOption).val('Tab with table');
1cc99faf 148 }
2af06525 149 $('#icon_row').toggle($("select#style").val() !== 'Inline');
6a488035 150 }
d9aa50a7 151 else {
2af06525 152 $("tr#multiple_row, #icon_row").hide();
1cc99faf
CW
153 if ($("select#style").val() === 'Tab with table') {
154 $("select#style").val('Inline');
d9aa50a7 155 }
1cc99faf 156 tabWithTableOption = $("select#style option[value='Tab with table']").detach();
d9aa50a7
PJ
157 }
158 }
6a488035 159
d9aa50a7 160 // In update mode, when 'extends' is set to an option which doesn't have
20b066e0 161 // any options in 2nd selector (for subtypes)
d9aa50a7
PJ
162 var subtypes = document.getElementById('extends_1');
163 if (subtypes) {
164 if (subtypes.options.length <= 0) {
165 subtypes.style.display = 'none';
166 }
167 else {
168 subtypes.style.display = 'inline';
169 }
170 }
6a488035 171
b01812e5
CW
172 // When removing sub-types
173 $('.crm-warnDataLoss').on('click', function() {
174 var submittedSubtypes = $('#extends_1').val();
175 var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
176
177 var warning = false;
178 $.each(defaultSubtypes, function(index, subtype) {
179 if ($.inArray(subtype, submittedSubtypes) < 0) {
180 warning = true;
181 }
182 });
6a488035 183
b01812e5 184 if (warning) {
c6195a0e 185 return confirm({/literal}'{ts escape='js'}Warning: You have chosen to remove one or more subtypes. This will cause any custom data records associated with those subtypes to be removed as long as the contact does not have a contact subtype still selected.{/ts}'{literal});
d9aa50a7 186 }
b01812e5 187 return true;
d9aa50a7 188 });
b01812e5 189});
6a488035
TO
190</script>
191{/literal}