<!DOCTYPE html>
<html>
<head>
    {{ template "inc/select2" . }}
</head>
<body>
    {{ template "inc/nav" . }}

    <div class="all">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Edit Team</h3>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label for="name">Name（a-zA-Z0-9_-.）：</label><input type="text"
                    id="name" class="form-control" value="{{.Team.Name}}" readonly="readonly"/>
                </div>
                <div class="form-group">
                    <label for="resume">Resume：</label> <input
                    type="text" id="resume" class="form-control" value="{{.Team.Resume}}"/>
                </div>
                <div class="form-group">
                    <label for="users">Member：</label> <input
                    type="text" id="users" class="form-control" value="{{.Uids}}"/>
                </div>
                <button type="button" class="btn btn-default" onclick="edit_team('{{.Org.Id}}','{{.Team.Id}}');">
                    <span class="glyphicon glyphicon-floppy-disk"></span>
                    更新
                </button>
                <a href="/teams" class="btn btn-default">
                    <span class="glyphicon glyphicon-arrow-left"></span>
                    返回
                </a>
            </div>
        </div>
    </div>

<script type="text/javascript">
$(function() {
    $("#users").select2({
        placeholder: "输入要添加组员的name",
        allowClear: true,
        multiple: true,
        quietMillis: 100,
        minimumInputLength: 1,
        id: function(obj){return obj.id;},
        initSelection: function(element, callback) {
            $.getJSON("/team/{{.Team.Id}}/users", function(json) {
                callback(json.data);
            });
        },
        ajax: {
            url: "/users/query",
            dataType: 'json',
            data: function(term, page) {
                return {
                    query: term,
                    limit: 20
                };
            },
            results: function(json, page) {
                return {results: json.data};
            }
        },
        formatResult: function(obj) {return obj.name + "["+obj.cnname+"]" + "["+obj.email+"]"},
        formatSelection: function(obj) {return obj.name},
    });
});
</script>
<script src="/js/team.js?_v=0.0.1"></script>
{{ template "inc/footer" . }}

</body>
</html>