<!DOCTYPE html>
<html lang="zh-CN">
<head>
{{template "widgets/head.html" .}}
    <style>a.btn-danger{color: #ffffff !important;}</style>
</head>
<body>
<div class="manual-reader">
    {{template "widgets/header.html" .}}
    <div class="container manual-body">
        <div class="row">
            <div class="page-left">
                {{template "manager/menu.html" .}}
            </div>
            <div class="page-right">
                <div class="m-box">
                    <div class="box-head">
                        <strong class="box-title">书籍列表</strong>
                        <a href="javascript:void(0);" data-toggle="modal" data-target="#deleteBooksModal" class="btn btn-danger pull-right">批量删除</a>
                    </div>
                    <ul class="nav nav-tabs" style="margin-top: 15px;">
                        <li {{if ne .Private 1}}class="active"{{end}}><a href="{{urlfor "ManagerController.Books"}}">公开书籍</a></li>
                        <li {{if eq .Private 1}}class="active"{{end}}><a href="{{urlfor "ManagerController.Books"}}?private=1">私有书籍</a></li>
                    </ul>
                    <br>
                    <form class="bs-example bs-example-form" role="form">
                        <div class="input-group">
                            <input type="hidden" name="private" value="{{.Private}}">
                            <input type="text" name="wd" value="{{.Wd}}" placeholder="搜索书籍" class="form-control">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="submit">搜索</button>
                            </span>
                        </div>
                    </form>
                </div>
                <div class="box-body" id="bookList">
                    <div class="book-list">

                        {{range $index,$item := .Lists}}
                        <div class="list-item">
                                <div class="book-title">
                                    <div class="pull-left">
                                        <a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" title="查看文档" data-toggle="tooltip">
                                            {{if eq $item.PrivatelyOwned 0}}
                                            <i class="fa fa-unlock" aria-hidden="true"></i>
                                            {{else}}
                                            <i class="fa fa-lock" aria-hidden="true"></i>
                                            {{end}}
                                            {{$item.BookName}}
                                        </a>
                                    </div>

                                    <div class="pull-right">
                                        <a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" title="查看文档" class="btn btn-default" data-toggle="tooltip" target="_blank"><i class="fa fa-eye"></i> 查看文档</a>
                                        <a href="{{urlfor "DocumentController.Edit" ":key" $item.Identify ":id" ""}}" title="编辑文档" class="btn btn-default" data-toggle="tooltip" target="_blank"><i class="fa fa-edit" aria-hidden="true"></i> 编辑文档</a>
                                        <a href="{{urlfor "ManagerController.EditBook" ":key" $item.Identify}}" title="书籍设置" class="btn btn-default" data-toggle="tooltip" target="_blank"><i class="fa fa-cogs" aria-hidden="true"></i> 书籍设置</a>
                                        <a href="javascript:void(0);" data-identify="{{$item.Identify}}" data-book="{{$item.BookName}}" data-action="{{urlfor "ManagerController.DeleteBook"}}?book_id={{$item.BookId}}" title="删除书籍" class="btn btn-danger btn-del-book" data-toggle="tooltip"><i class="fa fa-recycle" aria-hidden="true"></i> 删除书籍</a>
                                    </div>

                                    <div class="clearfix"></div>
                                </div>
                                <div class="desc-text">
                                    {{if eq $item.Description ""}}
                                    &nbsp;
                                    {{else}}
                                            {{$item.Description}}
                                    {{end}}
                                </div>
                                <div class="info">
                                    <span title="创建时间" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-clock-o"></i>
                                        {{date $item.CreateTime "Y-m-d H:i:s"}}
                                    </span>
                                    <span title="创建者" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-user"></i> {{$item.CreateName}}</span>
                                    <span title="文档数量" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-pie-chart"></i> {{$item.DocCount}}</span>
                                   {{if ne $item.LastModifyText ""}}
                                    <span title="最后编辑" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-pencil"></i> 最后编辑: {{$item.LastModifyText}}</span>
                                    {{end}}
                                    <div class="pull-right pull-right-sort">
                                        <div class="form-group">
                                            <input type="number" name="order_index" data-url="{{urlfor "ManagerController.UpdateBookSort"}}?book_id={{$item.BookId}}" class="form-control change-update" placeholder="请输入文档排序值，数值越大越靠前" value="{{$item.OrderIndex}}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        {{else}}
                        <div class="text-center">暂无数据</div>
                        {{end}}
                    </div>
                    <nav class="pagination-container">
                        {{.PageHtml}}
                    </nav>
                </div>
            </div>
        </div>
    </div>
</div>



<!-- Delete Book Modal -->
<div class="modal fade" id="deleteBookModal" tabindex="-1" role="dialog" aria-labelledby="deleteBookModalLabel">
    <div class="modal-dialog" role="document">
        <form method="post" id="deleteBookForm" class="ajax-form" action="">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">删除书籍</h4>
                </div>
                <div class="modal-body">
                    <div class="help-block">当前书籍名称为<span class="text-danger book-name"></span>，标识为 <span class="text-danger book-identify"></span> ；删除书籍后将无法找回。</div>
                    <div class="help-block">如确定删除，请输入当前文档标识和您的登录密码。</div>
                    <div class="input-group">
                        <span class="input-group-addon">文档标识</span>
                        <input type="text" name="identify" autocomplete="off" class="form-control">
                    </div>
                    <br>
                    <div class="input-group form-group">
                        <span class="input-group-addon">登录密码</span>
                        <input type="password" name="password" autocomplete="off" class="form-control">
                    </div>
                </div>
                <div class="modal-footer">
                    <span id="form-error-message2" class="error-message"></span>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-danger btnDeleteBook" data-loading-text="删除中...">确定删除</button>
                </div>
            </div>
        </form>
    </div>
</div>


<!-- 批量删除书籍 -->
<div class="modal fade" id="deleteBooksModal" tabindex="-1" role="dialog" aria-labelledby="deleteBooksModalLabel">
    <div class="modal-dialog" role="document">
        <form method="post" id="deleteBooksForm" class="ajax-form" action="{{urlfor "ManagerController.DeleteBook"}}">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">批量删除书籍</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group wait2del">
                        <div><strong>请勾选需要批量删除的书籍</strong></div>
                        <ul>
                            {{range $index,$item := .Lists}}
                            <li><label><input type="checkbox" name="book_id" value="{{$item.BookId}}"> {{$item.BookName}}</label></li>
                            {{end}}
                        </ul>
                    </div>
                    <div class="input-group form-group">
                        <span class="input-group-addon">登录密码</span>
                        <input type="password" name="password" autocomplete="off" class="form-control">
                    </div>
                </div>
                <div class="modal-footer">
                    <span id="form-error-message2" class="error-message"></span>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-danger btnDeleteBook" data-loading-text="删除中...">确定删除</button>
                </div>
            </div>
        </form>
    </div>
</div>

{{/*<script src="/static/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>*/}}
<script src="{{$.StaticDomain}}/static/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
{{/*<script src="/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>*/}}
<script src="{{$.StaticDomain}}/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script src="{{$.StaticDomain}}/static/vuejs/vue.min.js" type="text/javascript"></script>
<script src="{{$.StaticDomain}}/static/js/jquery.form.js" type="text/javascript"></script>
<script src="{{$.StaticDomain}}/static/js/toast.script.js" type="text/javascript"></script>
<script src="/static/js/main.js?version={{$.Version}}" type="text/javascript"></script>
<script>
    $(".btn-del-book").click(function () {
       var _this=$(this),bookName=_this.attr("data-book"),identify=_this.attr("data-identify"),
               action=_this.attr("data-action"),$modal=$("#deleteBookModal");
        $modal.find(".book-identify").text(identify);
        $modal.find(".book-name").text(bookName);
        $modal.find("form").attr("action",action);
        $modal.modal("show");
    });
</script>
</body>
</html>