<commit_before><!-- Element representing a 'Group' page. -->

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/core-ajax/core-ajax.html">
<link rel="import" href="main-card.html">
<link rel="import" href="group-members.html">
<link rel="import" href="tick-list.html">
<link rel="import" href="person-list.html">
<link rel="import" href="tick-card/tick-card.html">
<link rel="import" href="ticker-signup.html">
<link rel="import" href="add-session.html">
<link rel="import" href="file-browser/file-browser-card.html">

<link rel="import" href="../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../bower_components/core-collapse/core-collapse.html">

<polymer-element name="x-group" attributes="gid name info creator">
	<template>
		<link rel="stylesheet" type="text/css" href="../css/elements/group.css" shim-shadowdom>

		<!-- User roles API call. -->
		<core-ajax id="roleAjax"
			url="{{'http://urop2014.dtg.cl.cam.ac.uk/UROP_UI/api/user/' + gid + '/roles'}}"
			handleAs="json" on-core-response="{{roleResponse}}">
		</core-ajax>

		<!-- Available signup sheets API call. -->
		<core-ajax id="sheetListAPI"
			url="{{'http://urop2014.dtg.cl.cam.ac.uk/UROP_UI/api/signups/groups/' + gid }}"
			handleAs="json"
			on-core-response="{{sheetListResponse}}">
		</core-ajax>

        <main-card animated>
            <paper-tabs id="tabs" selected="0">
                <paper-tab>{{name}}</paper-tab>
                <paper-tab>TICKS</paper-tab>
                <!-- Need to somehow dynamically hide this -->
                    <paper-tab>TICKING SESSIONS</paper-tab>

                <paper-tab>MEMBERS</paper-tab>
            </paper-tabs>


            <core-collapse id="overview" opened>
                <div id="details" layout vertical start>
                    <div layout horizontal end style="width: 100%;">
                        <p class="creator">Created by: {{creator}}</p>

					<span layout horizontal end end-justified flex>
						<template if="{{isAuthor}}">
                            <paper-icon-button id="groupDeleteButton" icon="delete"></paper-icon-button>
                            <paper-icon-button id="groupCloneButton" icon="content-copy"></paper-icon-button>
                            <paper-icon-button id="groupEditButton" icon="create"></paper-icon-button>
                        </template>
					</span>
                    </div>

                    <div id="infoContainer">
                        <div style="padding: 15px">
                            <template if="{{info}}">
                                <h2>DESCRIPTION:</h2>
                                <p>{{info}}</p>
                            </template>

                            <template if="{{sheets}}">
                                <div layout horizontal center style="margin: 0; padding: 0;">
                                    <h2>TICKING SESSIONS:</h2>
                                    <template if="{{isAuthor}}">
                                        <add-session></add-session>
                                    </template>
                                </div>
                                <template repeat="{{sheet in sheets}}">
                                    <p>{{sheet.title}}, <i style="color: #7C7C7C; font-size: 0.9rem;">{{sheet.location}}</i></p>
                                </template>
                            </template>
                        </div>
                    </div>
                </div>
            </core-collapse>

            <core-collapse id="ticks">
                <tick-list gid="{{gid}}" on-fork-clicked="{{forkClickedHandler}}"
                           canFork="{{isSubmitter}}"></tick-list>
            </core-collapse>

            <core-collapse id="groups">
                <group-members gid="{{gid}}" allowAdd="{{isAuthor}}" rows="4"></group-members>
            </core-collapse>
		</main-card>
		
		<!-- <div id="headerBar" layout horizontal center>
			<h1 flex>Members ({{number}})</h1>
			<template if="{{allowAdd}}">
				<paper-icon-button icon="delete" on-click="{{deleteMemberClicked}}"></paper-icon-button>
				<paper-icon-button icon="add" on-click="{{addMemberClicked}}" core-overlay-toggle></paper-icon-button>
			</template>
			<search-box id="searchBox" placeholder="Search..."></search-box>
		</div>-->


		<!-- Tick list card. -->


		<template if="{{selectedTickId}}">
			<main-card animated>
			<tick-card id="tickCard"
				tickName="{{selectedTickName}}"
				tickId="{{selectedTickId}}"
				sheets="{{sheets}}"
				repoName="{{repoName}}"></tick-card>
		</main-card>
		</template>

        <template if="{{repoName}}">
            <main-card animated>
                <file-browser-card tickId="{{selectedTickId}}"
                                   repoName="{{repoName}}">
                </file-browser-card>
            </main-card>
        </template>

        <core-collapse id="tickingSessions">
            <template if="{{isMarker}}">
                <ticker-signup groupId="{{gid}}" on-main-card-swipe-away="{{cardSwiped}}"></ticker-signup>
            </template>
        </core-collapse>
		<!-- Group content card. -->
		<!-- <main-card animated>
			<paper-tabs selected=0 on-core-select="{{tabSelectedAction}}">
				<template repeat="{{role in roles}}">
					<paper-tab>{{role}}</paper-tab>
				</template>
			</paper-tabs>

			<author-pane id="authorPane" gid="{{gid}}" class="hidden"></author-pane>


			<div id="markerPane" class="hidden">Marker Pane</div>
			<div id="overviewPane" class="hidden">Marker Pane</div>
			<div id="submitterPane" class="hidden">Marker Pane</div>
		</main-card> -->

	</template>
	<script>
		Polymer('x-group', {  

			domReady: function () {
				this.$.roleAjax.go();
				this.$.sheetListAPI.go();

                var that = this.$;
                this.$.tabs.addEventListener('core-select', function() {
                    this.tabIndex = that.tabs.selected;
                    console.log(this.tabIndex);

                    that.overview.opened = this.tabIndex == 0;
                    that.ticks.opened = this.tabIndex == 1;
                    that.groups.opened = this.tabIndex == 3;
                    that.tickingSessions.opened = this.tabIndex== 2;
                });
			},

			roleResponse: function() {
				this.roles = this.$.roleAjax.response;

				// Check for permissions.
				this.isAuthor = (this.roles.indexOf('AUTHOR') > -1);
				this.isSubmitter = (this.roles.indexOf('SUBMITTER') > -1);
				this.isMarker = (this.roles.indexOf('MARKER') > -1);
			},

            nameChanged: function() {
                if (this.name != this.name.toUpperCase()) {
                    this.name = this.name.toUpperCase();<commit_msg>Removed unnecessary TODO for contextual tab display<commit_after><!-- Element representing a 'Group' page. -->

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/core-ajax/core-ajax.html">
<link rel="import" href="main-card.html">
<link rel="import" href="group-members.html">
<link rel="import" href="tick-list.html">
<link rel="import" href="person-list.html">
<link rel="import" href="tick-card/tick-card.html">
<link rel="import" href="ticker-signup.html">
<link rel="import" href="add-session.html">
<link rel="import" href="file-browser/file-browser-card.html">

<link rel="import" href="../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../bower_components/core-collapse/core-collapse.html">

<polymer-element name="x-group" attributes="gid name info creator">
	<template>
		<link rel="stylesheet" type="text/css" href="../css/elements/group.css" shim-shadowdom>

		<!-- User roles API call. -->
		<core-ajax id="roleAjax"
			url="{{'http://urop2014.dtg.cl.cam.ac.uk/UROP_UI/api/user/' + gid + '/roles'}}"
			handleAs="json" on-core-response="{{roleResponse}}">
		</core-ajax>

		<!-- Available signup sheets API call. -->
		<core-ajax id="sheetListAPI"
			url="{{'http://urop2014.dtg.cl.cam.ac.uk/UROP_UI/api/signups/groups/' + gid }}"
			handleAs="json"
			on-core-response="{{sheetListResponse}}">
		</core-ajax>

        <main-card animated>
            <paper-tabs id="tabs" selected="0">
                <paper-tab>{{name}}</paper-tab>
                <paper-tab>TICKS</paper-tab>
                <paper-tab>TICKING SESSIONS</paper-tab>
                <paper-tab>MEMBERS</paper-tab>
            </paper-tabs>


            <core-collapse id="overview" opened>
                <div id="details" layout vertical start>
                    <div layout horizontal end style="width: 100%;">
                        <p class="creator">Created by: {{creator}}</p>

					<span layout horizontal end end-justified flex>
						<template if="{{isAuthor}}">
                            <paper-icon-button id="groupDeleteButton" icon="delete"></paper-icon-button>
                            <paper-icon-button id="groupCloneButton" icon="content-copy"></paper-icon-button>
                            <paper-icon-button id="groupEditButton" icon="create"></paper-icon-button>
                        </template>
					</span>
                    </div>

                    <div id="infoContainer">
                        <div style="padding: 15px">
                            <template if="{{info}}">
                                <h2>DESCRIPTION:</h2>
                                <p>{{info}}</p>
                            </template>

                            <template if="{{sheets}}">
                                <div layout horizontal center style="margin: 0; padding: 0;">
                                    <h2>TICKING SESSIONS:</h2>
                                    <template if="{{isAuthor}}">
                                        <add-session></add-session>
                                    </template>
                                </div>
                                <template repeat="{{sheet in sheets}}">
                                    <p>{{sheet.title}}, <i style="color: #7C7C7C; font-size: 0.9rem;">{{sheet.location}}</i></p>
                                </template>
                            </template>
                        </div>
                    </div>
                </div>
            </core-collapse>

            <core-collapse id="ticks">
                <tick-list gid="{{gid}}" on-fork-clicked="{{forkClickedHandler}}"
                           canFork="{{isSubmitter}}"></tick-list>
            </core-collapse>

            <core-collapse id="groups">
                <group-members gid="{{gid}}" allowAdd="{{isAuthor}}" rows="4"></group-members>
            </core-collapse>
		</main-card>
		
		<!-- <div id="headerBar" layout horizontal center>
			<h1 flex>Members ({{number}})</h1>
			<template if="{{allowAdd}}">
				<paper-icon-button icon="delete" on-click="{{deleteMemberClicked}}"></paper-icon-button>
				<paper-icon-button icon="add" on-click="{{addMemberClicked}}" core-overlay-toggle></paper-icon-button>
			</template>
			<search-box id="searchBox" placeholder="Search..."></search-box>
		</div>-->


		<!-- Tick list card. -->


		<template if="{{selectedTickId}}">
			<main-card animated>
			<tick-card id="tickCard"
				tickName="{{selectedTickName}}"
				tickId="{{selectedTickId}}"
				sheets="{{sheets}}"
				repoName="{{repoName}}"></tick-card>
		</main-card>
		</template>

        <template if="{{repoName}}">
            <main-card animated>
                <file-browser-card tickId="{{selectedTickId}}"
                                   repoName="{{repoName}}">
                </file-browser-card>
            </main-card>
        </template>

        <core-collapse id="tickingSessions">
            <template if="{{isMarker}}">
                <ticker-signup groupId="{{gid}}" on-main-card-swipe-away="{{cardSwiped}}"></ticker-signup>
            </template>
        </core-collapse>
		<!-- Group content card. -->
		<!-- <main-card animated>
			<paper-tabs selected=0 on-core-select="{{tabSelectedAction}}">
				<template repeat="{{role in roles}}">
					<paper-tab>{{role}}</paper-tab>
				</template>
			</paper-tabs>

			<author-pane id="authorPane" gid="{{gid}}" class="hidden"></author-pane>


			<div id="markerPane" class="hidden">Marker Pane</div>
			<div id="overviewPane" class="hidden">Marker Pane</div>
			<div id="submitterPane" class="hidden">Marker Pane</div>
		</main-card> -->

	</template>
	<script>
		Polymer('x-group', {  

			domReady: function () {
				this.$.roleAjax.go();
				this.$.sheetListAPI.go();

                var that = this.$;
                this.$.tabs.addEventListener('core-select', function() {
                    this.tabIndex = that.tabs.selected;
                    console.log(this.tabIndex);

                    that.overview.opened = this.tabIndex == 0;
                    that.ticks.opened = this.tabIndex == 1;
                    that.tickingSessions.opened = this.tabIndex== 2;
                    that.groups.opened = this.tabIndex == 3;
                });
			},

			roleResponse: function() {
				this.roles = this.$.roleAjax.response;

				// Check for permissions.
				this.isAuthor = (this.roles.indexOf('AUTHOR') > -1);
				this.isSubmitter = (this.roles.indexOf('SUBMITTER') > -1);
				this.isMarker = (this.roles.indexOf('MARKER') > -1);
			},

            nameChanged: function() {
                if (this.name != this.name.toUpperCase()) {
                    this.name = this.name.toUpperCase();
{'fraction_non_alphanumeric': 0.1771694214876033, 'fraction_numerical': 0.005312868949232586, 'mean_word_length': 1.9246870953819595, 'pattern_counts': {'":': 0, '<': 280, '<?xml version=': 0, '>': 286, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1670027', 'n_tokens_mistral': 4314, 'n_tokens_neox': 3841, 'n_words': 657}