<!DOCTYPE html>
<html class="" lang="en">
<head  >

    {% include 'twig/common/header/include.twig' %}
    <script src="/dev/js/admin/setting.js?v=<?=_version?>" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/js/admin/global_permission.js?v=<?=_version?>" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/lib/handlebars-v4.0.10.js" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/js/handlebars.helper.js?v=<?=_version?>" type="text/javascript" charset="utf-8"></script>
    <script src="/dev/js/admin/jstree/dist/jstree.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" href="/dev/js/admin/jstree/dist/themes/default/style.min.css"/>

    <script src="/dev/lib/bootstrap-select/js/bootstrap-select.min.js"></script>
    <script src="/dev/lib/bootstrap-select/js/i18n/defaults-zh_CN.min.js"></script>
    <link href="/dev/lib/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" />
    <style>
        .text-muted {
            color: #777777;
        }
        label {
            display: inline-block;
            max-width: 100%;
            margin-bottom: 5px;
            font-weight: bold;
        }

        .modal .modal-content .modal-body {
            padding: 15px 30px 0;
        }

        .role-table {
            padding: 0 20px;
        }
    </style>

</head>
<body class="" data-group="" data-page="projects:issues:index" data-project="xphp">
{% include 'twig/common/body/script.twig' %}

<section class="has-sidebar page-layout max-sidebar">
    {% include 'twig/common/body/page-left.twig' %}

    <div class="page-layout page-content-body system-page">
{% include 'twig/common/body/header-content.twig' %}

<script>
    var findFileURL = "";
</script>
<div class="page-with-sidebar">
    {% include 'twig/admin/common-page-nav-admin.twig' %}


    <div class="content-wrapper page-with-layout-nav page-with-sub-nav">
        <div class="alert-wrapper">

            <div class="flash-container flash-container-page">
            </div>

        </div>
        <div class="container-fluid ">

            <div class="content" id="content-body">

                {% include 'twig/admin/common_system_left_nav.twig' %}
                <div class="row has-side-margin-left">
                    <div class="col-lg-12">
                        <div class="top-area">
                            <ul class="nav-links">
                                <li class="active">
                                    <a href="#">全局权限角色</a>
                                </li>
                            </ul>
                            <div class="nav-controls">
                                <div class="btn-group" role="group">
                                </div>
                            </div>
                        </div>
                        <div class="content-list">
                            <div class="bs-callout bs-callout-warning shared-runners-description hidden">
                              <p>你可以使用项目角色来将用户或用户组关联到指定项目中。 下面表格显示Masterlab中所有可用的项目角色。 这个页面可以添加,编辑以及删除项目角色。 你可以通过点击 '查看方案应用' 来查看每个项目中项目角色的权限 方案以及通知方案。</p>
                            </div>
                            <div class="row" style="margin-top: 10px">
                                <form id="form_add" class="js-requires-input" action="/admin/permission/global_permission_role_add"
                                      accept-charset="UTF-8" method="post">
                                    <div class="form-group col-md-1">
                                        <a class="btn btn-transparent" style="cursor:default">
                                        <strong class="append-right-5" >添加角色:</strong>
                                        </a>
                                    </div>
                                    <div class="form-group col-md-3">
                                        <input style="margin-left: -15px;" type="text" name="params[name]" maxlength="20" id="role_name" placeholder="角色名称" required="required" class="form-control">

                                    </div>
                                    <div class="form-group col-md-5">
                                        <input type="text" name="params[description]" id="role_description" maxlength="250" placeholder="描 述" class="form-control">

                                    </div>
                                    <div class="form-group col-md-3">
                                        <input id="btn-role_add" type="button" value="添 加" class="btn btn-create" >
                                    </div>
                                </form>
                            </div>
                            <div class="content">
                            </div>
                            <ul id="render" class="projects-list brd-bottom">
                            </ul>
                        </div>
                    </div>
                </div>


            </div>
            
        </div>
    </div>
</div>

    </div>
</section>


<div class="modal" id="modal-role_edit">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form_edit"
          action="#"
          accept-charset="UTF-8"
          method="post">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">编辑全局角色</h3>
                </div>

                <div class="modal-body">
                    <input type="hidden" name="id" id="edit_id" value="">
                    <input type="hidden" name="format" id="format" value="json">

                    <div class="form-group">
                        <label class="control-label" >角色名:</label>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="" name="params[name]" id="edit_name" value="" maxlength="20">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label" >描述:</label>
                        <div class="col-sm-5">
                            <div class="form-group">
                                <textarea placeholder="" class="form-control" rows="3" maxlength="250" name="params[description]" id="edit_description"></textarea>
                            </div>
                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button name="edit_role_save" type="button" class="btn  btn-create " id="btn-update">保存</button>
                    <a class="btn btn-cancel" data-dismiss="modal" href="#">取消</a>
                </div>
            </div>
        </div>
    </form>
</div>


<div class="modal fade" id="modal-permission_edit" data-keyboard=true role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form_permission_edit"
          action="/admin/permission/update_perm"
          accept-charset="UTF-8"
          method="post">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">权限分配</h3>
                </div>

                <div class="modal-body">
                    <input type="hidden" name="role_id" id="perm_role_id" value="">
                    <input type="hidden" name="permission_ids" id="permission_ids" value="">

                    <div class="form-group">
                        <label class="control-label">角色名称:</label>
                        <div class="col-sm-5">
                            <div class="form-group" >
                                <input type="text" class="form-control" disabled placeholder="" name="perm_role_name" id="perm_role_name" value="">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label" for="id_font_icon">权限分配:</label>
                        <div class="col-sm-6">
                            <div class="form-group" style="margin-top: 7px;">
                                <span class="text-muted"><input type="checkbox" name="" id="checkall"> <label for="checkall"><small>选中全部</small></label></span>
                                <div id="container">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button name="btn-permission_update" type="button" class="btn btn-save" id="btn-permission_update">保存</button>
                    <a  class="btn btn-cancel" data-dismiss="modal" href="#">取消</a>
                </div>
            </div>
        </div>
    </form>
</div>



<div class="modal" id="modal-role_user">
    <form class="js-quick-submit js-upload-blob-form form-horizontal" id="form-role_user"
          action="#"
          accept-charset="UTF-8"
          method="post">
        <input type="hidden" name="role_id" id="role_user-role_id" value="">
        <input type="hidden" name="format" id="format" value="json">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal" href="#">×</a>
                    <h3 class="modal-header-title">角色用户</h3>
                </div>

                <div class="modal-body min-height400">

                    <div class="form-group">
                        <label class="control-label" >请选择用户:</label>
                        <div class="row">
                            <div class="col-md-6">

                                <div class="issuable-form-select-holder">
                                    <select id="role_user_selected_user_id" name="params[select_user]"
                                            class="selectpicker"  data-live-search="true"
                                    >
                                        <option value="">选择用户</option>
                                        {% for user in users %}
                                            <option  data-content="<img width='26px' height='26px' class=' float-none' style='border-radius: 50%;' src='<?=user.avatar?>'> <?=user.display_name?>" value="<?=user.uid?>"><?=user.display_name?></option>
                                        {% endfor %}
                                    </select>
                                </div>

                            </div>
                            <div class="col-md-3">
                                <button id="btn-role_user_save" name="btn-role_user_save" type="button" class="btn " >添 加</button>
                            </div>
                        </div>
                    </div>

                    <div class="role-table">
                        <div class="form-group">
                            <table class="table ci-table">
                                <tbody id="role_user_list_render_id">

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <a class="btn btn-cancel" data-dismiss="modal" href="#">关 闭</a>
                </div>
            </div>
        </div>
    </form>
</div>
{% verbatim %}<script type="text/html"  id="role_user_list_tpl">
    {{#role_users}}
    <tr class="commit" id="role_user_id_{{id}}">
        <td>{{user_html user_id}}</td>
        <td>{{user_account_str user_id}}</td>
        <td>
            {{#if_eq root '1'}}
            {{^}}
            <a class="role_user_remove btn btn-transparent "
               href="javascript:;"
               data-id="{{id}}"
               data-user_id="{{user_id}}"
               data-role_id="{{role_id}}"
               data-value="{{user_id}}">
                <i class="fa fa-trash"></i><span class="sr-only">移除</span>
            </a>
            {{/if_eq}}
        </td>
    </tr>
    {{/role_users}}
</script>{% endverbatim %}



{% verbatim %}<script type="text/html" id="render_tpl">
    {{#roles}}
    <li class="member project_member" id="{{id}}">
        <span class="list-item-name">
            <strong>
                {{name}}
            </strong>
          <div class="hidden-xs cgray">{{description}}</div>
        </span>
        <div class="controls member-controls ">

            <a class="list_edit_perm prepend-left-10" rel="nofollow" data-id="{{id}}" data-name="{{name}}"  href="#">
                权 限
            </a>
            <a class="list_add_user prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                用 户
            </a>
            {{#if_eq is_system '1'}}
            {{^}}
            <a class="list_for_edit prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                编 辑
            </a>
            <a class="list_for_delete prepend-left-10" rel="nofollow" data-id="{{id}}"  href="#">
                删 除
            </a>
            {{/if_eq}}
        </div>
    </li>
    {{/roles}}
</script>{% endverbatim %}

<script type="text/javascript">
    var _issueConfig = {
        users:<?=users|json_encode()|raw?>
    };
    var globalPermission = null;
    var options = {

    };
    $(function() {
        globalPermission = new GlobalPermission(options);
        globalPermission.fetchPermissionGlobalRole('/admin/permission/fetch_global_permission_role','render_tpl','render');

        $('#btn-role_user_save').bind('click',function (e){
            addGlobalPermRoleUser();
        } );

    });

</script>

</body>
</html>
