Merge pull request #3495 from JohnFF/patch-5
[civicrm-core.git] / templates / CRM / Custom / Form / Group.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 {* 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}&nbsp;{$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>&nbsp;</td>
58 <td>{$form.collapse_display.html} {$form.collapse_display.label} {help id="id-collapse"}</td>
59 </tr>
60 <tr>
61 <td>&nbsp;</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>&nbsp;</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">
88 CRM.$(function($) {
89
90 showHideStyle();
91 $('#extends_0').change(function() {
92 showHideStyle();
93 });
94
95 var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}";
96 if (isGroupEmpty) {
97 showRange(true);
98 }
99 $('#is_multiple').click(function() {
100 showRange();
101 });
102
103 function showHideStyle() {
104 var isShow = false;
105 var extend = $('#extends_0').val();
106
107 var contactTypes = {/literal}{$contactTypes}{literal};
108 var showStyle = "{/literal}{$showStyle}{literal}";
109 var showMultiple = "{/literal}{$showMultiple}{literal}";
110 var showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}";
111
112 if ($.inArray(extend, contactTypes) >= 0) {
113 isShow = true;
114 }
115
116 if (isShow) {
117 $("tr#style").show();
118 $("tr#is_multiple").show();
119 if ($('#is_multiple :checked').length) {
120 $("tr#multiple").show();
121 }
122 }
123 else {
124 $("tr#style").hide();
125 $("tr#is_multiple").hide();
126 $("tr#multiple").hide();
127 }
128
129 if (showStyle) {
130 $("tr#style").show();
131 }
132
133 if (showMultiple) {
134 $("tr#style").show();
135 $("tr#is_multiple").show();
136 }
137
138 if (!showMaxMultiple) {
139 $("tr#multiple").hide();
140 }
141 else if($( '#is_multiple').prop('checked')) {
142 $("tr#multiple").show();
143 }
144 }
145
146 function showRange(onFormLoad) {
147 if($("#is_multiple :checked").length) {
148 $("tr#multiple").show();
149 $('#collapse_display').prop('checked', '');
150 $("select#style option[value='Tab with table']").prop("selected", true);
151 }
152 else {
153 $('#collapse_display').prop('checked', 'checked');
154 $("tr#multiple").hide();
155 if (!onFormLoad) {
156 $("select#style option[value='Inline']").prop("selected", true);
157 }
158 }
159 }
160
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 });
173
174 function warnDataLoss() {
175 var submittedSubtypes = cj('#extends_1').val();
176 var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
177
178 var warning = false;
179 cj.each(defaultSubtypes, function(index, subtype) {
180 if (cj.inArray(subtype, submittedSubtypes) < 0) {
181 warning = true;
182 }
183 });
184
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;
189 }
190 </script>
191 {/literal}