Ian province abbreviation patch - issue 724
[civicrm-core.git] / templates / CRM / Custom / Page / Option.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
2c4c49ca 3 | CiviCRM version 4.7 |
6a488035 4 +--------------------------------------------------------------------+
e7112fa7 5 | Copyright CiviCRM LLC (c) 2004-2015 |
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{if $action eq 1 or $action eq 2 or $action eq 4 or $action eq 8}
27 {include file="CRM/Custom/Form/Option.tpl"}
5e80a94b 28{else}
57c9c217 29 {if $reusedNames}
30 <div class="message status">
31 <div class="icon inform-icon"></div> &nbsp; {ts 1=$reusedNames}These Multiple Choice Options are shared by the following custom fields: %1{/ts}
32 </div>
33 {/if}
6a488035 34
57c9c217 35 <div id="field_page">
36 <p></p>
37 <div class="form-item">
38 {* handle enable/disable actions*}
39 {include file="CRM/common/enableDisableApi.tpl"}
40 <table class="crm-option-selector">
41 <thead>
6a488035 42 <tr class="columnheader">
57c9c217 43 <th class='crm-custom_option-label'>{ts}Label{/ts}</th>
44 <th class='crm-custom_option-value'>{ts}Value{/ts}</th>
45 <th class='crm-custom_option-default_value'>{ts}Default{/ts}</th>
c1cd77e2 46 <th class='crm-custom_option-is_active'>{ts}Enabled?{/ts}</th>
57c9c217 47 <th class='crm-custom_option-links'>&nbsp;</th>
48 <th class='hiddenElement'>&nbsp;</th>
6a488035 49 </tr>
57c9c217 50 </thead>
51 </table>
52 {literal}
53 <script type="text/javascript">
54 CRM.$(function($) {
55 var crmOptionSelector;
56
57 buildOptions();
58
59 function buildOptions() {
60 var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/optionlist" h=0 q="snippet=4&fid=$fid&gid=$gid"}'{literal};
61 var $context = $('.crm-ajax-container');
62 var ZeroRecordText = {/literal}'{ts escape="js"}None found.{/ts}'{literal};
63
64 crmOptionSelector = $('table.crm-option-selector', $context).dataTable({
65 "destroy" : true,
66 "bFilter" : false,
67 "bAutoWidth" : false,
68 "aaSorting" : [],
69 "aoColumns" : [
70 {sClass:'crm-custom_option-label'},
71 {sClass:'crm-custom_option-value'},
c1cd77e2 72 {sClass:'crm-custom_option-default_value'},
73 {sClass:'crm-custom_option-is_active'},
74 {sClass:'crm-custom_option-links'},
75 {sClass:'hiddenElement'}
57c9c217 76 ],
77 "bProcessing": true,
78 "asStripClasses" : [ "odd-row", "even-row" ],
79 "sPaginationType": "full_numbers",
80 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
81 "bServerSide": true,
82 "bJQueryUI": true,
c1cd77e2 83 "bSort" : false,
57c9c217 84 "sAjaxSource": sourceUrl,
85 "iDisplayLength": 10,
86 "oLanguage": {
87 "sZeroRecords": ZeroRecordText,
88 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
89 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
90 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
91 "oPaginate": {
92 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
93 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
94 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
95 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
96 }
97 },
98 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
99 var id = $('td:last', nRow).text().split(',')[0];
100 var cl = $('td:last', nRow).text().split(',')[1];
101 $(nRow).addClass(cl).attr({id: 'OptionValue-' + id});
667f0217
CW
102 $('td:eq(0)', nRow).wrapInner('<div style="margin-left: 10px;" class="crm-editable crmf-label" />');
103 $('td:eq(0)', nRow).prepend('<div style="cursor:move; position: relative; left: -7px;" class="icon ui-icon-arrowthick-2-n-s" />');
57c9c217 104 $('td:eq(2)', nRow).addClass('crmf-default_value');
57c9c217 105 return nRow;
106 },
46227b8d 107 "fnDrawCallback": function() {
108 // FIXME: trigger crmLoad and crmEditable would happen automatically
109 $('.crm-editable').crmEditable();
110 },
6a488035 111
57c9c217 112 "fnServerData": function ( sSource, aoData, fnCallback ) {
113 $.ajax( {
114 "dataType": 'json',
115 "type": "POST",
116 "url": sSource,
117 "data": aoData,
118 "success": fnCallback
119 } );
120 }
121 });
122 }
46227b8d 123
c1cd77e2 124
46227b8d 125 var startPosition;
126 var endPosition;
127 var gid = {/literal}'{$optionGroupID}'{literal};
128
129 $("table.crm-option-selector tbody").sortable({
667f0217 130 handle: ".ui-icon-arrowthick-2-n-s",
46227b8d 131 cursor: "move",
132 start:function(event, ui) {
133 var oSettings = $('table.crm-option-selector').dataTable().fnSettings();
134 var index = oSettings._iDisplayStart;
135 startPosition = index + ui.item.prevAll().length + 1;
136 },
137 update: function(event, ui) {
138 var oSettings = $('table.crm-option-selector').dataTable().fnSettings();
139 var index = oSettings._iDisplayStart;
140 endPosition = index + ui.item.prevAll().length + 1;
141
667f0217 142 CRM.status({}, $.getJSON(CRM.url('civicrm/ajax/reorder'), {
46227b8d 143 returnFormat:'JSON',
144 start:startPosition,
145 end: endPosition,
146 gid: gid
667f0217 147 }))
c1cd77e2 148 .success(function() {
667f0217
CW
149 $("table.crm-option-selector tbody tr").each(function(i) {
150 $(this).removeClass('odd even').addClass(i % 2 ? 'even' : 'odd');
151 });
c1cd77e2 152 });
46227b8d 153 }
154 });
57c9c217 155 });
156
157 </script>
158 {/literal}
159
160 <div class="action-link">
161 {crmButton q="reset=1&action=add&fid=$fid&gid=$gid" class="action-item" icon="circle-plus"}{ts}Add Option{/ts}{/crmButton}
162 {crmButton p="civicrm/admin/custom/group/field" q="reset=1&action=browse&gid=$gid" class="action-item cancel" icon="close"}{ts}Done{/ts}{/crmButton}
6a488035
TO
163 </div>
164 </div>
57c9c217 165 </div>
6a488035 166{/if}