<%inherit file="base.html"/>
<%def name="head()">
<script>
$(document).ready(function (){
    $("#checkAll").click(function() {  
        $("input[name='rule_item']:checkbox").each(function() { 
            $(this).prop("checked", true);  
        })    
    }); 
    //取消全选   
    $("#delCheckAll").click(function() {  
        $("input[name='rule_item']:checkbox").each(function() { 
            $(this).prop("checked",false);  
        })  
    });
});
</script>
</%def>
<%def name="body()">
    <div class="panel panel-default">
    <div class="panel-heading"><span class="glyphicon glyphicon-th"></span> ${form.title}<a class="badge pull-right" href="javascript:history.go(-1);">返回</a></div>
        <div class="panel-body">
            % if msg:
            <div class="alert alert-warning">${msg}</div>
            % endif
            <form class="form-horizontal form-well" role="form" action="${form.action}" method="post">
            ${form.render_css()}
            
            <div class="btn-group" role="group" aria-label="...">
              <button id="checkAll" type="button" class="btn btn-default">全部选择</button>
              <button id="delCheckAll" type="button" class="btn btn-default">取消选择</button>
            </div>
              <hr>
              

              % for menu in all_menus:
              <div class="panel panel-default">
                <div class="panel-heading">
                    <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 
                    ${menu['category']}</div>
                <!-- List group -->
                <ul class="list-group">
                    <div class="container-fluid">
                  % for item in sorted(menu['items'],key=lambda r:r['order']):
                  % if permit.check_open(item['path']):
                  <div class='row col-md-3'>
                      <li class="list-group-item ">
                          <!-- <font color="gray">${loop.index}&nbsp;</font> -->
                          <label>
                          <input type="checkbox" 
                          id="rule_item" 
                          name="rule_item" 
                          value="${item['path']}" ${item['path'] in rules and 'checked' or ''}>  
                           &nbsp;${item['name']}
                         </label>
                      </li>
                    </div>
                  % endif
                  % endfor
                  </div>
                </ul>
              </div>
               % endfor

        </form>
        
    </div>
</div>
</%def>