<%@ page language="java" %> 
<%@taglib uri="/WEB-INF/tld/com_iplanet_jato/jato.tld" prefix="jato"%> 
<%@taglib uri="/WEB-INF/tld/com_sun_web_ui/cc.tld" prefix="cc"%>
<%@taglib uri="/WEB-INF/lib/sa.tld" prefix="sa"%>

<jato:useViewBean className="com.sun.netstorage.mgmt.fm.storade.ui.viewbeans.topology.ListSnapshotsViewBean">

<%
  String isPrivilegedUser = (String)session.getAttribute("storade.privilegedRole");
  if (isPrivilegedUser == null) isPrivilegedUser = "false";
%>


<script language="javascript">
// This function will toggle the disabled state of action buttons
// depending on single or multiple selections.

function toggleDisabledState() {
   // Action button and menu names.
   var delButton = "ListSnapshots.deleteButton";
   var viewButton = "ListSnapshots.viewButton";
   var compareButton = "ListSnapshots.compareButton";
	
   // Element name (prefix) of selection checkbox/radiobutton.
   var elementName = "ListSnapshots.SnapshotsTable.SelectionCheckbox";
  
   // Document form.
   var form = document.snapshotsForm;

   // Flag indicating to disable action button and menu options.
   var disabled = true;
   var numChecked = 0;
   // Set flags according to single or multiple selections.
   for (i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if (e.name.indexOf(elementName) != -1) {
             if (e.checked) {
                disabled = false;
                numChecked ++;
            }
        }
   }
  
   // Toggle action button disabled state.
   ccSetButtonDisabled(delButton, "snapshotsForm", disabled);

   // do we have the role to delete a snapshot?
   if (!('true' == '<%=isPrivilegedUser%>')) {
     ccSetButtonDisabled(delButton, "snapshotsForm", true);
   }

   if(numChecked > 1) {
      ccSetButtonDisabled(viewButton, "snapshotsForm", true);
   } else {
      ccSetButtonDisabled(viewButton, "snapshotsForm", disabled);
   }

   if(numChecked != 2) {
      ccSetButtonDisabled(compareButton, "snapshotsForm", true);
   } else {
      ccSetButtonDisabled(compareButton, "snapshotsForm", disabled);
   }
}
</script>


<!-- Masthead -->
<sa:primarymasthead name="Masthead" showDefaultPageTitle="simple">

<jato:form name="snapshotsForm" method="post">

<cc:spacer name="spacer" height="10" newline="true"/>

<!-- table of snapshots -->
<cc:actiontable
 name="SnapshotsTable"
 bundleID="appBundle"
 title="snapshots.table.title"
 summary="snapshots.table.summary"
 empty="snapshots.table.empty"
 selectionType="multiple"
 selectionJavascript="toggleDisabledState()"
 showAdvancedSortingIcon="false"
 showLowerActions="false"
 showPaginationControls="true"
 showPaginationIcon="true"
 showSelectionIcons="true"
 showSortingRow="true"
 maxRows="25"
 page="1" />

</jato:form>

</sa:primarymasthead>

</jato:useViewBean>


