{% extends 'base.html' %}
{% load i18n %}
{% load static %}
{% load bootstrap3 %}
{% block custom_head_css_js %}
    <link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
    <script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
{% endblock %}
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-10">
            <div class="ibox float-e-margins">
                <div id="ibox-content" class="ibox-title">
                    <h5> {{ action }}</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="panel blank-panel">
                        <div class="panel-body">
                            <div class="tab-content">
                                <form id="groupForm" method="post" class="form-horizontal">
                                    {% csrf_token %}
                                    <h3 class="widget-head-color-box">资产组信息</h3>
                                    {% bootstrap_field form.name layout="horizontal" %}
                                    {% bootstrap_field form.comment layout="horizontal" %}
{#                                    <div class="hr-line-dashed"></div>#}
{#                                    <h3 class="widget-head-color-box">用户选择的资产</h3>#}
{#                                        <div class="form-group">#}
{#                                            <label class="col-sm-2 control-label" id="asset_on_count">已选（{{ assets_count }}）</label>#}
{#                                            <div class="col-sm-9" id="asset_sed">#}
{#                                                <div class="form-asset-on" id="add_asset">#}
{#                                                    <p id="asset_on_p">#}
{#                                                        {% for asset in assets_on_list %}#}
{#                                                        <button name='asset_hostname' title='{{ asset.ip }}' type='button' class='btn btn-default btn-xs'>{{ asset.hostname }}</button>#}
{#                                                       {% endfor %}#}
{#                                                    </p>#}
{#                                                </div>#}
{#                                            </div>#}
{#                                        </div>#}
                                    <div class="hr-line-dashed"></div>
                                    <div class="form-group">
                                        <div class="col-sm-4 col-sm-offset-5">
                                            <button class="btn btn-white" type="reset"> 重置 </button>
                                            <button class="btn btn-primary" type="submit"> 提交 </button>
                                            <div id='box2'> </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog modal-lg">
      <div class="modal-content" id="box">
        <!--此部分为主体内容，将远程加载进来-->
      </div>
   </div>
</div>

{% endblock %}

{% block custom_foot_js %}
<script type="text/javascript">
    $(document).ready(function () {
        $('.select2').select2();
        $('.select2-system-user').select2();
    });

    $('#add_asset').on('click',function(){
        $('#modal').modal('show');
    });

    $('#modal').modal({
        show: false,
        backdrop: 'static',
        keyboard: 'false',
        remote:"{% url 'assets:asset-modal-list' %}?group_id={{ group_id }}"
    });
    $('#modal').on('show.bs.modal',function(){
        //alert('当调用show方法时，立即触发；')
    });

    $('#modal').on('shown.bs.modal',function(){
        //alert('当弹窗完全加载完后，再触发；')
    });

    $('#modal').on('hide.bs.modal',function(){
        //alert('当关闭时，立即触发；')
    });

    $('#modal').on('hidden.bs.modal',function(){
        //alert('当关完全关闭后，再触发；')
    });

    $('#modal').on('loaded.bs.modal',function(){
        //alert('当远程数据加载完毕后，再触发；')
    });

</script>
{% endblock %}