{{/*
This file is part of SystemTestPortal.
Copyright (C) 2017  Institute of Software Technology, University of Stuttgart

SystemTestPortal is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SystemTestPortal is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with SystemTestPortal.  If not, see <http://www.gnu.org/licenses/>.
*/}}

{{define "content"}}
<div class="row">
    <div class="todo-list-header">
        <h4>Your todos</h4>
    </div>
</div>
<hr>
<div class="card">
    <div class="m-4">
    {{ range .TodoList.TODOs }}
        {{ if eq .Done false }}
        <div class="row todo-item" id="todo-item-{{ .Index }}">
            <div class="col">
                <div class="row">
                    <div class="todo-item-author"><a href="/{{ .Author }}">{{ .Author }}</a></div>
                    <div>
                    {{ if eq .Type 0 }}assigned you
                    {{ else }}gave you a todo for
                    {{ end }}
                    </div>
                    <div class="todo-item-ref">
                        <a href="/{{ .ProjectID.ActorID }}/{{ .ProjectID.Project }}/{{ if eq .Reference.Type 0 }}testcases{{ else }}testsequences{{ end }}/{{ .Reference.ID }}">{{ .Reference.ID }}</a>
                    </div>
                </div>
            </div>
            <div class="col-md-auto text-right">
                <div class="todo-item-creation-date">
                        <span class="d-none d-sm-block float-right badge badge-secondary">
                            <time class="timeago" datetime="">{{ .CreationDate }}</time>
                        </span>
                </div>
            </div>
            <div class="col-md-auto text-right">
                <button id="btn-todo-item-done-{{ .Index }}" value="{{ .Index }}" type="button" class="btn btn-secondary btn-todo-item-done"
                        title="Set the todo to done">
                    Done
                </button>
            </div>
        </div>
        <hr>
        {{ end }}
    {{ end }}
    </div>
</div>
<script src="/static/js/todo/todo.js"></script>
<script type="text/javascript">

    $('.timeago').each(function (i, obj) {
        var timeString = $(this).text();
        timeString = timeString.replace(" ", 'T');
        timeString = timeString.replace(" ", '');
        timeString = timeString.replace(" CET", '');
        $(this).text(timeString);
        $(this).attr("datetime", timeString);
    });
    jQuery("time.timeago").timeago();
</script>
{{ end }}