2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2018 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
26 <div class="crm-submit-buttons">{crmButton p="civicrm/dashboard" q="reset=1" icon="check"}{ts}Done{/ts}{/crmButton}</div>
27 <div id="help" style="padding: 1em;">
28 {ts}Available dashboard elements - dashlets - are displayed in the dark gray top bar. Drag and drop dashlets onto the left or right columns below to add them to your dashboard. Changes are automatically saved. Click 'Done' to return to the normal dashboard view.{/ts}
29 {help id="id-dash_configure" file="CRM/Contact/Page/Dashboard.hlp" admin=$admin}
31 <div class="dashlets-header">{ts}Available Dashlets{/ts}</div>
32 <div id="available-dashlets" class="dash-column">
33 {foreach from=$availableDashlets item=row key=dashID}
35 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved} <a class="crm-i fa-times delete-dashlet"></a>{/if}</div>
40 <div class="clear"></div>
41 <div id="dashlets-header-col-0" class="dashlets-header">{ts}Left Column{/ts}</div>
42 <div id="dashlets-header-col-1" class="dashlets-header">{ts}Right Column{/ts}</div>
43 <div id="existing-dashlets-col-0" class="dash-column">
44 {foreach from=$contactDashlets.0 item=row key=dashID}
46 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved} <a class="crm-i fa-times delete-dashlet"></a>{/if}</div>
51 <div id="existing-dashlets-col-1" class="dash-column">
52 {foreach from=$contactDashlets.1 item=row key=dashID}
54 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved} <a class="crm-i fa-times delete-dashlet"></a>{/if}</div>
59 <div class="clear"></div>
62 <script type="text/javascript">
64 var currentReSortEvent;
65 $(".dash-column").sortable({
66 connectWith: '.dash-column',
70 $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
71 .find(".portlet-header")
72 .addClass("ui-widget-header ui-corner-all")
74 .find(".portlet-content");
76 $(".dash-column").disableSelection();
78 function saveSorting(e, ui) {
79 // this is to prevent double post call
80 if (!currentReSortEvent || e.originalEvent != currentReSortEvent) {
81 currentReSortEvent = e.originalEvent;
83 // Build a list of params to post to the server.
87 dashletColumns = Array();
90 $('div[id^=existing-dashlets-col-]').each( function( i ) {
91 $(this).find('.portlet-header').each( function( j ) {
92 var elementID = this.id;
93 var idState = elementID.split('-');
94 params['columns[' + i + '][' + idState[0] + ']'] = idState[1];
99 var postUrl = {/literal}"{crmURL p='civicrm/ajax/dashboard' h=0 }"{literal};
100 params['op'] = 'save_columns';
101 params['key'] = {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal};
102 CRM.status({}, $.post(postUrl, params));
106 $('.delete-dashlet').click( function( ) {
107 var $dashlet = $(this).closest('.portlet-header');
109 title: {/literal}'{ts escape="js"}Remove Permanently?{/ts}'{literal},
110 message: {/literal}'{ts escape="js"}Do you want to remove this dashlet as an "Available Dashlet", AND delete it from all user dashboards?{/ts}'{literal}
112 .on('crmConfirm:yes', function() {
113 var dashletID = $dashlet.attr('id');
114 var idState = dashletID.split('-');
116 // Build a list of params to post to the server.
117 var params = {dashlet_id: idState[0]};
120 var postUrl = {/literal}"{crmURL p='civicrm/ajax/dashboard' h=0 }"{literal};
121 params['op'] = 'delete_dashlet';
122 params['key'] = {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal};
123 CRM.status({}, $.post(postUrl, params));
124 $dashlet.parent().fadeOut('fast', function() {