Skip to content
This repository
Browse code

Make actions menu disappear if no actions.

commit 1e0e426cce47f6b5ac4a3c261d343766c824f250 1 parent 418cb69
Mike Mintz authored
11  deme_django/cms/templates/default_layout.html
@@ -214,10 +214,19 @@
214 214
 <div style="position: fixed; top: 0px; left: 215px; right: 10px; height: 50px; padding: 10px; background: #fff; border: thin ridge gray; -moz-box-shadow: 5px 3px 3px #ccc; -webkit-box-shadow: 5px 3px 3px #ccc;box-shadow: px 3px 3px #ccc;">
215 215
 
216 216
     <div style="float: right;">
217  
-        <div style="float: left;">
  217
+        <div style="float: left;" id="actions_wrapper">
218 218
             <span style="text-size: larger; font-weight: bold;">Actions:</span>
219 219
             <br />
  220
+            <div id="actions_menu_wrapper">
220 221
             {% actionsmenu %}
  222
+            </div>
  223
+            <script type="text/javascript">
  224
+            $(function(){
  225
+                if ($.trim($('#actions_menu_wrapper').text()) == '') {
  226
+                    $('#actions_wrapper').hide();
  227
+                }
  228
+            });
  229
+            </script>
221 230
         </div>
222 231
 
223 232
         {% if item %}
50  deme_django/cms/templatetags/item_tags.py
@@ -376,6 +376,34 @@ def render(self, context):
376 376
             add_authentication_method_url = reverse('item_type_url', kwargs={'viewer': 'authenticationmethod', 'action': 'new'}) + '?populate_agent=%s' % item.pk
377 377
             add_contact_method_url = reverse('item_type_url', kwargs={'viewer': 'contactmethod', 'action': 'new'}) + '?populate_agent=%s' % item.pk
378 378
 
  379
+        list_items = []
  380
+        if item:
  381
+            if agentcan_global_helper(context, 'create Membership'):
  382
+                list_items.append("""<li><a href="#" onclick="openCommentDialog('additemtocollection%s'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add this item to collection</a></li>""" % (item.pk))
  383
+            if isinstance(item, Agent):
  384
+                if agentcan_helper(context, 'add_authentication_method', item):
  385
+                    list_items.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add authentication method</a></li>' % add_authentication_method_url)
  386
+                if agentcan_helper(context, 'add_contact_method', item):
  387
+                    list_items.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add contact method</a></li>' % add_contact_method_url)
  388
+            if not context['cur_agent'].is_anonymous():
  389
+                list_items.append("""<li><a href="#" onclick="openCommentDialog('subscribe_dialog'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-mail-closed"></span>Subscribe</a></li>""")
  390
+            if agentcan_helper(context, 'edit ', item, wildcard_suffix=True):
  391
+                list_items.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-pencil"></span>Edit</a></li>' % edit_url)
  392
+            if agentcan_global_helper(context, 'create %s' % item.item_type_string):
  393
+                list_items.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-copy"></span>Copy</a></li>' % copy_url)
  394
+            if item.can_be_deleted() and agentcan_helper(context, 'delete', item):
  395
+                if item.active:
  396
+                    list_items.append("""<li><a href="#" onclick="$('#deactivate_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Deactivate"><span class="ui-icon ui-icon-trash"></span>Deactivate</a></li>""")
  397
+                else:
  398
+                    list_items.append("""<li><a href="#" onclick="$('#reactivate_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Reactivate"><span class="ui-icon ui-icon-trash"></span>Reactivate</a></li>""")
  399
+                    list_items.append("""<li><a href="#" onclick="$('#destroy_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Destroy"><span class="ui-icon ui-icon-trash"></span>Destroy</a></li>""")
  400
+        if agentcan_global_helper(context, 'create', wildcard_suffix=True):
  401
+            list_items.append("""<li><a href="#" onclick="toggleNewItemMenu('HiddenNewItemMenu'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Create"><span class="ui-icon ui-icon-circle-plus"></span>Create</a></li>""")
  402
+
  403
+        if not list_items:
  404
+            return ''
  405
+
  406
+        if item:
379 407
             from cms.forms import AjaxModelChoiceField
380 408
             result.append("""
381 409
                 <div id="subscribe_dialog" style="display: none;" title="Subscribe to '%s'">
@@ -483,27 +511,7 @@ def render(self, context):
483 511
         <div style="display: none;">
484 512
             <ul style="font-size: 85%;">
485 513
         """)
486  
-        if item:
487  
-            if agentcan_global_helper(context, 'create Membership'):
488  
-                result.append("""<li><a href="#" onclick="openCommentDialog('additemtocollection%s'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add this item to collection</a></li>""" % (item.pk))
489  
-            if isinstance(item, Agent):
490  
-                if agentcan_helper(context, 'add_authentication_method', item):
491  
-                    result.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add authentication method</a></li>' % add_authentication_method_url)
492  
-                if agentcan_helper(context, 'add_contact_method', item):
493  
-                    result.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Add contact method</a></li>' % add_contact_method_url)
494  
-            if not context['cur_agent'].is_anonymous():
495  
-                result.append("""<li><a href="#" onclick="openCommentDialog('subscribe_dialog'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-mail-closed"></span>Subscribe</a></li>""")
496  
-            if agentcan_helper(context, 'edit ', item, wildcard_suffix=True):
497  
-                result.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-pencil"></span>Edit</a></li>' % edit_url)
498  
-            if agentcan_global_helper(context, 'create %s' % item.item_type_string):
499  
-                result.append('<li><a href="%s" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-copy"></span>Copy</a></li>' % copy_url)
500  
-            if item.can_be_deleted() and agentcan_helper(context, 'delete', item):
501  
-                if item.active:
502  
-                    result.append("""<li><a href="#" onclick="$('#deactivate_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Deactivate"><span class="ui-icon ui-icon-trash"></span>Deactivate</a></li>""")
503  
-                else:
504  
-                    result.append("""<li><a href="#" onclick="$('#reactivate_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Reactivate"><span class="ui-icon ui-icon-trash"></span>Reactivate</a></li>""")
505  
-                    result.append("""<li><a href="#" onclick="$('#destroy_dialog').dialog('open'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Destroy"><span class="ui-icon ui-icon-trash"></span>Destroy</a></li>""")
506  
-        result.append("""<li><a href="#" onclick="toggleNewItemMenu('HiddenNewItemMenu'); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all" title="Destroy"><span class="ui-icon ui-icon-circle-plus"></span>Create</a></li>""")
  514
+        result.extend(list_items)
507 515
         result.append("""
508 516
             </ul>
509 517
         </div>

0 notes on commit 1e0e426

Please sign in to comment.
Something went wrong with that request. Please try again.