Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
fee14197 | 3 | | CiviCRM version 5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
6b83d5bd | 5 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
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 | {* add/update/view custom data group *} | |
c67e7149 | 27 | <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 | 28 | <div class="crm-block crm-form-block"> |
6a488035 TO |
29 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> |
30 | <table class="form-layout"> | |
31 | <tr> | |
32 | <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> | |
33 | <td class="html-adjust">{$form.title.html} {help id="id-title"}</td> | |
34 | </tr> | |
35 | <tr> | |
36 | <td class="label">{$form.extends.label}</td> | |
37 | <td>{$form.extends.html} {help id="id-extends"}</td> | |
38 | </tr> | |
39 | <tr> | |
40 | <td class="label">{$form.weight.label}</td> | |
41 | <td>{$form.weight.html} {help id="id-weight"}</td> | |
42 | </tr> | |
1cc99faf | 43 | <tr id="is_multiple_row" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *} |
6a488035 TO |
44 | <td></td> |
45 | <td class="html-adjust">{$form.is_multiple.html} {$form.is_multiple.label} {help id="id-is_multiple"}</td> | |
46 | </tr> | |
1cc99faf | 47 | <tr id="multiple_row" class="hiddenElement"> |
6a488035 TO |
48 | <td class="label">{$form.max_multiple.label}</td> |
49 | <td>{$form.max_multiple.html} {help id="id-max_multiple"}</td> | |
50 | </tr> | |
1cc99faf | 51 | <tr id="style_row" class="hiddenElement"> |
6a488035 TO |
52 | <td class="label">{$form.style.label}</td> |
53 | <td>{$form.style.html} {help id="id-display_style"}</td> | |
54 | </tr> | |
55 | <tr class="html-adjust"> | |
56 | <td> </td> | |
57 | <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td> | |
58 | </tr> | |
59 | <tr> | |
60 | <td> </td> | |
61 | <td>{$form.collapse_adv_display.html} {$form.collapse_adv_display.label} {help id="id-collapse-adv"}</td> | |
62 | </tr> | |
63 | <tr> | |
64 | <td> </td> | |
65 | <td>{$form.is_active.html} {$form.is_active.label}</td> | |
66 | </tr> | |
460931ca JP |
67 | <tr> |
68 | <td> </td> | |
edf90a59 | 69 | <td>{$form.is_public.html} {$form.is_public.label} {help id="id-is-public"}</td> |
460931ca | 70 | </tr> |
6a488035 TO |
71 | <tr class="html-adjust"> |
72 | <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> | |
73 | <td>{$form.help_pre.html}</td> | |
74 | </tr> | |
75 | <tr class="html-adjust"> | |
76 | <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> | |
77 | <td>{$form.help_post.html}</td> | |
78 | </tr> | |
79 | </table> | |
80 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
81 | </div> | |
82 | {if $action eq 2 or $action eq 4} {* Update or View*} | |
83 | <p></p> | |
84 | <div class="action-link"> | |
80bc2820 | 85 | {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 |
86 | </div> |
87 | {/if} | |
88 | {$initHideBlocks} | |
89 | {literal} | |
90 | <script type="text/Javascript"> | |
3cc60a06 | 91 | CRM.$(function($) { |
1cc99faf | 92 | var tabWithTableOption; |
6a488035 | 93 | |
b01812e5 | 94 | $('#extends_0').each(showHideStyle).change(showHideStyle); |
6a488035 | 95 | |
8838f818 | 96 | var isGroupEmpty = {/literal}{$isGroupEmpty|@json_encode}{literal}; |
d9aa50a7 PJ |
97 | if (isGroupEmpty) { |
98 | showRange(true); | |
99 | } | |
1cc99faf | 100 | $('input#is_multiple').change(showRange); |
6a488035 | 101 | |
20b066e0 CW |
102 | // "Collapse" is a bad default for "Tab" display |
103 | $("select#style").change(function() { | |
104 | if ($(this).val() == 'Tab') { | |
105 | $('#collapse_display').prop('checked', false); | |
106 | } | |
107 | }); | |
108 | ||
109 | /** | |
110 | * Check if this is a contact-related set and show/hide other options accordingly | |
111 | */ | |
d9aa50a7 | 112 | function showHideStyle() { |
b01812e5 CW |
113 | var |
114 | extend = $(this).val(), | |
115 | contactTypes = {/literal}{$contactTypes}{literal}, | |
116 | showStyle = "{/literal}{$showStyle}{literal}", | |
117 | showMultiple = "{/literal}{$showMultiple}{literal}", | |
118 | showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}", | |
1cc99faf | 119 | isContact = ($.inArray(extend, contactTypes) >= 0); |
6a488035 | 120 | |
1cc99faf CW |
121 | if (isContact) { |
122 | $("tr#style_row, tr#is_multiple_row").show(); | |
ae8f569f | 123 | if ($('#is_multiple :checked').length) { |
1cc99faf | 124 | $("tr#multiple_row").show(); |
d9aa50a7 PJ |
125 | } |
126 | } | |
127 | else { | |
1cc99faf | 128 | $("tr#style_row, tr#is_multiple_row, tr#multiple_row").hide(); |
d9aa50a7 | 129 | } |
6a488035 | 130 | |
d9aa50a7 | 131 | if (showStyle) { |
1cc99faf | 132 | $("tr#style_row").show(); |
d9aa50a7 PJ |
133 | } |
134 | ||
135 | if (showMultiple) { | |
1cc99faf | 136 | $("tr#style_row, tr#is_multiple_row").show(); |
d9aa50a7 | 137 | } |
6a488035 | 138 | |
d9aa50a7 | 139 | if (!showMaxMultiple) { |
1cc99faf | 140 | $("tr#multiple_row").hide(); |
d9aa50a7 | 141 | } |
b01812e5 | 142 | else if ($('#is_multiple').prop('checked')) { |
1cc99faf | 143 | $("tr#multiple_row").show(); |
d9aa50a7 | 144 | } |
517184fa | 145 | } |
6a488035 | 146 | |
20b066e0 CW |
147 | /** |
148 | * Check if this set supports multiple records and adjust other options accordingly | |
149 | * | |
150 | * @param onFormLoad | |
151 | */ | |
d9aa50a7 | 152 | function showRange(onFormLoad) { |
1cc99faf CW |
153 | if($("#is_multiple").is(':checked')) { |
154 | $("tr#multiple_row").show(); | |
155 | if (onFormLoad !== true) { | |
156 | $('#collapse_display').prop('checked', false); | |
157 | $("select#style").append(tabWithTableOption); | |
158 | $("select#style").val('Tab with table'); | |
159 | } | |
6a488035 | 160 | } |
d9aa50a7 | 161 | else { |
1cc99faf CW |
162 | $("tr#multiple_row").hide(); |
163 | if ($("select#style").val() === 'Tab with table') { | |
164 | $("select#style").val('Inline'); | |
d9aa50a7 | 165 | } |
1cc99faf | 166 | tabWithTableOption = $("select#style option[value='Tab with table']").detach(); |
d9aa50a7 PJ |
167 | } |
168 | } | |
6a488035 | 169 | |
d9aa50a7 | 170 | // In update mode, when 'extends' is set to an option which doesn't have |
20b066e0 | 171 | // any options in 2nd selector (for subtypes) |
d9aa50a7 PJ |
172 | var subtypes = document.getElementById('extends_1'); |
173 | if (subtypes) { | |
174 | if (subtypes.options.length <= 0) { | |
175 | subtypes.style.display = 'none'; | |
176 | } | |
177 | else { | |
178 | subtypes.style.display = 'inline'; | |
179 | } | |
180 | } | |
6a488035 | 181 | |
b01812e5 CW |
182 | // When removing sub-types |
183 | $('.crm-warnDataLoss').on('click', function() { | |
184 | var submittedSubtypes = $('#extends_1').val(); | |
185 | var defaultSubtypes = {/literal}{$defaultSubtypes}{literal}; | |
186 | ||
187 | var warning = false; | |
188 | $.each(defaultSubtypes, function(index, subtype) { | |
189 | if ($.inArray(subtype, submittedSubtypes) < 0) { | |
190 | warning = true; | |
191 | } | |
192 | }); | |
6a488035 | 193 | |
b01812e5 | 194 | if (warning) { |
c6195a0e | 195 | 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 | 196 | } |
b01812e5 | 197 | return true; |
d9aa50a7 | 198 | }); |
b01812e5 | 199 | }); |
6a488035 TO |
200 | </script> |
201 | {/literal} |