Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 *} | |
27 | <div class="crm-block crm-form-block"> | |
28 | <div id="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> | |
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> | |
43 | <tr id="is_multiple" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *} | |
44 | <td></td> | |
45 | <td class="html-adjust">{$form.is_multiple.html} {$form.is_multiple.label} {help id="id-is_multiple"}</td> | |
46 | </tr> | |
47 | <tr id="multiple" class="hiddenElement"> | |
48 | {*<dt>{$form.min_multiple.label}</dt><dd>{$form.min_multiple.html}</dd>*} | |
49 | <td class="label">{$form.max_multiple.label}</td> | |
50 | <td>{$form.max_multiple.html} {help id="id-max_multiple"}</td> | |
51 | </tr> | |
52 | <tr id="style" class="hiddenElement"> | |
53 | <td class="label">{$form.style.label}</td> | |
54 | <td>{$form.style.html} {help id="id-display_style"}</td> | |
55 | </tr> | |
56 | <tr class="html-adjust"> | |
57 | <td> </td> | |
58 | <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td> | |
59 | </tr> | |
60 | <tr> | |
61 | <td> </td> | |
62 | <td>{$form.collapse_adv_display.html} {$form.collapse_adv_display.label} {help id="id-collapse-adv"}</td> | |
63 | </tr> | |
64 | <tr> | |
65 | <td> </td> | |
66 | <td>{$form.is_active.html} {$form.is_active.label}</td> | |
67 | </tr> | |
68 | <tr class="html-adjust"> | |
69 | <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> | |
70 | <td>{$form.help_pre.html}</td> | |
71 | </tr> | |
72 | <tr class="html-adjust"> | |
73 | <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> | |
74 | <td>{$form.help_post.html}</td> | |
75 | </tr> | |
76 | </table> | |
77 | <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div> | |
78 | </div> | |
79 | {if $action eq 2 or $action eq 4} {* Update or View*} | |
80 | <p></p> | |
81 | <div class="action-link"> | |
82 | <a href="{crmURL p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid"}" class="button"><span>{ts}Custom Fields for this Set{/ts}</span></a> | |
83 | </div> | |
84 | {/if} | |
85 | {$initHideBlocks} | |
86 | {literal} | |
87 | <script type="text/Javascript"> | |
3cc60a06 | 88 | CRM.$(function($) { |
6a488035 | 89 | |
517184fa | 90 | showHideStyle(); |
d9aa50a7 PJ |
91 | cj('#extends_0').change(function() { |
92 | showHideStyle(); | |
93 | }); | |
6a488035 | 94 | |
d9aa50a7 PJ |
95 | var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}"; |
96 | if (isGroupEmpty) { | |
97 | showRange(true); | |
98 | } | |
99 | cj('#is_multiple').click(function() { | |
100 | showRange(); | |
101 | }); | |
6a488035 | 102 | |
d9aa50a7 PJ |
103 | function showHideStyle() { |
104 | var isShow = false; | |
105 | var extend = cj('#extends_0').val(); | |
6a488035 | 106 | |
d9aa50a7 PJ |
107 | var contactTypes = {/literal}{$contactTypes}{literal}; |
108 | var showStyle = "{/literal}{$showStyle}{literal}"; | |
109 | var showMultiple = "{/literal}{$showMultiple}{literal}"; | |
110 | var showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}"; | |
6a488035 | 111 | |
d9aa50a7 PJ |
112 | if (cj.inArray(extend, contactTypes) >= 0) { |
113 | isShow = true; | |
114 | } | |
6a488035 | 115 | |
d9aa50a7 PJ |
116 | if (isShow) { |
117 | cj("tr#style").show(); | |
118 | cj("tr#is_multiple").show(); | |
119 | if (cj('#is_multiple :checked').length) { | |
120 | cj("tr#multiple").show(); | |
121 | } | |
122 | } | |
123 | else { | |
124 | cj("tr#style").hide(); | |
125 | cj("tr#is_multiple").hide(); | |
126 | cj("tr#multiple").hide(); | |
127 | } | |
6a488035 | 128 | |
d9aa50a7 PJ |
129 | if (showStyle) { |
130 | cj("tr#style").show(); | |
131 | } | |
132 | ||
133 | if (showMultiple) { | |
134 | cj("tr#style").show(); | |
135 | cj("tr#is_multiple").show(); | |
136 | } | |
6a488035 | 137 | |
d9aa50a7 PJ |
138 | if (!showMaxMultiple) { |
139 | cj("tr#multiple").hide(); | |
140 | } | |
8539f25d | 141 | else if(cj( '#is_multiple').prop('checked')) { |
d9aa50a7 PJ |
142 | cj("tr#multiple").show(); |
143 | } | |
517184fa | 144 | } |
6a488035 | 145 | |
d9aa50a7 PJ |
146 | function showRange(onFormLoad) { |
147 | if(cj("#is_multiple :checked").length) { | |
148 | cj("tr#multiple").show(); | |
5a205b89 PJ |
149 | cj('#collapse_display').prop('checked', ''); |
150 | cj("select#style option[value='Tab with table']").prop("selected", true); | |
6a488035 | 151 | } |
d9aa50a7 | 152 | else { |
5a205b89 | 153 | cj('#collapse_display').prop('checked', 'checked'); |
d9aa50a7 PJ |
154 | cj("tr#multiple").hide(); |
155 | if (!onFormLoad) { | |
6f9cd76f | 156 | cj("select#style option[value='Inline']").prop("selected", true); |
d9aa50a7 PJ |
157 | } |
158 | } | |
159 | } | |
6a488035 | 160 | |
d9aa50a7 PJ |
161 | // In update mode, when 'extends' is set to an option which doesn't have |
162 | // any options in 2nd selector (for subtypes) - | |
163 | var subtypes = document.getElementById('extends_1'); | |
164 | if (subtypes) { | |
165 | if (subtypes.options.length <= 0) { | |
166 | subtypes.style.display = 'none'; | |
167 | } | |
168 | else { | |
169 | subtypes.style.display = 'inline'; | |
170 | } | |
171 | } | |
172 | }); | |
6a488035 | 173 | |
d9aa50a7 PJ |
174 | function warnDataLoss() { |
175 | var submittedSubtypes = cj('#extends_1').val(); | |
176 | var defaultSubtypes = {/literal}{$defaultSubtypes}{literal}; | |
6a488035 | 177 | |
d9aa50a7 PJ |
178 | var warning = false; |
179 | cj.each(defaultSubtypes, function(index, subtype) { | |
180 | if (cj.inArray(subtype, submittedSubtypes) < 0) { | |
181 | warning = true; | |
182 | } | |
183 | }); | |
6a488035 | 184 | |
d9aa50a7 PJ |
185 | if (warning) { |
186 | return confirm( 'One or more subtypes has been un-selected from the list. Any custom data associated with un-selected subtype would be removed. Click OK to proceed.' ); | |
187 | } | |
188 | return true; | |
6a488035 TO |
189 | } |
190 | </script> | |
191 | {/literal} |