McPringle/sportchef

View on GitHub
src/main/webapp/sportchef_components/sportchef-events/sportchef-events.html

Summary

Maintainability
Test Coverage
<!--
    SportChef – Sports Competition Management Software
    Copyright (C) 2015, 2016 Marcus Fihlon

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

    This program 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 Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../sportchef-ajax/sportchef-ajax.html" />
<link rel="import" href="../sportchef-event/sportchef-event.html" />

<dom-module id="sportchef-events">
    <template>
        <sportchef-ajax api-url="/api/events" ajax-response="{{ajaxResponse}}"></sportchef-ajax>
        <!-- TODO: handle ajax errors -->
        <template is="dom-repeat" items="[[ajaxResponse]]">
            <sportchef-event event="{{item}}"></sportchef-event>
        </template>
    </template>

    <script>
        // register a new element called sportchef-events
        Polymer({
            is: "sportchef-events",
            generateHeaders: function(){
                var headers = {};
                var token = sessionStorage.getItem("token");
                if (token != null) {
                    headers.Token = token;
                }
                return headers;
            }
        });
    </script>
</dom-module>