Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
2a73d3b0 | 5 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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 | *} | |
4e1046df | 26 | <div class="crm-submit-buttons">{crmButton p="civicrm/dashboard" q="reset=1" icon="check"}{ts}Done{/ts}{/crmButton}</div> |
6a488035 TO |
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} | |
30 | </div><br/> | |
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} | |
34 | <div class="portlet"> | |
44f15f74 | 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> |
6a488035 TO |
36 | </div> |
37 | {/foreach} | |
38 | </div> | |
39 | <br/> | |
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} | |
45 | <div class="portlet"> | |
44f15f74 | 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> |
6a488035 TO |
47 | </div> |
48 | {/foreach} | |
49 | </div> | |
50 | ||
51 | <div id="existing-dashlets-col-1" class="dash-column"> | |
52 | {foreach from=$contactDashlets.1 item=row key=dashID} | |
53 | <div class="portlet"> | |
44f15f74 | 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> |
6a488035 TO |
55 | </div> |
56 | {/foreach} | |
57 | </div> | |
58 | ||
59 | <div class="clear"></div> | |
60 | ||
61 | {literal} | |
62 | <script type="text/javascript"> | |
3cc60a06 | 63 | CRM.$(function($) { |
6a488035 | 64 | var currentReSortEvent; |
ae8f569f | 65 | $(".dash-column").sortable({ |
6a488035 TO |
66 | connectWith: '.dash-column', |
67 | update: saveSorting | |
68 | }); | |
69 | ||
ae8f569f | 70 | $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all") |
6a488035 TO |
71 | .find(".portlet-header") |
72 | .addClass("ui-widget-header ui-corner-all") | |
73 | .end() | |
74 | .find(".portlet-content"); | |
75 | ||
ae8f569f | 76 | $(".dash-column").disableSelection(); |
6a488035 TO |
77 | |
78 | function saveSorting(e, ui) { | |
79 | // this is to prevent double post call | |
80 | if (!currentReSortEvent || e.originalEvent != currentReSortEvent) { | |
81 | currentReSortEvent = e.originalEvent; | |
82 | ||
83 | // Build a list of params to post to the server. | |
84 | var params = {}; | |
85 | ||
86 | // post each columns | |
87 | dashletColumns = Array(); | |
88 | ||
89 | // build post params | |
ae8f569f CW |
90 | $('div[id^=existing-dashlets-col-]').each( function( i ) { |
91 | $(this).find('.portlet-header').each( function( j ) { | |
6a488035 TO |
92 | var elementID = this.id; |
93 | var idState = elementID.split('-'); | |
94 | params['columns[' + i + '][' + idState[0] + ']'] = idState[1]; | |
95 | }); | |
96 | }); | |
97 | ||
98 | // post to server | |
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}; | |
ce2cc43e | 102 | CRM.status({}, $.post(postUrl, params)); |
6a488035 TO |
103 | } |
104 | } | |
105 | ||
ae8f569f | 106 | $('.delete-dashlet').click( function( ) { |
ce2cc43e CW |
107 | var $dashlet = $(this).closest('.portlet-header'); |
108 | CRM.confirm({ | |
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} | |
111 | }) | |
112 | .on('crmConfirm:yes', function() { | |
113 | var dashletID = $dashlet.attr('id'); | |
114 | var idState = dashletID.split('-'); | |
6a488035 | 115 | |
ce2cc43e CW |
116 | // Build a list of params to post to the server. |
117 | var params = {dashlet_id: idState[0]}; | |
6a488035 | 118 | |
ce2cc43e CW |
119 | // delete dashlet |
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() { | |
125 | $(this).remove(); | |
126 | }); | |
127 | }); | |
6a488035 TO |
128 | }); |
129 | }); | |
130 | </script> | |
131 | {/literal} |