2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2019 |
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 {if $action eq 1 or $action eq 2 or $action eq 8}
27 {include file="CRM/Admin/Form/Navigation.tpl"}
30 {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"}
33 <div class="crm-block crm-content-block">
34 <div id="new-menu-item">
35 {crmButton p="civicrm/admin/menu" q="action=add&reset=1" id="newMenuItem" icon="crm-i fa-plus-circle" style="margin-left: 6px;"}{ts}Add Menu Item{/ts}{/crmButton}
36 <span id="reset-menu" class="status" style="display:none">
37 {capture assign=rebuildURL}{crmURL p='civicrm/admin/menu' q="reset=1"}{/capture}
38 {ts 1=$rebuildURL}<a href='%1' title="Reload page"><strong>Click here</strong></a> to reload the page and see your changes in the menu bar above.{/ts}
41 <div class="spacer"></div>
42 <div style="padding-left: 25px;"><div class="crm-logo-sm"></div></div>
43 <div id="navigation-tree" class="navigation-tree" style="height:auto; border-collapse:separate; background-color:#FFFFFF;"></div>
44 <div class="spacer"></div>
46 <a href="#" class="nav-reset crm-hover-button">
47 {* TODO: fa-broom would be better, but not implemented yet. https://github.com/FortAwesome/Font-Awesome/issues/239 *}
48 <i class="crm-i fa-undo"></i> {ts}Cleanup reports menu{/ts}
51 <div class="spacer"></div>
54 <script type="text/javascript">
56 $("#navigation-tree").jstree({
57 plugins: ["dnd", "contextmenu"],
59 data: function(tree, callBack) {
60 CRM.api3('Navigation', 'get', {
61 domain_id: {/literal}{$config->domainID()}{literal},
62 options: {limit: 0, sort: 'weight'},
63 return: ['label', 'parent_id', 'icon'],
66 }).done(function(data) {
68 $.each(data.values, function(key, value) {
72 icon: value.icon || false,
73 parent: value.parent_id || '#'
79 progressive_render: true,
86 items: function (node, callBack) {
89 label: "{/literal}{ts escape='js'}Add{/ts}{literal}",
90 icon: 'crm-i fa-plus',
94 label: "{/literal}{ts escape='js'}Edit{/ts}{literal}",
95 icon: 'crm-i fa-pencil',
99 label: "{/literal}{ts escape='js'}Delete{/ts}{literal}",
100 icon: 'crm-i fa-trash',
101 action: function (menu) {
102 var nodeID = menu.reference.attr('id').replace('_anchor', ''),
103 node = $("#navigation-tree").jstree(true).get_node(nodeID),
104 menuName = node.text;
105 var deleteMsg = {/literal}"{ts escape='js'}Are you sure you want to delete this menu item:{/ts} " + '"'{literal} + menuName + {/literal}'"? {ts escape='js'}This action cannot be undone.{/ts}'{literal};
106 if (node.children.length) {
107 deleteMsg += {/literal}"<br /><br />" + ts('{ts escape='js' 1='<strong>%1</strong>'}%1 sub-menu items will also be deleted.{/ts}'{literal}, {1: node.children.length});
109 CRM.confirm({message: deleteMsg})
110 .on('crmConfirm:yes', function() {
111 CRM.api3('Navigation', 'delete', {id: nodeID}, true);
112 $("#navigation-tree").jstree(true).delete_node(menu.reference.closest('li'));
113 $("#reset-menu").show();
121 }).on("move_node.jstree", function (e, data) {
122 var nodeID = data.node.id;
123 var refID = data.parent === '#' ? '' : data.parent;
124 var ps = data.position;
125 var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
126 CRM.status({}, $.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps));
127 $("#reset-menu").show();
130 function editForm(menu) {
131 var nodeID = menu.reference.attr('id').replace('_anchor', ''),
132 action = menu.item.icon === 'crm-i fa-pencil' ? 'update' : 'add',
133 args = {reset: 1, action: action};
134 if (action === 'add') {
135 args.parent_id = nodeID;
139 CRM.loadForm(CRM.url('civicrm/admin/menu', args)).on('crmFormSuccess', function() {
140 $("#navigation-tree").jstree(true).refresh();
141 $("#reset-menu").show();
145 $('#new-menu-item a.button')
146 .on('click', CRM.popup)
147 .on('crmPopupFormSuccess', function() {
148 $("#navigation-tree").jstree(true).refresh();
149 $("#reset-menu").show();
152 $('a.nav-reset').on('click', function(e) {
155 title: $(this).text(),
156 message: '{/literal}{ts escape='js'}This will add links for all currently active reports to the "Reports" menu under the relevant component. If you have added report instances to other menus, they will be moved to "Reports". Are you sure?{/ts}{literal}'
158 .on('crmConfirm:yes', function() {
159 $('#crm-container').block();
160 CRM.api3('Navigation', 'reset', {'for': 'report'}, true)
162 $('#crm-container').unblock();
163 $("#navigation-tree").jstree(true).refresh();
164 $("#reset-menu").show();