CRM-16310 - implement pagination on custom field option list page
[civicrm-core.git] / templates / CRM / Custom / Page / Option.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
39de6fd5 3 | CiviCRM version 4.6 |
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>
46 <th class='nowrap crm-custom_option-weight'>{ts}Order{/ts}</th>
47 <th class='crm-custom_option-is_active nosort'>{ts}Enabled?{/ts}</th>
48 <th class='crm-custom_option-links'>&nbsp;</th>
49 <th class='hiddenElement'>&nbsp;</th>
6a488035 50 </tr>
57c9c217 51 </thead>
52 </table>
53 {literal}
54 <script type="text/javascript">
55 CRM.$(function($) {
56 var crmOptionSelector;
57
58 buildOptions();
59
60 function buildOptions() {
61 var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/optionlist" h=0 q="snippet=4&fid=$fid&gid=$gid"}'{literal};
62 var $context = $('.crm-ajax-container');
63 var ZeroRecordText = {/literal}'{ts escape="js"}None found.{/ts}'{literal};
64
65 crmOptionSelector = $('table.crm-option-selector', $context).dataTable({
66 "destroy" : true,
67 "bFilter" : false,
68 "bAutoWidth" : false,
69 "aaSorting" : [],
70 "aoColumns" : [
71 {sClass:'crm-custom_option-label'},
72 {sClass:'crm-custom_option-value'},
73 {sClass:'crm-custom_option-default_value', bSortable:false},
74 {sClass:'crm-custom_option-weight'},
75 {sClass:'crm-custom_option-is_active', bSortable:false},
76 {sClass:'crm-custom_option-links', bSortable:false},
77 {sClass:'hiddenElement', bSortable:false}
78 ],
79 "bProcessing": true,
80 "asStripClasses" : [ "odd-row", "even-row" ],
81 "sPaginationType": "full_numbers",
82 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
83 "bServerSide": true,
84 "bJQueryUI": true,
85 "sAjaxSource": sourceUrl,
86 "iDisplayLength": 10,
87 "oLanguage": {
88 "sZeroRecords": ZeroRecordText,
89 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
90 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
91 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
92 "oPaginate": {
93 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
94 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
95 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
96 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
97 }
98 },
99 "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
100 var id = $('td:last', nRow).text().split(',')[0];
101 var cl = $('td:last', nRow).text().split(',')[1];
102 $(nRow).addClass(cl).attr({id: 'OptionValue-' + id});
103 $('td:eq(2)', nRow).addClass('crmf-default_value');
104 $('td:eq(3)', nRow).addClass('crmf-weight');
105 return nRow;
106 },
6a488035 107
57c9c217 108 "fnServerData": function ( sSource, aoData, fnCallback ) {
109 $.ajax( {
110 "dataType": 'json',
111 "type": "POST",
112 "url": sSource,
113 "data": aoData,
114 "success": fnCallback
115 } );
116 }
117 });
118 }
119 });
120
121 </script>
122 {/literal}
123
124 <div class="action-link">
125 {crmButton q="reset=1&action=add&fid=$fid&gid=$gid" class="action-item" icon="circle-plus"}{ts}Add Option{/ts}{/crmButton}
126 {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
127 </div>
128 </div>
57c9c217 129 </div>
6a488035 130{/if}