commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / templates / CRM / Contact / Page / Dashlet.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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 <div id="help" style="padding: 1em;">
27 {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}
28 {help id="id-dash_configure" file="CRM/Contact/Page/Dashboard.hlp" admin=$admin}
29 </div><br/>
30 <div class="dashlets-header">{ts}Available Dashlets{/ts}</div>
31 <div id="available-dashlets" class="dash-column">
32 {foreach from=$availableDashlets item=row key=dashID}
33 <div class="portlet">
34 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved}&nbsp;<a class="ui-icon ui-icon-close delete-dashlet"></a>{/if}</div>
35 </div>
36 {/foreach}
37 </div>
38 <br/>
39 <div class="clear"></div>
40 <div id="dashlets-header-col-0" class="dashlets-header">{ts}Left Column{/ts}</div>
41 <div id="dashlets-header-col-1" class="dashlets-header">{ts}Right Column{/ts}</div>
42 <div id="existing-dashlets-col-0" class="dash-column">
43 {foreach from=$contactDashlets.0 item=row key=dashID}
44 <div class="portlet">
45 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved}&nbsp;<a class="ui-icon ui-icon-close delete-dashlet"></a>{/if}</div>
46 </div>
47 {/foreach}
48 </div>
49
50 <div id="existing-dashlets-col-1" class="dash-column">
51 {foreach from=$contactDashlets.1 item=row key=dashID}
52 <div class="portlet">
53 <div class="portlet-header" id="{$dashID}">{$row.label}{if $admin and !$row.is_reserved}&nbsp;<a class="ui-icon ui-icon-close delete-dashlet"></a>{/if}</div>
54 </div>
55 {/foreach}
56 </div>
57
58 <div class="clear"></div>
59
60 {literal}
61 <script type="text/javascript">
62 CRM.$(function($) {
63 var currentReSortEvent;
64 $(".dash-column").sortable({
65 connectWith: '.dash-column',
66 update: saveSorting
67 });
68
69 $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
70 .find(".portlet-header")
71 .addClass("ui-widget-header ui-corner-all")
72 .end()
73 .find(".portlet-content");
74
75 $(".dash-column").disableSelection();
76
77 function saveSorting(e, ui) {
78 // this is to prevent double post call
79 if (!currentReSortEvent || e.originalEvent != currentReSortEvent) {
80 currentReSortEvent = e.originalEvent;
81
82 // Build a list of params to post to the server.
83 var params = {};
84
85 // post each columns
86 dashletColumns = Array();
87
88 // build post params
89 $('div[id^=existing-dashlets-col-]').each( function( i ) {
90 $(this).find('.portlet-header').each( function( j ) {
91 var elementID = this.id;
92 var idState = elementID.split('-');
93 params['columns[' + i + '][' + idState[0] + ']'] = idState[1];
94 });
95 });
96
97 // post to server
98 var postUrl = {/literal}"{crmURL p='civicrm/ajax/dashboard' h=0 }"{literal};
99 params['op'] = 'save_columns';
100 params['key'] = {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal};
101 $.post( postUrl, params, function(response, status) {
102 // TO DO show done / disable escape action
103 });
104 }
105 }
106
107 $('.delete-dashlet').click( function( ) {
108 var 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};
109 if ( confirm( message) ) {
110 var dashletID = $(this).parent().attr('id');
111 var idState = dashletID.split('-')
112
113 // Build a list of params to post to the server.
114 var params = {};
115
116 params['dashlet_id'] = idState[0];
117
118 // delete dashlet
119 var postUrl = {/literal}"{crmURL p='civicrm/ajax/dashboard' h=0 }"{literal};
120 params['op'] = 'delete_dashlet';
121 params['key'] = {/literal}"{crmKey name='civicrm/ajax/dashboard'}"{literal};
122 $.post( postUrl, params, function(response, status) {
123 // delete dom object
124 $('#' + dashletID ).parent().remove();
125 });
126 }
127 });
128 });
129 </script>
130 {/literal}