Skip to content

Commit

Permalink
styling + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Green committed Jun 12, 2017
1 parent 46e80d5 commit abff36d
Show file tree
Hide file tree
Showing 33 changed files with 420 additions and 403 deletions.
2 changes: 1 addition & 1 deletion .vscode/symbols.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 9 additions & 26 deletions app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import * as Templates from "./pages/templates.ref";
import { NO_ERRORS_SCHEMA, NgModule } from "@angular/core";

import { AppComponent } from "./app.component";
import { MomentModule } from "angular2-moment";
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedrawer/angular";
import { NgPipesModule } from "ngx-pipes";

@NgModule({
bootstrap: [AppComponent],
Expand All @@ -21,7 +23,9 @@ import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedraw
NativeScriptHttpModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(AppRoutes.appRoutes),
NativeScriptUISideDrawerModule
NativeScriptUISideDrawerModule,
NgPipesModule,
MomentModule
],
declarations: [
AppComponent,
Expand Down Expand Up @@ -79,8 +83,8 @@ import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedraw

Pipes.DisplayDate,
Pipes.FormScoreFormatter,
Pipes.OrderByPipe,
Pipes.GroupByPipe,
// Pipes.OrderByPipe,
// Pipes.GroupByPipe,
Pipes.ScoreFormatter,
Pipes.TitleTransform
],
Expand All @@ -103,31 +107,10 @@ import { NativeScriptUISideDrawerModule } from "nativescript-telerik-ui/sidedraw
// deps: [PageRoute]
// }
],
schemas: [NO_ERRORS_SCHEMA],
// selector: "main",
// designMode: true,
// providers: [Logger,
// GradeCache,
// ClubCache,
// CompetitionCache,
// RegionCache
// ],
// registerElements: [{
// name: "CardView",
// resolver: () => require("nativescript-cardview").CardView
// },
// {
// name: "PullToRefresh",
// resolver: () => require("nativescript-pulltorefresh").PullToRefresh
// },{
// name: "VideoPlayer",
// resolver: () => require("nativescript-videoplayer").Video
// }],
// directives: []
schemas: [NO_ERRORS_SCHEMA]
})
export class AppModule {
constructor(private logger:Providers.Logger)
{
constructor(private logger:Providers.Logger) {
this.logger.Notify("Main Page Starting");
}
}
Expand Down
1 change: 1 addition & 0 deletions app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@import './theme/fonts.scss';
@import './theme/_components.scss';


.inset {
padding: $primary-content-padding;
}
Expand Down
3 changes: 0 additions & 3 deletions app/controls/icons/material-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ import {Directive} from "@angular/core";
}
})
export class MaterialIcon {
constructor() {
console.log("material-icon added");
}
}
1 change: 0 additions & 1 deletion app/controls/icons/nx-icon.css
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
.icon-wrapper2{background-color:#fff;border-style:solid;border-width:1;border-color:#e6e6e6;border-radius:15;height:29;width:29}.icon-wrapper{background-color:#f2f2f2;border-style:solid;border-width:1;border-color:#ccc;border-radius:15;text-align:center;horizontal-align:center;vertical-align:center;height:28;width:28;padding-top:2}.icon-wrapper .icon-text{color:#b3b3b3;font-size:18}
36 changes: 0 additions & 36 deletions app/controls/icons/nx-icon.scss
Original file line number Diff line number Diff line change
@@ -1,36 +0,0 @@
@import "app/theme/_app-variables.scss";

$icon-background-color: #fff;
$icon-background-color1 : darken($icon-background-color, 5% );
$icon-border-color: darken($icon-background-color, 10% );
$icon-border-color2: darken($icon-background-color, 20% );
$icon-font-color: darken($icon-background-color, 30% );

.icon-wrapper2 {
background-color:$icon-background-color;
border-style: solid;
border-width: 1;
border-color: $icon-border-color;
border-radius: 15;
height: 29;
width: 29;
}
.icon-wrapper {
background-color:$icon-background-color1;
border-style: solid;
border-width: 1;
border-color: $icon-border-color2;
border-radius: 15;
text-align: center;
horizontal-align: center;
vertical-align: center;
height: 28;
width: 28;
padding-top: 2;

.icon-text {
color: $icon-font-color;
font-size: 18;
}
}

15 changes: 12 additions & 3 deletions app/controls/icons/nx-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ import { Component, EventEmitter, Input } from "@angular/core";
styleUrls: ["nx-icon.css"],
outputs: ["tap"],
template: `
<StackLayout class="icon-wrapper2" (tap)="click($event)">
<GridLayout rows="*" columns="*" (tap)="click($event)">
<StackLayout class="icon-layer-back">
</StackLayout>
<StackLayout class="icon-layer-front">
</StackLayout>
<StackLayout class="icon-wrapper">
<Label class="icon-text" [material-icon] [text]="iconText"></Label>
<Label *ngIf="iconText" class="icon-text" [material-icon] [text]="iconText"></Label>
<Label *ngIf="justText" class="icon-text" [text]="justText"></Label>
</StackLayout>
</StackLayout>
</GridLayout>
`
})
export class NxIcon {
@Input("text")
public justText: string;

@Input("icon")
public iconText: string;
Expand Down
2 changes: 1 addition & 1 deletion app/controls/nav/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class NxNavRow {
selector:"nx-nav",
styleUrls: ["nav.common.css"],
template:`
<StackLayout class="nx-nav-wrapper">
<StackLayout class="nx-nav nx-nav-wrapper">
<StackLayout class="row1">
<nx-nav-row>
<nx-icon [nav-row-left] icon="menu" (tap)="menuButtonTap($event)"></nx-icon>
Expand Down
36 changes: 20 additions & 16 deletions app/models/models.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Observable } from "rxjs/Rx";

export interface IRegion {
Id: number;
Name: string;
Logo: string;
}

/*
{"Id":17,
"Name":"BUCS 2015 - Day 2 - Finals",
"LocationName":"Sheffield Ice Arena",
"CreatedUtc":"2015-02-22T10:41:22.197Z",
"StartDateTimeUtc":"2015-02-22T09:00:00Z",
"EndDateTimeUtc":"2015-08-23T16:00:00Z",
"LastUploadedUtc":null,
"Published":true,"
Public":true,"Provider":{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":null},"Notices":"None","Documents":null},{"Id":16,"Name":"BUCS 2015 - DAY 1 & Syncro","LocationName":"Sheffield Ice Arena","CreatedUtc":"2015-02-21T16:53:17.077Z","StartDateTimeUtc":"2015-02-21T09:00:00Z","EndDateTimeUtc":"2015-02-21T17:30:00Z","LastUploadedUtc":null,"Published":true,"Public":true,"Provider":{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":null},"Notices":"None","Documents":null}
{"Id":17,
"Name":"BUCS 2015 - Day 2 - Finals",
"LocationName":"Sheffield Ice Arena",
"CreatedUtc":"2015-02-22T10:41:22.197Z",
"StartDateTimeUtc":"2015-02-22T09:00:00Z",
"EndDateTimeUtc":"2015-08-23T16:00:00Z",
"LastUploadedUtc":null,
"Published":true,
"Public":true,
"Provider":{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":null},
"Notices":"None","Documents":null},{"Id":16,"Name":"BUCS 2015 - DAY 1 & Syncro","LocationName":"Sheffield Ice Arena","CreatedUtc":"2015-02-21T16:53:17.077Z","StartDateTimeUtc":"2015-02-21T09:00:00Z","EndDateTimeUtc":"2015-02-21T17:30:00Z","LastUploadedUtc":null,"Published":true,"Public":true,"Provider":{"Id":1,"Name":"BUCS","Logo":"content/logos/bucs-logo.jpg","CompetitionCount":null},"Notices":"None","Documents":null}
*/

export interface ICompetition {
Expand All @@ -33,15 +37,15 @@ export interface ICompetitionGrades {
Grades : IGrade[];
}

//{"Id":3359,"Name":"Bournemouth University","Letter":"B","Competitors":1,"Teams":[]}
// {"Id":3359,"Name":"Bournemouth University","Letter":"B","Competitors":1,"Teams":[]}
export interface IClub {
Id: number;
Letter: string;
Name: string;
Competitors: number;
}

//{"Id":1719,"ClassName":"BUCS 1 Elite Male","CompetitorsInFinal":0,"Discipline":"Individual","Competitors":11,"Enabled":true,"Panel":3}
// {"Id":1719,"ClassName":"BUCS 1 Elite Male","CompetitorsInFinal":0,"Discipline":"Individual","Competitors":11,"Enabled":true,"Panel":3}
export interface IGrade {
Id: number;
ClassName: string;
Expand All @@ -52,6 +56,11 @@ export interface IGrade {
Panel : number;
}

export interface IGroup<TModel> {
Key: any;
Items: Observable<TModel[]>;
}

export interface IPage {
title: string;
page: any;
Expand Down Expand Up @@ -109,8 +118,3 @@ interface ICorrectedScore {
Corrected: boolean;
Correction: number;
}

export interface IGroupOfItem<T> {
key: any;
items: Array<T>;
}
74 changes: 32 additions & 42 deletions app/pages/competition/club/club.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {CompetitionService} from "../../../providers/leagues/competitionService"
import {CompetitorResult} from "../../templates/competitor.results";
import {GradeService} from "../../../providers/leagues/gradeService";
import {Logger} from "../../../providers/logger";
import { Observable } from "rxjs/Rx";

@Component({
selector: "club-list-page",
Expand All @@ -25,14 +26,14 @@ import {Logger} from "../../../providers/logger";
<nx-content (refreshStarted)="refresh($event)">
<StackLayout class="inset">
<nx-list *ngFor="let group of list | orderBy:'key'">
<nx-list *ngFor="let group of List | async">
<nx-header item-top>
<!-- grade name -->
<label [text]="group.key" class="title"></label>
</nx-header>
<!-- competitors in that grade -->
<competitor-result *ngFor="let item of group.items" [competitor]="item"></competitor-result>
<competitor-result *ngFor="let item of group.items | async" [competitor]="item"></competitor-result>
</nx-list>
</StackLayout>
</nx-content>
Expand All @@ -48,64 +49,53 @@ export class ClubPage implements OnInit {
private cache: CompetitionCache) {
this.logger.Notify("club page started");
}

public list: Models.IGroupOfItem<Models.ICompetitorContext>[];

public clubSearch($event : any) {
public list: Observable<Models.IGroup<Models.ICompetitorContext>[]>;

public clubSearch($event : any): void {
this.logger.Notify("Search passed to region");
this.logger.Notify($event);
//this.logger.Notify("Search Term in Regions Page: " + $event.Value);
}

public ngOnInit() {
public ngOnInit(): void {
this.logger.Notify("club-page ngOnInit");

this.loadDetail();
}

public loadDetail() {
let observable = this.clubService
.ListCompetitors(this.context.CompetitionId, this.context.ClubId)
.map(e=> e.json());

observable.subscribe((e : Models.ICompetitor[])=> {
var projection : Models.ICompetitorContext[] = e.map((competitor) => {
let item : Models.ICompetitorContext = {
Expanded : false,
Competitor: competitor
public loadDetail(): Observable<Models.ICompetitor[]> {
let observable: Observable<Models.ICompetitor[]> = this.clubService
.ListCompetitors(this.context.CompetitionId, this.context.ClubId);

this.list = observable
.flatMap(e=> e)
.groupBy(e=> e.Group)
.map(e => {
let items: Observable<Models.ICompetitorContext> = e.map(e=> {
let context : Models.ICompetitorContext = {
Competitor : e,
Expanded : false
};
return context;
})
.publishReplay()
.refCount();

let group: Models.IGroup<Models.ICompetitorContext> = {
Key : e.key,
Items: items.toArray()
};
return item;
});

this.list = this.groupByCompetition(projection);
});
return group;
})
.toArray();

return observable;
}

public refresh(args: any) {
public refresh(args: any):void {
this.loadDetail().subscribe(() => {
args.completed();
});
}

private groupByCompetition(items: Models.ICompetitorContext[]) {
let groups : Models.IGroupOfItem<Models.ICompetitorContext>[] = [];

items.forEach(item => {
let existing = groups.filter(e=> e.key === item.Competitor.Group);

if(existing.length > 0) {
existing[0].items.push(item);
return;
}

groups.push({
key : item.Competitor.Group,
items: [ item ]
});
});

return groups;
}
}
2 changes: 1 addition & 1 deletion app/pages/competition/competition.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</nx-header>
<nx-item animate="true" pageTransition="slide" [nsRouterLink]="['startList']">
<nx-icon item-left icon="assignment"></nx-icon>
<label text="Start list"></label>
<label text="Start lists"></label>
<nx-icon item-right icon="chevron_right"></nx-icon>
</nx-item>
<nx-item animate="true" pageTransition="slide" [nsRouterLink]="['gradeList']">
Expand Down
3 changes: 2 additions & 1 deletion app/pages/competition/competition.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ export class CompetitionPage implements OnInit {

this.competition = this.competitionService.Get(competitionId);
this.clubCount = this.clubService.List(competitionId).map(e=> e.length);

let gradeList = this.gradeService.List(competitionId);
this.gradeCount = gradeList.map(e=> e.length);
this.competitorCount = gradeList.map(e=> {
let competitors = e.map(a => a.Competitors);
let total = competitors.reduce((a,b) => a+=b );
let total: number = competitors.reduce((a,b) => a+=b );
return total;
});

Expand Down
Loading

0 comments on commit abff36d

Please sign in to comment.